Getting to camera coordinates from world coordinates. (estimateC​ameraParam​eters)

5 次查看(过去 30 天)
I did a camera calibration, which gives me the cameraParams . I then assumed that I could do
A = cameraParams.PatternExtrinsics(2).A; % I'm interested in the second image
A(:,4) = A(:,4)/1000; % If I dont do in meters, things look terrible.
K = cameraParams.K
WorldPoints = cameraParams.WorldPoints'/1000;
WorldPoints(3,:) = 0; % need a z coordinate for the world points
WorldPoints(4,:) = 1; % need a 4th row, with a one, as according to the 'algorithms' section here: https://nl.mathworks.com/help/vision/ref/estimatecameraparameters.html, what we want to do is impoints=KA[X Y Z 1]'
tmp1 = A*WorldPoints; % need to do this step first, otherwise cannot multiply with camera params
imagePoints = K*tmp1(1:3,:);
imagePoints = imagePoints(1:2,:);%this should be equal to the image coordinates?
realimagePoints = cameraParams.ReprojectedPoints(:,:,2)';% but it's not equal to this
However, the thus obtained imagePoints does not equal realimagePoints(which does agree with the image that I have of the checkerboard that I used). Why is that? And how would I be able to get from the WorldPoints to imagePoints? As far as I understand, this should be possible given the info in cameraParams??

回答(1 个)

Sjoerd
Sjoerd 2024-5-7
Got it. All I needed to do was;
imagePoints(1,:) =imagePoints(1,:)./imagePoints(3,:);
imagePoints(2,:) =imagePoints(2,:)./imagePoints(3,:);

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for USB Webcams 的更多信息

产品


版本

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by