简体   繁体   English

Pybullet中的旋转矩阵是将世界坐标转换为相机还是将相机转换为世界?

[英]Is the rotation matrix in Pybullet converting world coordinates into camera or camera to world?

I am working on a project, where I need to replace the renderings by pybullet with renders generated with pytorch3d.我正在做一个项目,我需要将 pybullet 的渲染替换为 pytorch3d 生成的渲染。

I figured out that pybullet and pytorch3d have different definitions for the coordinate systems (see these links: pybullet , pytorch3d ; x and z axes are flipped), and I accounted for that in my code.我发现 pybullet 和 pytorch3d 对坐标系有不同的定义(请参阅这些链接: pybulletpytorch3d ;x 和 z 轴被翻转),我在我的代码中解释了这一点。 But I still have inconsistency in the rendered objects.但是我在渲染的对象中仍然存在不一致。 I thought the problem could be that while pytorch3d expects a c2w rotation matrix (ie camera to world), pybullet could probably expect a w2c rotation matrix.我认为问题可能在于,虽然 pytorch3d 需要一个 c2w 旋转矩阵(即相机到世界),但 pybullet 可能需要一个 w2c 旋转矩阵。 However, I cannot find any documentation related to this.但是,我找不到与此相关的任何文档。 Has anyone ever encountered this problem, or maybe can give some useful hint on how to find out what exactly pybullet expects its rotation matrix to be?有没有人遇到过这个问题,或者可以就如何找出 pybullet 期望它的旋转矩阵到底是什么提供一些有用的提示?

Thanks!谢谢!

I assume you are talking about the viewMatrix expected by pybullet.getCameraImage() .我假设您正在谈论viewMatrix pybullet.getCameraImage()预期的 viewMatrix 。 This should indeed be a world-to-camera rotation matrix.这确实应该是一个世界到相机的旋转矩阵。

However, in pyBullet the camera is looking in negative z-direction while I usually expect it to be in positive one.然而,在 pyBullet 中,相机是在负 z 方向看,而我通常认为它是正方向。 I am compensating for this by adding a 180°-rotation around the x-axis:我通过围绕 x 轴添加 180° 旋转来对此进行补偿:

rot_x_180 = np.array(
    [
        [1, 0, 0, 0],
        [0, -1, 0, 0],
        [0, 0, -1, 0],
        [0, 0, 0, 1],
    ]
)
tf_mat = rot_x_180 @ tf_world_to_camera
view_matrix = tf_mat.flatten(order="F")

where tf_world_to_camera is a homogeneous rotation matrix.其中tf_world_to_camera是齐次旋转矩阵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何应用基本矩阵将 3D 点从相机 1 的世界坐标转换为相机 2 的世界坐标 - How to apply the essential matrix to transform a 3D point from camera 1's world coordinate to camera 2's world coordinates 解释相对于定义的世界坐标的旋转矩阵 - Interpreting the rotation matrix with respect to a defined World coordinates 如何将3D世界坐标转换为3D相机坐标 - How convert 3d world coordinates to 3d camera coordinates 相机旋转矩阵 - Camera rotation matrix PyBullet 获取世界中物体的名称 - PyBullet get names of bodies in world OpenCV使用固定的相机位置将2D像素坐标映射到3D世界坐标 - Opencv map 2D pixel coordinates to 3D world coordinates using fixed camera position 使用aruco估算相机的世界位置 - using aruco to estimate the world position of camera 使用OpenCV Python计算相机世界位置 - Calculate camera world position with OpenCV Python 如何使用 cv.calibrateCamera 的 rvecs 和 tvecs 输出将摄像机坐标中的棋盘投影到 OpenCV 中的真实坐标? - How to project a chessboard in camera coordinates to real-world coordinates in OpenCV using rvecs and tvecs outputs of cv.calibrateCamera? OpenCV 相机标定旋转向量转矩阵 - OpenCV camera calibration rotation vector to matrix
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM