美文网首页
pointnet代码解释

pointnet代码解释

作者: ou源仔 | 来源:发表于2020-12-16 15:40 被阅读0次

ShapeNetDataset

  1. 读取synsetoffset2category.txt文件。查看分类种类和对应文件夹名存放到字典self.cat中以及其键值翻转版本self.id2cat
  2. 读取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为每个类别应该分隔成哪几种。
  3. 索引,大概会说明如何把点云数据转换成网络可以识别的数据。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)

可以使用ros_numpy将rosmsg转换为numpy信息

相关文章

网友评论

      本文标题:pointnet代码解释

      本文链接:https://www.haomeiwen.com/subject/ljvngktx.html