ModelNet40 中加入自己的数据集
ModelNet40 :http://modelnet.cs.princeton.edu/#
含有40个内别的CAD三维模型,是评价点云深度学习模型进行语意分割、实例分割和分类的标准数据集
代码功能:对自己的点云目标进行标准化融合到ModleNet40中
主要步骤:
- 中心化:将点云中心移动到坐标原点;
- 尺度缩放:将所有点的坐标的绝对值限制在1以内;
- 采样:将点云采样到固定大小点数;
- 输出保存文件的格式;
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 21:53:03 2019
@author: sgl
"""
import os
import sys
import numpy as np
import h5py
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
def getDataFiles(list_filename):
return [line.rstrip() for line in open(list_filename)]
def loadDataFile(path):
data = np.loadtxt(path)
num = data.shape[0]
point_xyz = data[:,0:3]
point_normal = data[:,3:6]
point_rgb = data[:,6:9]
# label just a example, should be repalced the real.
# modlenet40 is 0-39, so the label can be 40 and 41
label = np.ones((num,1), dtype=int)+39
return point_xyz, label
def change_scale(data):
#centre
xyz_min = np.min(data[:,0:3],axis=0)
xyz_max = np.max(data[:,0:3],axis=0)
xyz_move = xyz_min+(xyz_max-xyz_min)/2
data[:,0:3] = data[:,0:3]-xyz_move
#scale
scale = np.max(data[:,0:3])
data[:,0:3]

最低0.47元/天 解锁文章
3076

被折叠的 条评论
为什么被折叠?



