raulmur / ORB_SLAM2

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities
Other
9.33k stars 4.69k forks source link

Generating unified stereo parameters for Stereo ORB-SLAM configuration file #980

Open Gordon-4389 opened 3 years ago

Gordon-4389 commented 3 years ago

Hi everyone,

I am attempting to run Stereo ORB-SLAM (EuRoC mode) with a custom dataset (https://www.eth3d.net/slam_datasets). However, I am not able to generate unified stereo parameters as seen in the EuRoC.yaml file in the Stereo Examples.

As shown below, the EuRoC.yaml parameters are:

Camera.fx: 435.2046959714599
Camera.fy: 435.2046959714599
Camera.cx: 367.4517211914062
Camera.cy: 252.2008514404297

Which is the same as the parameters found in the left and right projection matrices in the stereo rectification section:

LEFT.P:  !!opencv-matrix
   rows: 3
   cols: 4
   dt: d
   data: [435.2046959714599, 0, 367.4517211914062, 0,  0, 435.2046959714599, 252.2008514404297, 0,  0, 0, 1, 0]

RIGHT.P:  !!opencv-matrix
   rows: 3
   cols: 4
   dt: d
   data: [435.2046959714599, 0, 367.4517211914062, -47.90639384423901, 0, 435.2046959714599, 252.2008514404297, 0, 0, 0, 1, 0]

However, my problem is that for my dataset, I am given the intrinsics of both cameras (named calibration.txt and calibration2.txt), the extrinsics from the right camera to the left (named extrinsics_1_2.txt) and no distortion parameters (as the images pre-rectified). When I attempt to calculate the projection matrices for both cameras (using the left camera as a base) I am left with differing parameters for both cameras instead of unified values like in the EuRoC.yaml file.

My attempt to calculate the values are as follows, assuming no distortion: P = K*[R|T] where as [R_left|T_left] is an 3x3 identity matrix concatenated with a columns of zeros and [R_right|T_right] is the extrinsics given. My results using MATLAB are as follows:

P_Left =

  726.2874         0  354.6497         0
         0  726.2874  186.4657         0
         0         0    1.0000         0

P_Right =

  726.9647   10.5283  383.8499  -65.0718
   -8.3160  727.0392  259.2905   -0.0724
    0.0025    0.0040    1.0000    0.0003

Have I been performing the wrong calculation, or should I have included distortion parameters into my calculation? Any advice would be extremely useful, thanks.

I've attached the following calibration files used for calculation: calibration.txt (left camera intrinsics) calibration2.txt (right camera intrinsics) extrinsics_1_2.txt (stereo extrinsics)