matlab标定相机内参

一、获取单目针孔相机数据

在APP中选择Camera Calibrator,如下:
在这里插入图片描述
点击 Add Images,导入拍照图片。标定20张左右就够了,然后角度变一下,但不需要变太大,太大了会影响标定效果。标定板最好在视场中心,且占据较大面积。
在这里插入图片描述
修改棋盘格大小为27*27mm(我的A4纸测量是这样)
在这里插入图片描述
对于标准相机,菜单栏的option里选择三阶径向畸变和斜切:
在这里插入图片描述
而鱼眼相机,选择
在这里插入图片描述

点击Calibrate,进行相机标定:
右上角是重建平均误差,只要平均误差小于0.5,就可以认为这是相机标定的结果是可靠的。这里太大了哈哈哈:
在这里插入图片描述把相机参数导出来,点击 Export Camera Parameters。点击确定,就可以看到matlab工作区出现了相机参数。点开这个参数,就可以得到相机的各个参数:
在这里插入图片描述

  1. ImageSize:图像大小
  2. Radial Distortion:径向畸变
  3. Tangential Distortion:切向畸变
  4. World Points:世界坐标系下的点
  5. World Units:世界坐标下的单位
  6. Estimate Skew:估计倾斜
  7. Num Radial Distortion Coefficient:径向畸变系数个数
  8. Estimate Tangential Distortion:估计切向畸变
  9. Translation Vectors:平移向量
  10. Reprojection Errors: 重投影误差
  11. Detected Keypoints:检测到的关键点
  12. Rotation Vectors:旋转向量
  13. Num Patterns:模态数
  14. Intrinsics:内参
  15. Intrinsic Matrix:内参矩阵
  16. Focal Length:焦距
  17. Principal Point:主点偏移
  18. Skew:偏斜
  19. Mean Reprojection Error:平均重投影误差
  20. Reprojected Points:重投影点
  21. Rotation Matrices:旋转矩阵
    结果如下:
    在这里插入图片描述

二、制作单目相机yaml文件

%YAML:1.0

#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
Camera.type: "PinHole"

# Camera calibration and distortion parameters (OpenCV) 
Camera.fx: 1715.3730
Camera.fy: 1702.5771
Camera.cx: 1129.8076
Camera.cy: 642.5709

Camera.k1: 0.02724
Camera.k2: -0.097636
Camera.k3: 0.10436
Camera.p1: 0.0000127185
Camera.p2: -0.001243

# Camera frames per second 
Camera.fps: 30.0

# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 0

# Camera resolution
Camera.width: 640
Camera.height: 480

#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------

# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000

# ORB Extractor: Scale factor between levels in the scale pyramid 	
ORBextractor.scaleFactor: 1.2

# ORB Extractor: Number of levels in the scale pyramid	
ORBextractor.nLevels: 8

# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast			
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7

#--------------------------------------------------------------------------------------------
# Viewer Parameters
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 5
Viewer.GraphLineWidth: 0.9
Viewer.PointSize: 2
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3
Viewer.ViewpointX: 0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500

三、获取鱼眼相机数据

参考链接。拍照同上。区别在这里
在这里插入图片描述
camera model 选择 fisheye, estimate alignment 选择勾,因为官网解释说

Estimate the axes alignment, specified as the comma-separated pair consisting of ‘EstimateAlignment’ and false or true. Set to true if the optical axis of the fisheye lens is not perpendicular to the image plane.
估计坐标轴的对齐,指定为逗号分隔的一对,由’EstimateAlignment’和false或true组成。如果鱼眼镜头的光轴不垂直于像平面,则设置为true。

计算结果cameraParams中查看Intrinsics
在这里插入图片描述
Mapping Coefficients: 映射系数, [ a 0 a 2 a 3 a 4 ] \left[ \begin{matrix} { {a}_{0}} & { {a}_{2}} & { {a}_{3}} & { {a}_{4}} \end{matrix} \right] [a0a2a3a4], a 1 = 1 { {a}_{1}}=1 a1=1
Image Size: 图像大小
Distortion Center: 畸变中心
Stretch Matrix: 拉伸变换, [ c d e 1 ] \left[ \begin{matrix} c & d \\ e & 1 \\\end{matrix} \right] [ced1]

猜你喜欢

转载自blog.csdn.net/miracle_world/article/details/127748071