You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入相机至MeshLab时位置错位问题求助

相机变换矩阵在Open3D与MeshLab间的导入错位问题

我通过相机对齐得到4x4变换矩阵形式的相机位姿信息,在Open3D中可视化完全正常:物体位于相机中心,RGB轴对应场景原点,代码和显示效果都符合预期。

但将这些相机导入MeshLab时,我编写脚本生成了.mlp项目文件,打开后相机位置出现错位——相机沿Z轴镜像且旋转了180度。

最小复现步骤

可通过以下步骤复现:

  1. git clone https://github.com/flolu/meshlab-camera-transformation
  2. cd meshlab-camera-transformation
  3. conda env create -n meshlab-camera-transformation -f conda.yml(耗时较长)
  4. conda activate meshlab-camera-transformation
  • 执行python visualize_cameras.py查看Open3D中的正常场景
  • 执行python main.py生成MeshLab项目文件

在MeshLab中查看相机的操作:

  1. 打开MeshLab
  2. 文件➝打开项目...➝选择project.mlp
  3. 渲染➝显示相机
  4. 在右下角“显示相机”选项中,将“相机缩放方式”设为“固定系数”,输入0.005作为缩放系数
  5. 滚动缩放视图
  6. 渲染➝显示轴

已尝试的方案

我尝试对相机变换矩阵做反向变换,代码如下:

for transformation_matrix in camera_transformation_matrices:
    # flip z value
    transformation_matrix[2, 3] *= -1

    # swap y and z rotation
    swap_y_and_z = np.array([[0, 0, 1],
                             [0, 1, 0],
                             [1, 0, 0]])
    transformation_matrix[:3, :3] = np.matmul(
        swap_y_and_z, transformation_matrix[:3, :3])

    # rotate transformation_matrix 90 degrees about y axis of the camera
    rotate_90_around_y_axis = np.array([[math.cos(-math.pi/2), 0, math.sin(-math.pi/2)],
                                        [0, 1, 0],
                                        [-math.sin(-math.pi/2), 0, math.cos(-math.pi/2)]])
    T = np.eye(4)
    T[:3, :3] = rotate_90_around_y_axis
    T[:3, 3] = transformation_matrix[:3, 3] - \
        np.matmul(rotate_90_around_y_axis, transformation_matrix[:3, 3])
    transformation_matrix[:4, :4] = np.matmul(T, transformation_matrix)

调整后MeshLab里的相机位置看似正常,但切换到“显示当前光栅模式”查看相机视角时,画面和网格完全不对齐——多数视角看不到网格,而相机本应朝向网格。可执行python failed_try.py生成project_failed_try.mlp测试该情况。

问题

  1. 为什么会出现相机错位的情况?
  2. 如何解决视角未对齐的问题?

内容的提问来源于stack exchange,提问作者Florian Ludewig

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 08:27:39