How do I use the 'worldToImage' function?

7 views (last 30 days)
Bryan Rodriguez
Bryan Rodriguez on 23 Aug 2018
Answered: Amal George M on 29 Aug 2018
I am trying to use the function "worldToImage" to superimpose a 3D point cloud representation of an object onto a 2D image. At the outset, I am not 100% sure this is the right function to do this. If there is a better way, then please let me know.
When I run the "worldToImage" function I get an error that says "Undefined function 'worldToImage' for input arguments of type 'double'." I'm not sure I understand what this error means or how to resolve it.
Below is a portion of my test code:
worldPoints = [x, y, z];
R = [1, 1, 1; 1, 1, 1; 1, 1, 1];
t = [0, 0, 0];
projectedPoints = worldToImage(camMatrix,R,t,worldPoints);
In my test code I am simply trying to see how the 3D points are projected onto the 2D image. My worldPoints are my point cloud points which is an Mx3 matrix in 'double'. I'm assuming that this is the problem, but I am not sure how else to input these points to make this function work. Does anyone have any insight?
I've already confirmed that this is not a license or path issue for this function.

Answers (1)

Amal George M
Amal George M on 29 Aug 2018
To my understanding, the intention is to use 'worldToImage' function to project world coordinates onto a 2D Image. Can you check the datatype of the 'camMatrix' variable?
From the documentation, the first argument to ' worldToImage() ' is a 'cameraParameters' object, not a simple matrix.
Also, 'rotationMatrix' corresponding to no rotation is the Identity matrix.

Community Treasure Hunt

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

Start Hunting!