logo资料库

Matlab相机标定工具箱(Camera Calibration Toolbox for Matlab)实验.pdf

第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
资料共9页,剩余部分请下载后查看
一、原始数据
二、实验过程
1、安装工具箱
2、读入影像
3、提取角点
4、标定
5、相机的外参数
6、投影误差分析
7、考虑畸变系数后重新标定
8、重标定后的投影误差再分析
9、对影像进行纠正
三、结果
武汉大学测绘学院 Matlab 相机标定工具箱实验 (Camera Calibration Toolbox for Matlab) Hu Yulei @sgg.whu 2012.11.12 一、原始数据 image 文件夹下的 9 张影像(以前做相机标定时用笔记本摄像头采集的数据) 1600pixel*1200pixel 二、实验过程 1、安装工具箱 下载相机标定工具箱(Camera Calibration Toolbox for Matlab),并加载到系统路径。 http://www.vision.caltech.edu/bouguetj/calib_doc/#start 2、读入影像
武汉大学测绘学院 Calibration images 因为第 9 张影像呈现模糊,后面就舍弃了(工具箱的文档说最好用 20~25 张影像)。 3、提取角点 通过简单手动交互,从 Chess1.jpg 提取的角点如下: Extracted corners ) e m a r f a r e m a c n i ( c Y 200 400 600 800 1000 1200 O dY dX 200 400 600 800 Xc (in camera frame) 1000 1200 1400 1600
武汉大学测绘学院 Extracted corners ) e m a r f a r e m a c n i ( c Y 500 550 600 650 700 750 650 700 750 800 Xc (in camera frame) 850 900 950 1000 按文档的说法,角点提取的精度能达到 0.1 pixel。提取角点过程中可以通过设置初始畸 变参数对自动检测到的角点进行调整(可以反复进行),直到对提取到的角点比较满意。 如果镜头畸变太大(如鱼眼相机),可能无法精确提取到角点,只能手动完成角点提取 (即一个一个点击,这是非常耗时的,也是最后的无奈之举!) 4、标定 标定包括两步:初始化、非线性优化。 初始化是在不考虑镜头畸变的情况下计算相机参数,非线性优化过程是基于最小二乘准 则使得像点的反投影误差最小。 结果如下: Calibration parameters after initialization: Focal Length: fc = [ 1568.55714 1568.55714 ] Principal point: cc = [ 799.50000 599.50000 ] Skew: alpha_c = [ 0.00000 ] => angle of pixel = 90.00000 degrees Distortion: kc = [ 0.00000 0.00000 0.00000 0.00000 0.00000 ]尚未考虑畸变差! Main calibration optimization procedure - Number of images: 8 Gradient descent iterations(梯度下降迭代): 1...2...3...4...5...6...7...8...9...10...11...12...13...14...15...16...17...18... 19...20...done Estimation of uncertainties...done Calibration results after optimization (with uncertainties):
武汉大学测绘学院 Focal Length: fc = [ 1582.65925 1583.72173 ] ± [ 28.56101 27.73260 ] Principal point: cc = [ 784.75027 621.28086 ] ± [ 21.57134 18.70249 ] Skew: alpha_c = [ 0.00000 ] ± [ 0.00000 ] => angle of pixel axes = 90.00000 ± 0.00000 degrees Distortion: kc = [ 0.06559 -0.25891 0.00055 0.00569 0.00000 ] ± [ 0.03454 0.13605 0. 00395 0.00507 0.00000 ] Pixel error: err = [ 1.82640 0.86523 ] (可以与后面二次标定的结果比较!) Note: The numerical errors are approximately three times the standard deviations (for reference). 5、相机的外参数 相机坐标系下的视图: Extrinsic parameters (camera-centered) 500 54 0 -500 7 6 2 8 3 1 2000 1800 1600 1400 1200 1000 Zc Xc Oc 800 600 400 200 800 600 400 Yc 0 -200 200 -400 0 世界坐标系下的视图:
武汉大学测绘学院 Extrinsic parameters (world-centered) 7 54 628 13 1600 1400 1200 1000 800 600 400 200 d l r o w Z 0 1600 1400 1200 1000 X: 0 Y: 0 Z: 0 800 600 400 200 0 -200 0 Yw orld 6、投影误差分析 Reprojection error (in pixel) 800 600 400 200 Xw orld y 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -4 -2 0 x 2 4 6 各角点的投影误差区间是 x:(-6.5 , 7),y:(-3.2 , 4.2)(可以与后面二次标定的结果比较!) 上图共有 8 中色彩,表示的是每张影像的投影差,如蓝色表示的是 chess1.jpg 上各个角 点的反投影误差,详情如下图。
武汉大学测绘学院 Image 1 - Image points (+) and reprojected grid points (o) Y O X 200 400 600 800 1000 1200 1400 1600 Image 1 - Image points (+) and reprojected grid points (o) 100 200 300 400 500 600 700 800 900 1000 1100 1200 500 520 540 560 580 600 620 900 920 940 960 980 1000 1020 1040 1060 1080 可以看出 chess1.jpg 上各个角点的投影误差方向有一定的规律性。 误差分析: Pixel error: err = [ 1.82640 0.86523] (all active images) 用鼠标选择误差分布图上的某个点,结果如下: Selected image: 1 # 第一张影像 Selected point index: 22 # 第 22 个角点 Pattern coordinates (in units of (dX,dY)): (X,Y)=(5,7) # 在模板上的坐标 Image coordinates (in pixel): (1219.53,638.01) # 在图像上的坐标 Pixel error = (2.34570,0.40206) # 投影误差 Window size: (wintx,winty) = (13,13) Selected image: 2 Selected point index: 29
武汉大学测绘学院 Pattern coordinates (in units of (dX,dY)): (X,Y)=(4,6) Image coordinates (in pixel): (1147.60,669.70) Pixel error = (-0.29877,0.07599) Window size: (wintx,winty) = (13,13) …… Selected image: 5 Selected point index: 29 Pattern coordinates (in units of (dX,dY)): (X,Y)=(4,6) Image coordinates (in pixel): (801.63,740.93) Pixel error = (0.29962,-0.24884) Window size: (wintx,winty) = (13,13) Selected image: 6 Selected point index: 8 Pattern coordinates (in units of (dX,dY)): (X,Y)=(7,9) Image coordinates (in pixel): (1594.26,890.54) Pixel error = (0.97464,-3.30900) Window size: (wintx,winty) = (13,13) 7、考虑畸变系数后重新标定 Aspect ratio optimized (est_aspect_ratio = 1) -> both components of fc are estimated (DEFAULT). Principal point optimized (center_optim=1) - (DEFAULT). To reject principal point, set center_optim=0 Skew not optimized (est_alpha=0) - (DEFAULT) Distortion not fully estimated (defined by the variable est_dist): Sixth order distortion not estimated (est_dist(5)=0) - (DEFAULT) . Main calibration optimization procedure - Number of images: 8 Gradient descent iterations: 1...2...3...4...5...6...7...8...9...10...11...12...13...14...15...16...17...18...19...20...done Estimation of uncertainties...done 上述过程显示并没有进行初始化,因为是从在上次标定的结果的基础上进行优化。 Calibration results after optimization (with uncertainties): 注:下面的?其实都是±。 Focal Length: fc = [ 1593.11040 1596.07192 ] ? [ 18.08120 17.61336 ] Principal point: cc = [ 781.57083 623.99733 ] ? [ 13.63710 11.75612 ] Skew: alpha_c = [ 0.00000 ] ? [ 0.00000 ] => angle of pixel axes = 90.00000 ? 0.00000 de grees Distortion: kc = [ 0.07159 -0.30191 0.00128 0.00712 0.00000 ] ? [ 0.02198 0.08808 0.00248 0.00321 0.00000 ]
武汉大学测绘学院 Pixel error: err = [ 1.01103 0.76628 ]第二次标定的结果显示,x 和 y 方向的标准差都明显减小。 Note: The numerical errors are approximately three times the standard deviations (for reference). 8、重标定后的投影误差再分析 Reprojection error (in pixel) y 4 3 2 1 0 -1 -2 -3 -2 -1 0 x 1 2 3 4 误差区间:x:(-4 , 4.5),y:(-2.5 , 2)。(可以与前面第一次标定的结果比较!) 9、对影像进行纠正 Chess1.jpg
分享到:
收藏