ShapeNetDataset
- 读取synsetoffset2category.txt文件。查看分类种类和对应文件夹名存放到字典
self.cat
中以及其键值翻转版本self.id2cat
。 - 读取train_test_split/shuffled_{}_file_list.json的json文件。创建
self.meta
以类别为key,其value为list。list中为对应文件夹下points和points_label
中同id的标记文件地址元组。用meta
每个id的点云和分割标注文件和对应点云类别组成元组存入list中叫self.datapath
。此外读取../misc/num_seg_classes.txt
将类别和其序号重新排序存入seg_classes。num_seg_classes为每个类别应该分隔成哪几种。 - 索引,大概会说明如何把点云数据转换成网络可以识别的数据。
point_set = np.loadtxt(fn[1]).astype(np.float32)
对有排列规则的txt文件读取为numpy的array。choice
是对point_set进行随机采样npoints
个点后point_set = point_set[choice, :]
重新组成point_set,注意这里的点的个数影响推断的精度。point_set = point_set - np.expand_dims(np.mean(point_set, axis=0), 0)
对点云数据中心化。dist = np.max(np.sqrt(np.sum(point_set ** 2, axis=1)), 0)point_set = point_set / dist # scale
进行坐标归一化。
用自定义点云信息转换为网络输入的步骤(分类任务中)
# 重采样致2500个点
choice = np.random.choice(len(seg), self.npoints, replace=True)
point_set = point_set[choice, :]
# 中心化
point_set = point_set - np.expand_dims(np.mean(point_set, axis=0), 0) # center
# 归一化
dist = np.max(np.sqrt(np.sum(point_set ** 2, axis=1)), 0)
point_set = point_set / dist # scale
# 转换为tensor
point_set = torch.from_numpy(point_set)
网友评论