OpenCV using the calibration diagram

Source: Internet
Author: User

Previous step to generate a calibration map reference the previous article OpenCV generate a calibration map.

After the calibration map is generated, it needs to be printed with A4 paper to get the camera to fiddle with.


The author uses the ImageList Picture List way uses the calibration diagram, namely first uses the camera to take a sub-image, then obtains the distortion parameter by the calibration engineering calibration which is said below--the main reason is not yet figuring out how to get the video stream of this camera (Conway Vision) in real time, The calibration examples of--OPENCV that are currently accessed via HTTP from the browser are supported by the real-time calibration based on the calibration board video stream.


Project to generate a list of calibration diagrams for OpenCV recognition: Opencv248\sources\samples\cpp\imagelist_creator.cpp. Examples of using commands: Imagelist_creator imagelist.yaml *.png. Get Imagelist.yaml as follows:

<?xml version= "1.0"?><opencv_storage><images>  "1.png" "2.png" "3.png" "4.png" "5.png" "6.png" " 7.png "8.png" </images></opencv_storage>

For calibration works using calibration maps, refer to the OPENCV example project: Opencv248\sources\samples\cpp\calibration.cpp. Examples of using commands: Calibration-w 9-h 6-pt chessboard-o camera.yaml-op-oe-su imagelist.xml. The key of the CAMERA.YAML is the parameter matrix and the distortion parameter matrix in the camera:

%yaml:1.0calibration_time: "07/16/15 14:58:18" Camera_matrix:!! Opencv-matrix   rows:3   cols:3   dt:d   data: [5.5977614554147385e+002, 0., 4.3513787505786939e+002, 0.,< c4/>4.1717385931117281e+002, 2.3329672151206768e+002, 0., 0., 1. ]distortion_coefficients:!! Opencv-matrix   rows:5   cols:1   dt:d   data: [ -4.0702020878986456e-001, 2.5025002728793899e-001,       - 3.7768192568471098e-003, -9.1190914257643463e-004,       -1.0546751146845158e-001]

Fortunately, the Calibration.cpp has already included how to calibrate a distorted picture. To sort out the key code:

#include <time.h>void Loadcameraparams (Mat &cameramatrix, Mat &distcoeffs) {Filestorage fs ("Camera.yaml    ", Filestorage::read);    FS ["Camera_matrix"] >> Cameramatrix; FS ["Distortion_coefficients"] >> distcoeffs;} Mat Calibrator (Mat &view) {vector<string> imagelist;static bool Bloadcameraparams = false;static Mat Cameramatrix, Distcoeffs, Map1, MAP2; Mat Rview; Size imagesize,newimagesize;if (!view.data) return Mat (); imagesize.width = View.cols;imagesize.height = View.rows; Newimagesize.width = Imagesize.width;newimagesize.height = imagesize.height;if (Bloadcameraparams = = False) { Loadcameraparams (Cameramatrix, distcoeffs); bloadcameraparams = True;initundistortrectifymap (CameraMatrix, Distcoeffs, Mat (), Getoptimalnewcameramatrix (Cameramatrix, Distcoeffs, ImageSize, 1, newimagesize, 0), Newimagesize, CV _16SC2, Map1, MAP2);} Undistort (view, Rview, Cameramatrix, distcoeffs, Cameramatrix); Remap (view, Rview, Map1, MAP2, inter_linear);//imshow ("Image View", RVIew);//int C = 0xff & Waitkey (); Rview.copyto (view); return view;} 


Problems encountered during the journey and resolution steps:

1, using the camera to finish the calibration picture, use, found the call process crashes. That is, the camera has taken a lot of pictures, still did not find a card can correctly identify the board.

2, the use of OpenCV with the picture opencv248\sources\samples\cpp\leftxx.jpg, turned into PNG, successfully executed. The corner points are traced in the recognized checkerboard.

3, in order to reduce the occurrence of factors, as far as possible to control the single variable, the use of the same row and column leftxx.jpg the same calibration board Picture: 9 Small squares wide, high 6 small squares. Still not recognized.

4, the suspicion is the camera distortion is too serious, resulting in the picture can not be recognized, using a mobile phone camera to try. Because the phone camera distortion is very small, basically can be ignored. The results are not recognizable, though. But the original picture of the phone to the monitor to take pictures of the leftxx.jpg using a gray border, the results can be identified!

5, the camera took pictures, using a gray border, found still can not recognize. If the camera distortion is too serious to identify, it seems not very reasonable, because it is a number game AH. Squares should be better identified. Distortions do not look much larger than leftxx.jpg. The rest can only suspect that the black squares of the printing paper is not obvious, with a brush black (also drunk).

6, finally can identify a part of the picture! It's done, too. By the way to despise a domestic print shop printer quality, black square color is too shallow, I leftxx.jpg foreign printer to play so God color.


The original distorted picture, the calibration tool depicts the distorted picture of the corner point and corrects the picture, taking the same sheet, respectively, as follows:





Added command line batch file, calibration calibration tool, picture package download Link: http://download.csdn.net/detail/lonelyrains/8906705


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

OpenCV using the calibration diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.