2020-06-28
点云数据 & 点云处理软件lidar360
用GreenValley International (数字绿土)公司的点云样本数据。
这里是.LiData格式的数据样本:
https://greenvalleyintl.com/sample-data/
这里是GVI的免费软件lidar360 lite的下载地址,可以导入.LiData, 导出为.las,.laz, .ply等格式,其中.ply 可以导入meshlab:
https://www.lidar360.com/archives/4327.html
https://pan.baidu.com/s/1pLNOeCz
(lidar360是数字绿土的主打软件之一,正式版是付费的,但有试用期;lite版是免费的,但功能较少)
其他用到的软件
- 开源软件meshlab
官网下载即可(我下载时很慢,大家可以找找别的地方)
https://www.meshlab.net/ - python
后面的步骤用到了python。 - unity
最后的目的是将彩色3D模型导入unity
步骤(1-8步来自队友)
导入ply点云文件
使用MeshLab降采样(如果点云太密集,构面会可能要花几天甚至几个月;如果不是很大量的数据也可以不用降采样)
Filter -> Point Set ->Point Cloud Simplification
注意生成新的layer之后 要将之前没用的layer删除掉计算法线
Filters -> Normals,Curvatures and Orientation -> Smooth normals on a point sets曲面重建
Filters -> Remeshing,Simplification and Reconstruction -> Surface Reconstruction: Ball PivotingFilters -> Texture -> Parametrization: Trivial Per-Triangle
Filters -> Texture -> Transfer Vertex Attributes to Texture
可能会报找不到文件的错误,你需要把文件放到它指定的目录下面。Filter–> Texture –> Project active rasters color to current mesh, filling thetexture
这一步需要保存projectFilter –> Texturing –>Parameterization + texturing from registered rasters.
然后保存为obj即可-
用以下代码把obj中点的坐标移动到重心
为什么要有这一步呢?因为之前无论怎么试都不成功,最后突然看到.obj文件里的点的坐标值非常大,这说明模型和他的锚点离的相当远,我们找不到他也是正常的。尤其这一组坐标,我试着直接在unity里新建一个立方体,放到这个位置,也显示不出来,说明这么大的坐标值很可能是越界了。
# 1.Read .obj File
inputFile = open('test002.obj', 'r', encoding='UTF-8')
outFile =open("ObjMove2Center.obj","w")
inputString = ''
outputString = ''
try:
inputString = inputFile.read()
finally:
inputFile.close()
# 2. Calculate center position
lines = inputString.split("\n")
Xsum = 0
Ysum =0
Zsum =0
VerticeNum = 0
for line in lines:
# print(line)
if len(line) >1:
if (line[0] == 'v') and (line[1] == ' '):
VerticeNum += 1
values = line.split(' ')
Xsum += float(values[1])
Ysum += float(values[2])
Zsum += float(values[3])
Xavg = Xsum/VerticeNum
Yavg = Ysum/VerticeNum
Zavg = Zsum/VerticeNum
# 3. move to the center
for line in lines:
# print(line)
if len(line) >1:
if (line[0] == 'v') and (line[1] == ' '):
values = line.split(' ')
x = str(float(values[1]) - Xavg)
y = str(float(values[2]) - Yavg)
z = str(float(values[3]) - Zavg)
newLine = 'v ' + x + ' '+ y + ' '+ z
print(newLine)
outputString += newLine
outputString += "\n"
else:
outputString +=line
outputString += "\n"
outFile.write(outputString)
print(outputString)
outFile.close()
参考链接
稠密点云构面:https://blog.csdn.net/qq_42666483/article/details/81034569
meshlab点云构面:https://blog.csdn.net/hanshuobest/article/details/50754766
https://blog.csdn.net/HW140701/article/details/78876507/
https://www.cnblogs.com/hont/p/5239725.html
https://www.jianshu.com/p/f7f3e7b6ebf5
https://blog.csdn.net/qq_33854260/article/details/70884948
导入unity无法显示的问题(第5-8步的来源):
https://stackoverflow.com/questions/62002886/how-to-import-colored-mesh-from-meshlab-to-unitymay-thouth-3ds-max
截图
导入unity结果如下。