0

I have an cube with 6 aruco markers and trying to find the center of the cube in world coordinates. Basically need to move the known point in the center of the aruco marker down half the length of the cube perpendicular to the face of the marker.

In a car game, this would be similar to finding the next position based on it's velocity and the direction it's going.

I'm not sure how to transform the point a given distance in the opposite direction of rvec. I am after the position in 3D in world coordinates, so this one doesn't help much.

This is what I have so far based on projectPoints() implementation

                Matx33d R;
                Rodrigues(rvecs[i], R);
                Affine3d aff(rvecs[i], tvecs[i]);
                Vec3d move_along_z(0, 0, 0.5f);
                Vec3d new_point = aff*move_along_z; // ??
Chris Gunawardena
  • 6,246
  • 1
  • 29
  • 45
  • your link goes to the fisheye module in OpenCV... not sure if you meant that. As far as I understood you should do the following: find the aruco markers, obtain the pose in 3D, then move perpendicular to the marker (depends on your coordinate system) and you get the center... take a look to [this tutorial](https://docs.opencv.org/3.1.0/d5/dae/tutorial_aruco_detection.html) And as far as I see in the tutorial you have to move -0.5. and it is `move_along_z * aff`since you move towards the center of the marker, and then apply an extra shift to it. Try it and draw it :) – api55 Jan 08 '18 at 11:33

1 Answers1

0

This answer is mostly based on this post.

                double half_side = 0.05;
                cv::Mat rot_mat;
                Rodrigues(rvecs[i], rot_mat);

                 // transpose of rot_mat for easy columns extraction
                 Mat rot_mat_t = rot_mat.t();
                 // transform along z axis
                 double * rz = rot_mat_t.ptr<double>(2); // x=0, y=1, z=2
                 tvecs[i][0] +=  rz[0]*half_side;
                 tvecs[i][1] +=  rz[1]*half_side;
                 tvecs[i][2] +=  rz[2]*half_side;

                aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i],
                                markerLength * 0.5f);

The above code will make the aruco axis float above the marker by transforming it a distance of half_side in the z axis.

Chris Gunawardena
  • 6,246
  • 1
  • 29
  • 45