Abdelrahman Wael
Abdelrahman Wael

Reputation: 13

How to get the pixel indices from the world coordinates with a calibrated camera in matlab

I have calibrated my camera and I have now cameraParams, rotation and translation matrices (R ,t) I know that there is a way to get the world coordinates from the pixel indices by the function "pointsToWorld(__)" but I want to do the otherwise , I can't find anything about that in the Matlab help ! So I don't know what to do, any suggestions?

Upvotes: 1

Views: 435

Answers (1)

Dima
Dima

Reputation: 39389

Currently you have to do that yourself. If you have R and t, you can use the cameraMatrix function to compute the camera projection matrix P. Then you can compute the projection of a world point into the image as follows:

P = cameraMatrix(cameraParams, R, t);
p = [X, Y, Z, 1] * P;
x = p(1) / p(3);
y = p(2) / p(3);

X, Y, and Z are the world coordinates. x and y are the image coordinates in pixels.

Upvotes: 1

Related Questions