参数
相机矩阵:包括焦距(fx,fy),光学中心(Cx,Cy),完全取决于相机本身,是相机的固有属性,只需要计算一次,可用矩阵表示如下:[fx, 0, Cx; 0, fy, cy; 0,0,1];
畸变系数:畸变数学模型的5个参数 D = (k1,k2, P1, P2, k3);
相机内参:相机矩阵和畸变系数统称为相机内参,在不考虑畸变的时候,相机矩阵也会被称为相机内参;
相机外参:通过旋转和平移变换将3D的坐标转换为相机2维的坐标,其中的旋转矩阵和平移矩阵就被称为相机的外参;描述的是将世界坐标系转换成相机坐标系的过程。
static void help(char** argv)
{
printf( "This is a camera calibration sample.\n"
"Usage: %s\n"
" -w=<board_width> # the number of inner corners per one of board dimension\n"
" -h=<board_height> # the number of inner corners per another board dimension\n"
" [-pt=<pattern>] # the type of pattern: chessboard or circles' grid\n"
" [-n=<number_of_frames>] # the number of frames to use for calibration\n"
" # (if not specified, it will be set to the number\n"
" # of board views actually available)\n"
" [-d=<delay>] # a minimum delay in ms between subsequent attempts to capture a next view\n"
" # (used only for video capturing)\n"
" [-s=<squareSize>] # square size in some user-defined units (1 by default)\n"
" [-o=<out_camera_params>] # the output filename for intrinsic [and extrinsic] parameters\n"
" [-op] # write detected feature points\n"
" [-oe] # write extrinsic parameters\n"
" [-oo] # write refined 3D object points\n"
" [-zt] # assume zero tangential distortion\n"
" [-a=<aspectRatio>] # fix aspect ratio (fx/fy)\n"
" [-p] # fix the principal point at the center\n"
" [-v] # flip the captured images around the horizontal axis\n"
" [-V] # use a video file, and not an image list, uses\n"
" # [input_data] string for the video file name\n"
" [-su] # show undistorted images after calibration\n"
" [-ws=<number_of_pixel>] # Half of search window for cornerSubPix (11 by default)\n"
" [-dt=<distance>] # actual distance between top-left and top-right corners of\n"
" # the calibration grid. If this parameter is specified, a more\n"
" # accurate calibration method will be used which may be better\n"
" # with inaccurate, roughly planar target.\n"
" [input_data] # input data, one of the following:\n"
" # - text file with a list of the images of the board\n"
" # the text file can be generated with imagelist_creator\n"
" # - name of video file with a video of the board\n"
" # if input_data not specified, a live view from the camera is used\n"
"\n", argv[0] );
printf("\n%s",usage);
printf( "\n%s", liveCaptureHelp );
}
离线文件
-w=4
-h=5
标定图片示例上图中,横向和纵向分别为9个交点和6个交点,对应上面的命令行的命令参数应该为:?-w 9 -h 6。
- 经多次使用发现,不指定 -p参数时计算的结果误差较大,主要表现在对u0,v0的估计误差较大,因此建议使用时加上-p参数
-s=0.025
每格的宽度应设置为实际的毫米数,该参数的实际用途尚待考证。目前看来,即使设置的不准确也无大碍。我使用默认参数50。
<!-- The size of a square in some user defined metric system (pixel, millimeter)-->
<Square_Size>50</Square_Size>
-o=camera.yml
%YAML:1.0
---
calibration_time: "Fri Apr 29 17:00:05 2022"
nframes: 13
image_width: 640
image_height: 480
board_width: 9
board_height: 6
square_size: 2.5000000372529030e-02
flags: 0
camera_matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 5.3646256689600978e+02, 0., 3.4236865068583234e+02, 0.,
5.3641493800336877e+02, 2.3554895558339965e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
rows: 5
cols: 1
dt: d
data: [ -2.7864428555798293e-01, 6.7166038149765392e-02,
1.8241702364718330e-03, -3.4339100766844229e-04, 0. ]
avg_reprojection_error: 4.0902606790992146e-01
per_view_reprojection_errors: !!opencv-matrix
rows: 13
cols: 1
dt: f
data: [ 1.92254305e-01, 1.22073436e+00, 1.69930875e-01,
1.94889039e-01, 1.59580454e-01, 1.80783704e-01, 2.36002639e-01,
2.42605597e-01, 3.02249402e-01, 1.67995840e-01, 2.05065876e-01,
4.64376807e-01, 1.75895900e-01 ]
输出?
-op -oe image_list.xml
list_of_views.txt
该txt文件表示的是你在电脑上面需要用以标定的图片列表。
view00.png
view01.png
#view02.png
view03.png
view10.png
one_extra_view.jpg
上面的例子中,前面加“井号”的图片被忽略。
- 在windows的命令行中,有一种简便的办法来产生此txt文件。在CMD窗口中输入如下命令(假设当前目录里面的所有jpg文件都用作标定,并且生成的文件为a.txt)。
dir *.jpg /B >> a.txt
|