what's the corresponding theory formula about the function of estimateMonoCameraParameters
1 view (last 30 days)
Show older comments
Hi, when i reading the source code of the function of estimateMonoCameraParameters as follows, i cann't understand the process of implementation.
If someone knows the corresponding theory formula, please give me a hint. I will appreciate it!
[rotationMatrix, translationVector] = extrinsics(imagePoints, worldPoints, intrinsics);
% Compute camera pose in the world coordinate system defined by the board.
orientation = rotationMatrix';
location = -translationVector * rotationMatrix';
isPatternHorizontal = strcmpi(patternOrientation, 'horizontal');
% Rotate the world coordinate sytem attached to the board so that X-axis
% points to the right side of the vehicle.
R = getXAxisRotationMatrix(pattternPosition, isPatternHorizontal);
% Adjust camera position in the new world coordinate sytem.
location = R * location(:);
orientation = orientation * R';
% Rotate the world coordinate sytem attached to the board so that Z-axis
% points up.
R = getZAxisRotationMatrix(isPatternHorizontal);
% Adjust camera position in the new world coordinate sytem.
location = R * location(:);
orientation = orientation * R';
% Rotate 90 degrees around z.
R = [0 1 0; -1 0 0; 0 0 1];
orientation = orientation * R';
% Decompose the rotation matrix into Euler angles.
% This is the inverse operation of the transformation defined in
% monoCamera.rotationMatrix()
R = [0 -1 0; -1 0 0; 0 0 -1] * orientation';
%==========================================================================
function R = getZAxisRotationMatrix(isPatternHorizontal)
if isPatternHorizontal
% Flip Y and Z axis.
R = [1 0 0; 0 -1 0; 0 0 -1];
else
% Rotate -90 degrees around x.
R = [1 0 0; 0 0 1; 0 -1 0];
end
%==========================================================================
function R = getXAxisRotationMatrix(pattternPosition, isPatternHorizontal)
if strcmpi(pattternPosition, 'front')
R = [1 0 0; 0 1 0; 0 0 1];
elseif strcmpi(pattternPosition, 'back')
if isPatternHorizontal
R = [-1 0 0; 0 -1 0; 0 0 1];
else
R = [-1 0 0; 0 1 0; 0 0 -1];
end
elseif strcmpi(pattternPosition, 'left')
if isPatternHorizontal
R = [0 1 0; -1 0 0; 0 0 1];
else
R = [0 0 -1; 0 1 0; 1 0 0];
end
elseif strcmpi(pattternPosition, 'right')
if isPatternHorizontal
R = [0 -1 0; 1 0 0; 0 0 1];
else
R = [0 0 1; 0 1 0; -1 0 0];
end
end
1 Comment
Mochammad Habibi
on 27 Apr 2021
Hi, Have you found any answer? Can we discuss it please? Thank you so much!
Answers (0)
See Also
Categories
Find more on 3-D Scene Control in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!