Reputation: 53
I'm developing a pose estimation app with OpenCV and ArUco library.
In my scene there are two markers, say A and B.
I know the pose (tvec
and rvec
) of A and B, so the pose is relative to the camera.
I want to know the pose of B relative to A. I know that the OpenCV provides cv::Rodrigues
and i tried to use it, but i think i have a theory lack. This i what i tried:
[...]
cv::Rodrigues(rvecs[0], R1_rodriguez);
cv::Rodrigues(rvecs[1], R2_rodriguez);
cv::Mat R1 = R1_rodriguez;
cv::Mat R2 = R2_rodriguez;
cv::Mat M1 = (cv::Mat_<double>(4,4) <<
R1.at<double>(0,0),R1.at<double>(0,1),R1.at<double>(0,2),tvecs[0][0],R1.at<double>(1,0),R1.at<double>(1,1),R1.at<double>(1,2),tvecs[0][1],R1.at<double>(2,0),R1.at<double>(2,1),R1.at<double>(2,2),tvecs[0][2],0.0,0.0,0.0,1.0);
cv::Mat M2 = (cv::Mat_<double>(4,4) <<
R2.at<double>(0,0),R2.at<double>(0,1),R2.at<double>(0,2),tvecs[1][0],R2.at<double>(1,0),R2.at<double>(1,1),R2.at<double>(1,2),tvecs[1][1],R2.at<double>(2,0),R2.at<double>(2,1),R2.at<double>(2,2),tvecs[1][2],0.0,0.0,0.0,1.0);
cv::Mat M1_inv = M1.inv();
cv::Mat M2inM1 = M1_inv*M2;
So my question is: how can I "map" B to A, so how can I know the pose of B relative to A (knowing the pose in camera frame)? In other words i imagine A as the (0,0,0) and i want to know the pose (so translation and rotation) of B.Thanks in advance.
Upvotes: 0
Views: 668
Reputation: 11
if you already set your world coordinates and you know the pose (rvec & tvec) of A and B relatives to your choosen world coordinate system. For example: you know all the 3 rotation angles and translation vector in x,y,z of A and B from world coordinate system.
Then, in my opinion, all you need to do is to proceed with the obtained pose data by substract/add (depend on the case) the pose of A and B to get the relative pose.
Upvotes: 0