背景:
当你有一堆点云(pcd格式)以及对于的标记,你想放到PointNet里面训练。你需要把收集的点云(.pcd)存到一个h5文件里。
首先你需要把pcd们写成一个3x1024xN的数据集,3指的是(一个点的维度),1024指的是多少个点,N指的是多少个点云。
然后把标记写成一个1XN的数据集。
合成放到h5文件里。
详见下面代码。
注:项目结构
- src
- main.cpp
- my_io.cpp
- include
- my_io.h
- bin
- xxx.可执行文件
- raw
- xxx1.pcd
- xxx2.pcd
- ..... .pcd
- pcd_names_file.txt
- labels_file.txt
注:这里面的标记文件labels_file.txt,是需要你自己去为你的训练的点云类别去设置的。举个例子,你采了一个苹果的点云,那么你的苹果对应的id也就是标记可以设为0。
那么,
pcd_names_file.txt labels_file.txt
苹果1.pcd 0
香蕉1.pcd 1
苹果2.pcd 0
香蕉2.pcd 1
香蕉3.pcd 1
... ...
注:你使用matlab打开pointnet用的数据集(那些h5文件),你就会看见里面有个labels的数组,数字为0~39。
1. main的代码:
/*Author: AmbitiousRuralDog
Date: 2018/06/28
This a main file to call my_io functions to covert PCL's PCD-type
data to chunk-format HDF5 data
*/
#include <iostream>
#include <string>
#include <time.h>
#include <fstream>
#include "my_io.h"
using namespace std;
int main(int argc, char** argv){
MyIO my_io;
string h5_filename = "trainset1.h5";
my_io.combinePCDsAndLabelsIntoH5File(h5_filename, "raw_data/pcd_names_file1.txt", "raw_data/labels_file1.txt");
cout << "data is writed to " << h5_filename << endl;
return 0;