lzccccc / 3d-bounding-box-estimation-for-autonomous-driving

3d bounding box estimation from monocular image based on 2d bounding box
127 stars 36 forks source link

Camera Calibration Data ? #12

Open MaximumProgrammer opened 4 years ago

MaximumProgrammer commented 4 years ago

Hello i have one question,

which kind of data do we need for the camera calibration data ? because if we want to compute other 3d bounding box especially for other cameras, which camera calibration data do we need to get good results ? or just better results.

Kind Regards.

Joywalker commented 3 years ago

Hi @MaximumProgrammer. For the camera calibration you'll need camera intrinsic parameters which will make the camera calibration matrix.

K = np.array([[fx,  0, c_x], [0, fy, c_y], [ 0,  0,  1 ]])

where, fx, fy - focal distance X, Y c_x, c_y - optical center X, Y in 2D plane.

Assuming your camera and 3D recorded data are in the same coordinate space, for postprocessing the network's output you'll need the projection matrix, which in this case you can get by:

K_proj = np.matmul(K, np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]])

which will give you a 3x4 matrix representing the projection matrix where world Translation and Rotation are 0. The latter case applies when using data recorded with front camera from datasets like nuscenes or kitti, as the Camera that gives RGB images and the LiDAR sensor that records 3D informations are placed on the same plane.

Otherwise, if you use your own dataset, or other cameras (e.g camera on front left/right of the car in NuSCENES) you'll have to compute the K_proj for each individual case. All needed camera calibration parameters are to be found in calib.txt files in KITTI or calibration_data.json from NuSCENES sweeps.

Useful links: http://www.cs.cmu.edu/~16385/s17/Slides/11.1_Camera_matrix.pdf https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/EPSRC_SSAZ/node3.html

MaximumProgrammer commented 3 years ago

Ok Thx, i will take a look at this.

dantp-ai commented 3 years ago

@Joywalker, you have a small closing-paranthesis typo. Instead it should be:

K_proj = np.matmul(K, np.array(
    [
        [1, 0, 0, 0], 
        [0, 1, 0, 0], 
        [0, 0, 1, 0]
    ]
))