script1
clear
load cameraParams
displayErrors(estimationErrors, cameraParams);
Standard Errors of Estimated Camera Parameters
----------------------------------------------
Intrinsics
----------
Focal length (pixels): [ 6568.2737 +/- 22.8045 6560.9700 +/- 23.0898 ]
Principal point (pixels):[ 2446.9143 +/- 11.7226 1429.3892 +/- 15.3688 ]
Radial distortion: [ -0.0064 +/- 0.0093 -0.1059 +/- 0.0664 ]
Extrinsics
----------
Rotation vectors:
[ -1.0995 +/- 0.0027 0.4616 +/- 0.0018 0.7231 +/- 0.0012 ]
[ -1.1202 +/- 0.0025 -0.4490 +/- 0.0022 -0.6532 +/- 0.0011 ]
[ 0.3608 +/- 0.0021 -0.7476 +/- 0.0018 -0.1435 +/- 0.0011 ]
[ 0.9236 +/- 0.0034 0.3885 +/- 0.0024 1.6344 +/- 0.0009 ]
[ -1.1009 +/- 0.0027 0.4800 +/- 0.0019 0.7143 +/- 0.0012 ]
[ -0.1673 +/- 0.0026 -0.1013 +/- 0.0031 1.5039 +/- 0.0004 ]
[ 0.0849 +/- 0.0018 -0.0065 +/- 0.0018 -0.0234 +/- 0.0002 ]
[ 0.0958 +/- 0.0019 -0.1485 +/- 0.0018 1.5275 +/- 0.0003 ]
[ 0.0275 +/- 0.0018 -0.2246 +/- 0.0024 1.5016 +/- 0.0003 ]
[ -0.5332 +/- 0.0025 -0.6161 +/- 0.0021 1.4283 +/- 0.0009 ]
Translation vectors (inches):
[ 10.6353 +/- 0.2367 3.0658 +/- 0.3100 132.1400 +/- 0.4116 ]
[ -3.3195 +/- 0.2131 10.9201 +/- 0.2745 118.7797 +/- 0.4038 ]
[ -4.1288 +/- 0.2002 -9.6135 +/- 0.2622 111.8675 +/- 0.4297 ]
[ 26.6131 +/- 0.1900 -9.2855 +/- 0.2586 110.8880 +/- 0.4467 ]
[ 11.4750 +/- 0.2373 4.9988 +/- 0.3102 132.3406 +/- 0.4125 ]
[ 19.0897 +/- 0.2050 -9.9572 +/- 0.2734 117.2632 +/- 0.4153 ]
[ -8.5040 +/- 0.1209 -11.9872 +/- 0.1604 67.3922 +/- 0.2397 ]
[ 19.0046 +/- 0.1243 -12.9489 +/- 0.1665 69.4139 +/- 0.2539 ]
[ -1.0049 +/- 0.1214 -12.0291 +/- 0.1604 67.2780 +/- 0.2412 ]
[ 4.4572 +/- 0.2006 -16.3471 +/- 0.2633 112.7032 +/- 0.3812 ]
rotationVector = [ -1.0995 0.4616 0.7231 ];
rotationMatrix = rotationVectorToMatrix(rotationVector)
rotationMatrix =
0.6879 0.2953 -0.6630
-0.7257 0.2657 -0.6347
-0.0113 0.9177 0.3970
load CalibrationSession
calibrationSession
BoardSet = calibrationSession.BoardSet
BoardPoints = BoardSet.BoardPoints;
WorldPoints = BoardSet.WorldPoints;
save BoardData BoardPoints WorldPoints
calibrationSession =
Session with properties:
CameraModel: [1×1 struct]
StandardCameraModelUI: [1×1 struct]
FisheyeCameraModelUI: [1×1 struct]
OptimizationOptions: []
IsFisheyeModel: 0
IsFisheyeSelected: 0
IsFixedIntrinsics: 0
StereoIntrinsics1: []
StereoIntrinsics2: []
StereoIntrinsicsVarName1: []
StereoIntrinsicsVarName2: []
CameraParameters: [1×1 cameraParameters]
EstimationErrors: [1×1 cameraCalibrationErrors]
ShouldExportErrors: 0
BoardSet: [1×1 vision.internal.calibration.tool.BoardSet]
HasEnoughBoards: 1
CanExport: 1
IsChanged: 1
ExtrinsicsView: 'CameraCentric'
ErrorsView: 'BarGraph'
Filename: 'C:\ece564\CV2020-02-05\calibrationSession.mat'
ExportVariableName: 'cameraParams'
ExportErrorsVariableName: 'estimationErrors'
FileName: 'C:\ece564\CV2020-02-05\calibrationSession.mat'
IsValidStereoCameraSession: 0
IsValidSingleCameraSession: 1
BoardSet =
BoardSet with properties:
FullPathNames: {1×10 cell}
BoardSize: [9 9]
BoardPoints: [64×2×10 double]
WorldPoints: [64×2 double]
SquareSize: 3
BoardLabels: {1×10 cell}
BoardIcons: {1×10 cell}
LastNonDetectedPathNames: {1×0 cell}
NumBoards: 10
ImageSize: [2592 4608]
Units: 'inches'
IsStereo: 0
hcam = calibrationSession.CameraParameters
RotationMatrices = hcam.RotationMatrices;
TranslationVectors = hcam.TranslationVectors;
hcam =
cameraParameters with properties:
Camera Intrinsics
Intrinsics: [1×1 cameraIntrinsics]
Camera Extrinsics
RotationMatrices: [3×3×10 double]
TranslationVectors: [10×3 double]
Accuracy of Estimation
MeanReprojectionError: 1.0618
ReprojectionErrors: [64×2×10 double]
ReprojectedPoints: [64×2×10 double]
Calibration Settings
NumPatterns: 10
WorldPoints: [64×2 double]
WorldUnits: 'inches'
EstimateSkew: 0
NumRadialDistortionCoefficients: 2
EstimateTangentialDistortion: 0
R = RotationMatrices(:,:,1)
fprintf("Infinity norm of difference %g\n",norm(rotationMatrix-R,Inf));
disp("check R' * rotationMatrix")
R'*rotationMatrix
Rvec = rotationMatrixToVector(R)
fprintf("Infinity norm of difference %g\n",norm(rotationVector-Rvec,Inf));
R =
0.6879 0.2952 -0.6630
-0.7257 0.2656 -0.6347
-0.0113 0.9178 0.3970
Infinity norm of difference 8.03457e-05
check R' * rotationMatrix
ans =
1.0000 -0.0000 0.0000
0.0000 1.0000 0.0001
-0.0000 -0.0001 1.0000
Rvec =
-1.0995 0.4616 0.7231
Infinity norm of difference 4.42888e-05
v = rodrigues(R)
Rt1 = rotationVectorToMatrix(v)
Rt2 = rotationVectorToMatrix(-v)
disp("Rt1*Rt2");
Rt1*Rt2
v =
1.0995
-0.4616
-0.7231
Rt1 =
0.6879 -0.7257 -0.0113
0.2952 0.2656 0.9178
-0.6630 -0.6347 0.3970
Rt2 =
0.6879 0.2952 -0.6630
-0.7257 0.2656 -0.6347
-0.0113 0.9178 0.3970
Rt1*Rt2
ans =
1.0000 -0.0000 -0.0000
-0.0000 1.0000 0.0000
-0.0000 0.0000 1.0000
-TranslationVectors(2,:)*RotationMatrices(:,:,2)'/12
-TranslationVectors(2,:)*RotationMatrices(:,:,2)/12
t = zeros(10,3);
for n=1:10
t(n,:) = -TranslationVectors(n,:)*RotationMatrices(:,:,n)'/12;
end
t
ans =
-5.8307 6.6143 -4.5973
ans =
-0.3293 -9.4864 -2.9633
t =
6.6160 7.5640 -4.5959
-5.8307 6.6143 -4.5973
-5.9001 -2.7064 -6.7476
-2.5375 -5.0574 -7.6740
6.6337 7.5391 -4.6764
1.0819 3.3013 -9.3081
0.6540 0.5348 -5.6856
0.1022 1.8032 -5.8199
0.0686 0.6657 -5.6566
0.6731 6.6967 -6.7010
n=2;
rgb = imread("2020-02-05_17-48-14.JPG");
imshow(rgb);
ndx = find(WorldPoints(:,2)==0);
ndy = find(WorldPoints(:,1)==0);
mx = find(and(WorldPoints(:,2)==0,WorldPoints(:,1)==21));
my = find(and(WorldPoints(:,2)==21,WorldPoints(:,1)==0));
p = BoardPoints(:,:,n);
hold on
plot(p(ndx,1),p(ndx,2),'b','LineWidth',2);
plot(p(ndy,1),p(ndy,2),'y','LineWidth',2);
text(p(mx,1),p(mx,2),'X','Color','b','FontSize',21);
text(p(my,1),p(my,2),'Y','Color','y','FontSize',21);
fprintf("Translation Vector %g %g %g\n",t(n,:));
hold off
Translation Vector -5.83074 6.61428 -4.59727