SysCV / shift-dev

SHIFT Dataset DevKit - CVPR2022
https://www.vis.xyz/shift
MIT License
101 stars 10 forks source link

The projection of 3D box #40

Open LuPaoPao opened 1 year ago

LuPaoPao commented 1 year ago

I projected the 3D box onto the 2D pixel plane, but the orientation of the box was wrong. I did this:

step 1: Convert the orientation to a rotation matrix and then to a quaternion, using the corner points of the box.

def xyz2Quaternion(xyz): rot = np.array(xyz) rot_matrix = R.from_euler("xyz", rot, degrees=False).as_matrix() return Quaternion(matrix=rot_matrix)

step 2: Convert the orientation to a rotation matrix and then to a quaternion, using the corner points of the box. camera_intrinsic= [[640.0, 0.0, 640.0], [0.0, 640.0, 400.0], [0.0, 0.0, 1.0]]} view = np.eye(4) view[:3, :3] = np.array(camera_intrinsic) in_front = corners_3d[2, :] > 0.1 if all(in_front) is False: continue points = corners_3d points = np.concatenate((points, np.ones((1, points.shape[1]))), axis=0) points = np.dot(view, points)[:3, :] points /= points[2, :]

图片