Clear Filters
Clear Filters

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

5 views (last 30 days)
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??

Answers (1)

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

Categories

Find more on MATLAB Support Package for USB Webcams in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!