raulmur / ORB_SLAM2

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

How to get R and P camera calibration matrices? #645

Open salocinx opened 5 years ago

salocinx commented 5 years ago

I am currently experimenting with a stereo camera like this. I am using 2.8mm and optionally 3.6mm lenses with a resolution of 640x480 pixels for the left and right camera/image.

ORB SLAM 2 lets me define several distortion/rectifying parameters withing the settings file (*.yaml), such as:

fx, fy, cx, cy k1, k2, p1, p2

I conducted the OpenCV camera calibration using a chessboard like described here (9x7 inner corners and 70mm square length). Later on I used this automated calibration program from MRPT which gives me the same results with less stumbling blocks.

However, in the YAML settings file from stereo_euroc example I noticed, that I can define these additional parameters for pre-rectifying the images (if I understand this correctly):

D: 1x5 Matrix -> Distortion Coefficients aquired from calibration (fx,fy,cx,cy) ? K: 3x3 Matrix -> Intrinsic Matrix aquired from calibration (k1,k2,p1,p2,k3) ? R: 3x3 Matrix -> Rectification Transformation ? P: 3x4 Matrix -> New Projection Matrix ?

My questions are the following:

A.) Is my assumption correct, that D are the distortion coefficients and K is the intrinsic matrix acquired from the checkboard calibration procedure ?

B.) Is defining fx, fy, cx, cy in settings.yaml sufficient for pre-rectifying the images and successful operation of ORB SLAM 2 ?

C.) Do I need R and P matrices for successful operation of ORB SLAM 2 ?

D.) How can I acquired the R and P matrices? The OpenCV camera calibration procedure with the checkboard does not provide me these matrices, correct ?

NicksonYap commented 5 years ago

Hi @salocinx

I'm also looking into a similar method for this

How did it go? Any luck so far?

Stereo camera calibration is more specifically the rectification matrix for two cameras: https://github.com/raulmur/ORB_SLAM2/issues/89#issuecomment-225924981 https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereorectify

salocinx commented 5 years ago

Hi @NicksonYap

Yes, I successfully calibrated my stereo camera using the ROS calibration tool on Ubuntu 16.04. I asked the same question on stackoverflow.com, since I didn't got any answer here.

Here's the starting point and you'll get all the matrices (D, K, R and P). I guess raulmur did use this as well.

NicksonYap commented 5 years ago

@salocinx

I suppose you followed this guide? http://wiki.ros.org/camera_calibration/Tutorials/StereoCalibration

salocinx commented 5 years ago

@NicksonYap : Yes, that's exactly the guide I followed. There are different versions of ROS for different Linux OS version. I used ROS Kinetic Kane together with Ubuntu 16.04 (Xenial).