bbenligiray / stag

STag: A Stable Fiducial Marker System
MIT License
187 stars 52 forks source link

How do you get the center position in estimateHomography() of Quad.cpp? #14

Open DavidLeeDoosan opened 3 years ago

DavidLeeDoosan commented 3 years ago

Hello, I deeply study your S-tag program.

I have a question. May I ask you some about making the center position of the mark?

// product of these transformations is the homography H = HarInv * Haffsim;

// locate the projection of the center of the marker
Mat origCenter(3, 1, CV_64FC1);
origCenter.at<double>(0) = 0.5;
origCenter.at<double>(1) = 0.5;
origCenter.at<double>(2) = 1;

origCenter = H * origCenter;
center.x = origCenter.at<double>(0) / origCenter.at<double>(2);
center.y = origCenter.at<double>(1) / origCenter.at<double>(2);

Why do you divide "origCenter.at(2) " from each x, y Coordinator?

In addition, can I get Z Coordinator of the mark center in the camera pose if I take hand-eye calibration?

is it possible?

bbenligiray commented 3 years ago

Hi, @DavidLeeDoosan

Why do you divide "origCenter.at(2) " from each x, y Coordinator?

origCenter is represented as homogeneous coordinates. To convert that to Cartesian (i.e. regular) coordinates, I'm normalizing it. See the links below

http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/BEARDSLEY/node2.html (part c)

https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#convertpointsfromhomogeneous

In addition, can I get Z Coordinator of the mark center in the camera pose if I take hand-eye calibration?

Try using solvePnP to find the camera pose and look at tvec, that may be what you're looking for.

DavidLeeDoosan commented 3 years ago

Hi, bbenligiray.

I got the marker's center from "origCenter = H * origCenter" of estimateHomography(). the marker's center is (x, y). After I calculate cv::solvePnP(objectPoints, corners, cameraMatrix1, distCoeff1, rvec, tvec), I get rvec and tvec. I would like to make X of transpose, Y of transpose and Z of transpose (Tx, Ty, Tz) by using tvec and marker's center.

How can I found transpose tvec of the marker's center?

Thank you for your attention.

Hi, @DavidLeeDoosan

Why do you divide "origCenter.at(2) " from each x, y Coordinator?

origCenter is represented as homogeneous coordinates. To convert that to Cartesian (i.e. regular) coordinates, I'm normalizing it. See the links below

http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/BEARDSLEY/node2.html (part c)

https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#convertpointsfromhomogeneous

In addition, can I get Z Coordinator of the mark center in the camera pose if I take hand-eye calibration?

Try using solvePnP to find the camera pose and look at tvec, that may be what you're looking for.