3
votes

I am a beginner of OpenCV. I want to calibrate stereo camera using opencv . I have two usb-webcam and chessboard pattern of 9x6. I have gone through the tutorials of stereo vision calibration and also the calibration.cpp example in opencv.

I have clicked around 20 images from both camera and stored it in a folder .Also, I made a text file of location of each image as referenced from Martin Paris tutorial.

My question is ? 1. How to call each image for corner detection ? 2. Following the method -Calibrate each camera and then do StereoCalibration ?

I am really stuck . Any help would be highly appreciated.!

1

1 Answers

0
votes

For your first question, in this case you need find the corner for each image separately. For example:

found1 = findChessboardCorners(img1, board_sz, corners1, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
found2 = findChessboardCorners(img2, board_sz, corners2, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);

where board_sz is the size of the board and corners1 are the corners of the chessboard in the image1 and the same for the image 2 (see openCV reference for more detail: http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#findchessboardcorners)

For you second question, you should not calibrate each camera separately. stereoCalibrate do the work for you and store the intrinsics (cameraMatrix1, distCoeffs1 for camera1 and cameraMatrix2, distCoeffs2 for camera2) and extrinsics parameters (R,T, E, F which are the rotation, translation, essential matrix and fundamental matrix):

double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, Size imageSize, OutputArray R, OutputArray T, OutputArray E, OutputArray F, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6), int flags=CALIB_FIX_INTRINSIC 

Note that the intrinsics and extrinsics parameters are input/output.

Here, imagePoints1 and imagePoints2 are a list of corners points, because you need take several pictures of the chessboard in different poses. So, you will do something like this (for each picture):

if (found1 && found2)
{
    imagePoints1.push_back(corners1);
    imagePoints2.push_back(corners2);
    objectPoints.push_back(obj);
    printf ("Corners stored\n");
    success++;
}

If you need more detail, see this post: http://www.jayrambhia.com/blog/stereo-calibration/