ray*_*yon 7 python 3d numpy rotational-matrices open3d
社区,
\n我正在尝试使用 Open3D 将点云与检测到的地板对齐。到目前为止,我实施了以下步骤(此答案的一部分):
\nget_rotation_matrix_from_axis_angle(参见3)结果还不错,但我必须在最后使用优化因子以获得更好的结果。是否有错误或更简单/更精确的对齐方式?
\n# See functions below\n\n# Get the plane equation of the floor \xe2\x86\x92 ax+by+cz+d = 0\nfloor = get_floor_plane(pcd)\na, b, c, d = floor\n\n# Translate plane to coordinate center\npcd.translate((0,-d/c,0))\n\n# Calculate rotation angle between plane normal & z-axis\nplane_normal = tuple(floor[:3])\nz_axis = (0,0,1)\nrotation_angle = vector_angle(plane_normal, z_axis)\n\n# Calculate rotation axis\nplane_normal_length = math.sqrt(a**2 + b**2 + c**2)\nu1 = b / plane_normal_length\nu2 = -a / plane_normal_length\nrotation_axis = (u1, u2, 0)\n\n# Generate axis-angle representation\noptimization_factor = 1.4\naxis_angle = tuple([x * rotation_angle * optimization_factor for x in rotation_axis])\n\n# Rotate point cloud\nR = pcd.get_rotation_matrix_from_axis_angle(axis_angle)\npcd.rotate(R, center=(0,0,0))\n\n# FUNCTIONS \ndef vector_angle(u, v):\n return np.arccos(np.dot(u,v) / (np.linalg.norm(u)* np.linalg.norm(v)))\n\ndef get_floor_plane(pcd, dist_threshold=0.02, visualize=False):\n plane_model, inliers = pcd.segment_plane(distance_threshold=dist_threshold,\n ransac_n=3,\n num_iterations=1000)\n [a, b, c, d] = plane_model \n return plane_model\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
5771 次 |
| 最近记录: |