Get extrinsic camera parameters from pose estimation
8 views (last 30 days)
Show older comments
Hi,
I have a camera mounted on the roof of a vehicle and try to transform between the image and the world coordinate system. I made a calbration via cameraCalibrator and have the intrinsics, which do look good. Afterwards i tried to get the camera pose via estimateMonoCameraParameters, which gave me following values:
Estimated camera pose:
pitch: -0.6738
yaw: 3.2368
roll: 0.9376
height: 1.7581
which looks totally fine and plausible. My question is now, how can I get the camera matrices Translation, R respectively A from the estimated pitch, yaw, roll angle and height which i got from estimateMonoCameraParameters? If i use
monoCamera(cameraParams.Intrinsics, Camera.height, 'Yaw', Camera.yaw, 'Pitch', Camera.pitch, 'Roll', Camera.roll)
i dont get any more information. Unfortunately the camera position was moved, but before that i had a set of corresponding image and worldpoints and used
Camera.Extrinsics = estimateExtrinsics(imagePoints, worldPoints, Camera.Model.Intrinsics)
to get the extrinsics. Since i do not have any image and worldpoints for the new position, i can not use the estimateExtrinsics function for the new positioned camera. Additionally I was trying to compute the rotation and translation matrices by myself using
tform = rigidtform3d(angles,translation)
and use this as an extrinsics object, but i think I'm missing some additional transformation from the camera to the vehicle coordinate system and I'm not quite sure about the convention of the euler angles.
Is there maybe an easier way to get these camera matrices?
Any help would be appreciated,
Thanks a lot, Jens
0 Comments
Accepted Answer
Matt J
on 12 Sep 2025
Edited: Matt J
on 12 Sep 2025
From the documentation for estimateMonoCameraParameters, it appears that the camera is assumed to lie at a translation of C=[0,0,height] from the world origin. So, the only non-trivial thing seems to be the conversion of yaw,pitch, roll to a rotation matrix. Here's a function that will do that.
function R = ypr2rotm(yaw, pitch, roll)
%YPR2ROTM Convert yaw, pitch, roll angles to a 3x3 rotation matrix
%
% R = YPR2ROTM(yaw, pitch, roll) returns the rotation matrix corresponding
% to the given yaw, pitch, and roll angles (in degrees).
%
% - yaw : rotation about Z-axis (degrees)
% - pitch : rotation about Y-axis (degrees)
% - roll : rotation about X-axis (degrees)
%
% The rotation order is Z (yaw) -> Y (pitch) -> X (roll).
% Rotation about Z (yaw)
Rz = [cosd(yaw) -sind(yaw) 0;
sind(yaw) cosd(yaw) 0;
0 0 1];
% Rotation about Y (pitch)
Ry = [cosd(pitch) 0 sind(pitch);
0 1 0;
-sind(pitch) 0 cosd(pitch)];
% Rotation about X (roll)
Rx = [1 0 0;
0 cosd(roll) -sind(roll);
0 sind(roll) cosd(roll)];
% Combined rotation (Z-Y-X intrinsic order)
R = Rz * Ry * Rx;
end
4 Comments
Matt J
on 15 Sep 2025
Edited: Matt J
on 15 Sep 2025
I think I had a mistake and it should be as below. Keep in mind that I only have your input data to 4 decimal places, so some discrepancies from what you're getting are to be expected.
K =1000*[1.3658 0 0.9591
0 1.3675 0.5472
0 0 0.0010];
yaw = 0.5329; pitch = 0.4282; roll = 0.2161; height = 1.7249;
Q=[0 0 1;
-1 0 0;
0 -1 0]';
R = Q*ypr2rotm(yaw, pitch, roll)';
C = [0;0;height];
Pmatt3 = K*R*[eye(3),-C]
function R = ypr2rotm(yaw, pitch, roll)
%YPR2ROTM Convert yaw, pitch, roll angles to a 3x3 rotation matrix
%
% R = YPR2ROTM(yaw, pitch, roll) returns the rotation matrix corresponding
% to the given yaw, pitch, and roll angles (in degrees).
%
% - yaw : rotation about Z-axis (degrees)
% - pitch : rotation about Y-axis (degrees)
% - roll : rotation about X-axis (degrees)
%
% The rotation order is Z (yaw) -> Y (pitch) -> X (roll).
% Rotation about Z (yaw)
Rz = [cosd(yaw) -sind(yaw) 0;
sind(yaw) cosd(yaw) 0;
0 0 1];
% Rotation about Y (pitch)
Ry = [cosd(pitch) 0 sind(pitch);
0 1 0;
-sind(pitch) 0 cosd(pitch)];
% Rotation about X (roll)
Rx = [1 0 0;
0 cosd(roll) -sind(roll);
0 sind(roll) cosd(roll)];
% Combined rotation (Z-Y-X intrinsic order)
R = Rz * Ry * Rx;
end
More Answers (0)
See Also
Categories
Find more on Camera Sensor Configuration 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!