相机校准

Calibrate the Camera
Estimate camera parameters using a set of images of a checkerboard calibration pattern.


% Create a set of calibration images.创建一组矫正相机
images = imageSet(fullfile(toolboxdir('vision'), 'visiondata', ...
    'calibration', 'fishEye'));
imageFileNames = images.ImageLocation;


% Detect calibration pattern. 检测校验模式
[imagePoints, boardSize] = detectCheckerboardPoints(imageFileNames);


% Generate world coordinates of the corners of the squares.生成正方形角落的世界坐标
squareSize = 29; % millimeters
worldPoints = generateCheckerboardPoints(boardSize, squareSize);


% Calibrate the camera.矫正相机
[params, ~, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints);






外参
Extrinsics
You can quickly discover obvious errors in your calibration by plotting relative locations of 
the camera and the calibration pattern. Use the showExtrinsics function to either plot the 
locations of the calibration pattern in the camera's coordinate system, or the locations of
the camera in the pattern's coordinate system.Look for obvious problems, such as the pattern
 being behind the camera, or the camera being behind the pattern. Also check if a pattern is 
too far or too close to the camera.
通过绘制相机的相对位置和校准模式,可以快速发现校准中的明显错误。
使用showextrinsics功能要么情节在摄像机坐标系统校准图案的位置,或位置的相机模式中的坐标系统。
寻找明显的问题,例如相机后面的模式,或者相机在模式后面。还要检查图案是否太远或太靠近照相机。


figure;
showExtrinsics(params, 'CameraCentric');
figure;
showExtrinsics(params, 'PatternCentric');




Reprojection Errors重投影误差
Reprojection errors provide a qualitative measure of accuracy. A reprojection error is the distance 
between a pattern keypoint detected in a calibration image, and a corresponding world point projected 
into the same image. The showReprojectionErrors function provides a useful visualization of the average
reprojection error in each calibration image. If the overall mean reprojection error is too high,
consider excluding the images with the highest error and recalibrating.


重投影误差的准确性提供定性的测量。投影误差是一个模式的关键点在校准图像检测之间的距离,
和一个相应的世界点投影到同一图像。的showreprojectionerrors功能提供了在每个校准图像的平均重投影
误差的一个有用的可视化。如果整体平均重投影误差太大,考虑剔除图像具有最高的误差和调整。


figure;
showReprojectionErrors(params);




Estimation Errors估计误差


Estimation errors represent the uncertainty of each estimated parameter. The estimateCameraParameters function 
optionally returns estimationErrors output, containing the standard error corresponding to each estimated camera 
parameter. The returned standard error  $\sigma$ (in the same units as the corresponding parameter) can be used
to calculate confidence intervals. For example +/-  $1.96 \sigma$ corresponds to the 95% confidence interval. 
In other words, the probability that the actual value of a given parameter is within  $1.96 \sigma$ of its
estimate is 95%.
估计误差表示每个估计参数的不确定性。estimatecameraparameters功能可选的回报估计误差输出,包含标准误差对应于
每个估计相机参数。返回的标准错误$ \ sigma $(与相应参数相同的单位)可以用来计算置信区间。
例如,+ / $ 1.96 \ sigma $对应于95%置信区间。换句话说,给定参数的实际值在1.96美元内的概率是95%。


Interpreting Principal Point Estimation Error分析主点误差
The principal point is the optical center of the camera, the point where the optical axis intersects the image plane.
You can easily visualize and interpret the standard error of the estimated principal point. Plot an ellipse around the 
estimated principal point  $(cx,cy)$, whose radii are equal to 1.96 times the corresponding estimation errors. 
The ellipse represents the uncertainty region, which contains the actual principal point with 95% probability.
主要点是照相机的光学中心,光轴与图像平面相交的点。您可以轻松地可视化和解释估计主点的标准错误。
在估计的主点$(CX,CY)周围画一个椭圆,其半径等于相应估计误差的1.96倍。椭圆表示不确定区域,
其中包含95%概率的实际主点。




principalPoint = params.PrincipalPoint;
principalPointError = estimationErrors.IntrinsicsErrors.PrincipalPointError;


fig = figure;
ax = axes('Parent', fig);
imshow(imageFileNames{1}, 'InitialMagnification', 60, 'Parent', ax);
hold(ax, 'on');


% Plot the principal point.绘制主点
plot(principalPoint(1), principalPoint(2), 'g+', 'Parent', ax);


% Plot the ellipse representing the 95% confidence region.绘制表示95%置信区域的椭圆。
halfRectSize = 1.96 * principalPointError;
rectangle('Position', [principalPoint-halfRectSize, 2 * halfRectSize], ...
    'Curvature', [1,1], 'EdgeColor', 'green', 'Parent', ax);


legend('Estimated principal point');
title('Principal Point Uncertainty');
hold(ax, 'off');




Interpreting Translation Vectors Estimation Errors 分析解释估计误差
You can also visualize the standard errors of the translation vectors. Each translation vector represents the translation 
from the pattern's coordinate system into the camera's coordinate system. Equivalently, each translation vector represents 
the location of the pattern's origin in the camera's coordinate system. You can plot the estimation errors of the translation
 vectors as ellipsoids representing uncertainty volumes for each pattern's location at 95% confidence level.
您还可以可视化翻译向量的标准错误。每一个翻译矢量表示从模式坐标系统到摄像机坐标系的转换。等效地,每一个平移矢量表示图案的原点
在相机坐标系中的位置。你可以绘制的平移向量的估计误差为代表的不确定性量为每个模式的位置,在95%的置信水平的椭球。


% Get translation vectors and corresponding errors.获取编译矢量和相应的错误
vectors = params.TranslationVectors;
errors = 1.96 * estimationErrors.ExtrinsicsErrors.TranslationVectorsError;


% Set up the figure.建图表
fig = figure;
ax = axes('Parent', fig, 'CameraViewAngle', 5, 'CameraUpVector', [0, -1, 0], ...
    'CameraPosition', [-1500, -1000, -6000]);
hold on


% Plot camera location.小块区域摄像头的位置
plotCamera('Size', 40, 'AxesVisible', true);


% Plot an ellipsoid showing 95% confidence volume of uncertainty of绘制一个椭球体,显示不确定度的95%置信体积。
% location of each checkerboard origin. 棋盘格每个原点的位置
labelOffset = 10;
for i = 1:params.NumPatterns
    ellipsoid(vectors(i,1), vectors(i,2), vectors(i,3), ...
        errors(i,1), errors(i,2), errors(i,3), 5)


    text(vectors(i,1) + labelOffset, vectors(i,2) + labelOffset, ...
        vectors(i,3) + labelOffset, num2str(i), ...
        'fontsize', 12, 'Color', 'r');
end
colormap('hot');
hold off


% Set view properties.设置视图的属性
xlim([-400, 200]);
zlim([-100, 1100]);


xlabel('X (mm)');
ylabel('Y (mm)');
zlabel('Z (mm)');


grid on
axis 'equal'
cameratoolbar('Show');
cameratoolbar('SetMode', 'orbit');
cameratoolbar('SetCoordSys', 'Y');
title('Translation Vectors Uncertainty');




提升标定精度的方法
1.改变校准的设置,尝试三个经向畸变系数,估计切线失真或歪斜。
2.建立多角度偏转图片的库,每个图片取多点
3排除法,将较高的重投影和误差大的图排除,重新校准。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值