Aruco marker : get orientation and position after pose estimation

  aruco, augmented-reality, c++, opencv, pose-estimation

I want to know the real position and orientation of my marker.
If I understood well, tvecs gives me the real position of my marker, I measure the distance with a ruler and it seems be correct even I had sometimes weird values.

If someone has an idea of why ?

Unfortunately, rvecs gives me strange value too and it’s hard to measure. I hold my marker in front of the camera so the angle is approximately at 0° so rvecs needs to return [0, 0, 0] and if i turn my marker of 45° in y, i need to have [0, 45, 0] etc.

Rvecs doesn’t return the orientation of the marker ?

        std::vector<int> ids;
        std::vector<std::vector<cv::Point2f>> corners;

        //Detection of markers
        cv::aruco::detectMarkers(image, dictionary, corners, ids);
        char key = (char) cv::waitKey(waitTime);
        // if at least one marker detected
        if (ids.size() > 0)
        {
            //std::cout << "FOUND " << std::endl;
            cv::aruco::drawDetectedMarkers(imageCopy, corners, ids);

            std::vector<cv::Vec3d> rvecs, tvecs;
            cv::aruco::estimatePoseSingleMarkers(corners, 0.01, cameraMatrix, distCoeffs, rvecs, tvecs);

            // draw axis for each marker
            for(size_t i=0; i<ids.size(); i++)
            {
                cv::aruco::drawAxis(imageCopy, cameraMatrix, distCoeffs, rvecs[i], tvecs[i], 0.1);
                if(key == 65)
                {
                    std::cout << i << std::endl;
                    std::cout << rvecs[i] << std::endl;
                    std::cout << tvecs[i] << std::endl;
                    std::cout << tvecs[i]*rvecs[i] << std::endl;
                    double distance = sqrt( (tvecs[i][0] * tvecs[i][0]) + (tvecs[i][1] * tvecs[i][1]) + (tvecs[i][2] * tvecs[i][2]) );
                    std::cout << distance << std::endl;
                    std::cout << rvecs[i][0] * 100 << " /// " << rvecs[i][1] * 100 << " /// " << rvecs[i][2] << std::endl;
                    fileOut << rvecs[i][0] << "," << rvecs[i][1] << "," << rvecs[i][2] << std::endl;
                }

            }

        }

Here my code, but I don’t think I have done something wrong.
Maybe I should multiply the Rvecs with something ? But for tvecs I don’t need to multiply, I get directly the values

Source: Windows Questions C++

LEAVE A COMMENT