Calculate object points in OpenCV CameraCalibration function

I want to use the opencv Cameracalibration function ( calibrateCamera() ) to calibrate my camera.
According to the opencv document , I have to take at least 10 frames of my chessboard.
But when I want to calculate objectPoints (here, where the internal points of the checkerboard are located), I confuse:

If the source is a camera and the chessboard is moving, itโ€™s easy for me to understand the theoretical basis of the concept, but it is difficult to calculate objectPoints .
The second way is to fix the chessboard and move the camera. But in this solution, I donโ€™t understand how to apply the distance of the camera from the chessboard when calculating objectPoints or in any other way to say about the calibration of the opencv camera, the function will change by distance and direction.

I would appreciate it if you could help me solve my problem.

+6
source share
1 answer

The second approach that you mentioned is the most popular because it is very easy to use.

Say you have the following checkerboard (9,6) , where the side of the square has a length a :

opencv chess calibration http://docs.opencv.org/_images/fileListImage.jpg

Then you simply define your object points as follows:

 // 3D coordinates of chessboard points std::vector<cv::Point3f> objectPoints; for(int y=0; y<6; ++y) { for(int x=0; x<9; ++x) objectPoints.push_back(cv::Point3f(x*a,y*a,0)); } // One vector of chessboard points for each chessboard image std::vector<std::vector<cv::Point3f>> arrayObjectPoints; for(int n=0; n<number_images; ++n) arrayObjectPoints.push_back(objectPoints); 

Basically, since you can choose a 3D coordinate system of your choice, you can use a checkerboard coordinate system, which makes object points very easy to define. Then the calibrateCamera function will take care of evaluating one R, t (relative orientation and translation relative to the selected coordinate system) for each image, as well as one internal matrix K and distortion coefficients D common to all images.

In addition, take care to use the same order for two-dimensional points.

+7
source

All Articles