zoukankan      html  css  js  c++  java
  • MeshLab中进行点云配准

      MeshLab是一个开源、可移植和可扩展的三维几何处理系统,主要用于交互处理和非结构化编辑三维三角形网格。它支持多种文件格式:

    • import:PLY, STL, OFF, OBJ, 3DS, COLLADA, PTX, V3D, PTS, APTS, XYZ, GTS, TRI, ASC, X3D, X3DV, VRML, ALN
    • export:PLY, STL, OFF, OBJ, 3DS, COLLADA, VRML, DXF, GTS, U3D, IDTF, X3D

      下面来试一下MeshLab中的点云配准功能,为了进行验证,需要先创建两块位置姿态不匹配的点云。这里使用开源的三维建模软件Blender,首先在Blender中按X键删除默认的立方体后,按Shift+A创建一个猴头suzanne(Suzanne is Blender's alternative to more common test models such as the Utah Teapot and the Stanford Bunny),然后添加一个修改器,Subdivision Surface将Render设置为1之后点击Apply。

      接下来将其输出为PLY格式的文件( PLY文件格式是Stanford大学开发的一套三维mesh模型数据格式,它允许以ASCII码格式或二进制形式存储文件,在图形学的研究领域中PLY是种常用且重要的文件格式)

      然后将该猴头在Blender中平移和旋转到另一个位置,这里沿着XYZ轴分别平移了2个单位(Blender中使用键盘命令:GX2、GY2、GZ2),然后绕Z轴旋转了-45°(RZ-45),最后也将其输出为PLY文件。

      这一变换对应的变换矩阵T为:

      在MeshLab中导入这两个文件,渲染模式选为点后可以看到两块点云,如下图所示。

      接着点击工具栏上的Align按钮进行配准,这时会弹出一个Align Tool的对话框。首先要选择参考点云,这里将没有平移旋转的原始点云作为参考,然后点击Glue Here Mesh,选择好之后点云名字前面会出现一个星号。

      然后选择另一块点云,点击Point Based Glueing,这时弹出一个窗口,在两块点云上手动选择匹配点,至少选4对点之后点OK确认。双击鼠标左键进行选择,按住Ctrl双击左键消除选择。

      之后会发现,两块点云基本上重合在了一起,并且第二块点云名字前也出现了一个星号。初始配准之后,我们将进行ICP配准,注意Param ICP Default中的默认参数,根据需要进行修改。如果我们的两块点云大小相同,那么就要勾选Rigid matching选型。如果我们不勾选,那最终的变换矩阵中将会有一个缩放因子。

    • 采样点数目(Sample Number):this is the number of samples it pulls from each mesh to compare to the other meshes. You do not want to make this number too big. A small sample typically works quiet well. 1,000 to 5,000 is usually plenty.
    • Minimal starting distance:this ignores any samples that are outside of this range. Typically for a manually aligned object you want this to be large enough to encompass your 'point picking' error. A value of 5 or 10 (in millimeters) is usually a good start. Once the initial alignements are complete, drop it down to 1mm to 'fine tune'
    • Target distance(相当于均方误差mse):an average alignment error value that the software will try to obtain from the process 
    • 最大迭代次数(Max iteration number):the maximum number of iterations that the software will perform 

      点击Process之后软件开始自动计算,将工程保存为ALN文件(Align Project),之后用文本编辑器打开,可以看到Align文件中每一个点云都有一个代表其位置和姿态的旋转矩阵。

    1.ply
    #
    1.000000 -0.000000 -0.000000 -0.000000 
    0.000000 1.000000 0.000000 -0.000000 
    0.000000 -0.000000 1.000000 -0.000000 
    0.000000 0.000000 0.000000 1.000000 
    2.ply
    #
    0.706755 -0.707458 0.000400 0.000489 
    0.707458 0.706755 0.000011 -2.828475 
    -0.000291 0.000275 1.000000 -1.999996 
    0.000000 0.000000 0.000000 1.000000

      将猴头从位置2变换到位置1的矩阵为T-1

      对比可以看出MeshLab中的Align配准工具正确计算出了变换矩阵T-1。需要注意的是,不要想当然的以为逆矩阵中的移动分量为(-2,-2,-2)T,参考《机器人学导论》中第2章——Spatial descriptions and transformations

    已知B→A的齐次变换矩阵T,则A→B的齐次变换矩阵T-1如下:

    参考:

    http://blog.csdn.net/szchtx/article/details/7587999

    http://download.csdn.net/detail/chx_man/6314891

  • 相关阅读:
    [Typescript] Augmenting Modules with Declarations
    [Postgres] On conflict Do Something Clause in Postgres
    [React] Debug Custom React Hooks With useDebugValue
    为什么不推荐通过Executors直接创建线程池
    JAVA线程池使用注意事项
    Java线程池使用的注意事项
    分布式事务(六)总结提高
    分布式事务(五)源码详解
    分布式事务(三)mysql对XA协议的支持
    分布式事务(二)Java事务API(JTA)规范
  • 原文地址:https://www.cnblogs.com/21207-iHome/p/6034792.html
Copyright © 2011-2022 走看看