projecting 2D (x, y) coordinates onto a 3D plane
Show older comments
I'm looking to project 2D points (x, y) from my image onto a 3D plane (X, Y, Z). The plane into which I want to project my points is defined by the position of my checkerboard in one of my calibration images (image 9). However, when using the following formula:
w⎡xy1⎦=K[R∣t]⎡XYZ1⎦
The calculated 3D points do not lie on the specified plane. In fact, I am attaching a photo to my question that shows both the extrinsic parameters of my camera calibration and the detected checkerboard points, reprojected onto the 3D plane using the previously mentioned formula.
I am also attaching a snippet of my code associated with this transformation. Does anyone have a solution to provide? Is there an error in my code or my reasoning?
[param_int]= estimateCameraParameters(imagepoints_tot(:,:,:,1), worldPoints,'EstimateSkew', false, 'EstimateTangentialDistortion', true, ...
'NumRadialDistortionCoefficients', 3, 'WorldUnits', 'mm', ...
'InitialIntrinsicMatrix', [], 'InitialRadialDistortion', [], ...
'ImageSize',imagesize );
%%
Mat_transfo=[param_int.RotationMatrices(:,:,9),transpose(param_int.TranslationVectors(9,:))]
Mat_transfo=transpose(param_int.IntrinsicMatrix)*Mat_transfo
Mat_transfo=pinv(Mat_transfo)
translationVector=[param_int.TranslationVectors(9,:),1]
%%
for i = 1:88
pointsdamier=Mat_transfo*[imagepoints_tot(i,1,9,1);imagepoints_tot(i,2,9,1);1]
pointsdamier=pointsdamier/pointsdamier(4)+transpose(translationVector)
hold on
plot3(pointsdamier(1),pointsdamier(3),pointsdamier(2),'bO','MarkerSize',1)
end
showExtrinsics(param_int)
7 Comments
William Rose
on 15 Dec 2023
You asked "Is there an error in my code or my reasoning?" I cannot answer whether there is an error in the code, because I do not yet understand the reasoning. I cannot tell from the figure you provided exactly where the [x,y] points are. The figure shows a camera with coordinate system Xc,Yc,Zc. The plot has axes X,Y,Z. It appears that the plot axes X,Y,Z have the same orientaiotn and axes as Xc,Yc,Zc. The plot also shows 9 planes embeeded in the 3D space. YOur first line of code estimates the camera position, orientation, etc, based on knowing the worldponts and the imagepoints. Is it your intention to do this? If so, please provide the worldpoints and imagepoints as an attachement, so others can assist you better.
If you have weither the world points or the image points, and you want to know the other, then you nee to supply the camera position and orientaiton, or the plane orientation, and position of its origin, relative to the camera. If that is your intention, provide a point set and the information that deifnes the plane or camera position and orientation.
The camera parameters can only be used to determine the infinite 3D line, extending from the camera center, that your 2D image point corresponds to. To find where that line intersects a 3D plane, which is your goal, you also need to have the equation for that plane. I cannot see in your steps where you incorporate that.
Giuseppe Cecchelli
on 15 Dec 2023
Edited: Giuseppe Cecchelli
on 15 Dec 2023
William Rose
on 15 Dec 2023
@giuseppe, thank you. I will reply tomorrow.
Giuseppe Cecchelli
on 18 Dec 2023
Matt J
on 18 Dec 2023
Attach a .mat file with param_init and imagepoints.
Giuseppe Cecchelli
on 18 Dec 2023
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Support Package for USB Webcams 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!

