what's the corresponding theory formula about the function of estimateMonoCameraParameters
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mochammad Habibi
2021-4-27
Hi, Have you found any answer? Can we discuss it please? Thank you so much!
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Scene Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!