OpenCV Camera Calibration
首先,修改路径下xml文档,存入照片
- <?xml version="1.0"?>
- <opencv_storage>
- <Settings>
- <!-- Number of inner corners per a item row and column. (square, circle) -->
- <BoardSize_Width>9</BoardSize_Width> //设定CHESSBOARD角点
- <BoardSize_Height>6</BoardSize_Height>
- <!-- The size of a square in some user defined metric system (pixel, millimeter)-->
- <Square_Size>50</Square_Size> //标定板方块边长/mm
- <!-- The type of input used for camera calibration. One of: CHESSBOARD CIRCLES_GRID ASYMMETRIC_CIRCLES_GRID -->
- <Calibrate_Pattern>"CHESSBOARD"</Calibrate_Pattern> //标定模式
- <!-- The input to use for calibration. 所采集的标定图像存储的路径及名称xml档
- To use an input camera -> give the ID of the camera, like "1"
- To use an input video -> give the path of the input video, like "/tmp/x.avi"
- To use an image list -> give the path to the XML or YAML file containing the list of the images, like "/tmp/circles_list.xml"
- -->
- <Input>"./vtDirTest.xml"</Input>
- <!-- If true (non-zero) we flip the input images around the horizontal axis.-->
- <Input_FlipAroundHorizontalAxis>0</Input_FlipAroundHorizontalAxis>
- <!-- Time delay between frames in case of camera. -->
- <Input_Delay>100</Input_Delay>
- <!-- How many frames to use, for calibration. -->
- <Calibrate_NrOfFrameToUse>25</Calibrate_NrOfFrameToUse>
- <!-- Consider only fy as a free parameter, the ratio fx/fy stays the same as in the input cameraMatrix.
- Use or not setting. 0 - False Non-Zero - True-->
- <Calibrate_FixAspectRatio> 1 </Calibrate_FixAspectRatio>
- <!-- If true (non-zero) tangential distortion coefficients are set to zeros and stay zero.-->
- <Calibrate_AssumeZeroTangentialDistortion>1</Calibrate_AssumeZeroTangentialDistortion>
- <!-- If true (non-zero) the principal point is not changed during the global optimization.-->
- <Calibrate_FixPrincipalPointAtTheCenter> 1 </Calibrate_FixPrincipalPointAtTheCenter>
- <!-- The name of the output log file. -->
- <Write_outputFileName>"out_camera_vt.xml"</Write_outputFileName> //输出标定后的内参/外参以及其他参数的文档名称路径
- <!-- If true (non-zero) we write to the output file the feature points.-->
- <Write_DetectedFeaturePoints>1</Write_DetectedFeaturePoints>
- <!-- If true (non-zero) we write to the output file the extrinsic camera parameters.-->
- <Write_extrinsicParameters>1</Write_extrinsicParameters>
- <!-- If true (non-zero) we show after calibration the undistorted images.-->
- <Show_UndistortedImage>1</Show_UndistortedImage>
- </Settings>
- </opencv_storage>
运行D:\OPENCV\opencv\sources\samples\cpp\tutorial_code\calib3d\camera_calibration 下camera_calibration.cpp
得到out_camera_vt.xml
内参
Camera_Matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 6.5746697810243404e+002, 0., 3.1950000000000000e+002, 0.,
6.5746697810243404e+002, 2.3950000000000000e+002, 0., 0., 1. ]
rows: 3
cols: 3
dt: d
data: [ 6.5746697810243404e+002, 0., 3.1950000000000000e+002, 0.,
6.5746697810243404e+002, 2.3950000000000000e+002, 0., 0., 1. ]
Extrinsic_Parameters: !!opencv-matrix
rows: 8
cols: 6
dt: d
data: [ -7.8704123655486097e-002, -1.5922384772614945e-001,
3.1166227207451498e+000, 2.4224388101960471e+002,
1.1795590397660339e+002, 6.2576484126093249e+002,
-1.4117480285164308e-001, -1.7917415443804836e-002,
rows: 8
cols: 6
dt: d
data: [ -7.8704123655486097e-002, -1.5922384772614945e-001,
3.1166227207451498e+000, 2.4224388101960471e+002,
1.1795590397660339e+002, 6.2576484126093249e+002,
-1.4117480285164308e-001, -1.7917415443804836e-002,
...
但,OpenCV将这些外参放在一起,不方便分开使用
http://research.microsoft.com/en-us/um/people/zhang/
http://blog.csdn.net/aptx704610875/article/details/48914043
后论内参、外参的使用
运行D:\OPENCV\opencv\sources\samples\cpp\tutorial_code\calib3d\camera_calibration 下camera_calibration.cpp