Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Matrix rotation error and how pull out a single element

Hi, I have problem with matrix rotation. I am using the module Aruco to receive marker position. Then I use the function Rodrigues () to receive a rotation matrix. I would like to pull out of the matrix as a single element needs to calculate the orientation of the marker. But all the time I error. The following code:

cv::Mat rvecs, tvecs;

    // detect markers and estimate pose
    aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected);
    if (estimatePose && ids.size() > 0)
        aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs, tvecs);
    double currentTime = ((double)getTickCount() - tick) / getTickFrequency();

    Mat R = Mat::zeros(3, 3, CV_64F);
    Rodrigues(rvecs, R);

Here is the formula:

Mat Thz = (atan2 (R (3), R (0))) * (180 / M_PI)

But the problem lies in the variables.

When you use R.at <double> (1, 1) displays a single element matrix. For example, when I give Mat thz = atan2 (R.at <double> (1, 1), R.at <double> (1, 2)); ,

displays error C2440: 'initializing': can not convert from 'double' this' cv :: Mat

How do I convert the matrix R so I can use them with designs and functions atan2?

Matrix rotation error and how pull out a single element

Hi, I have problem with matrix rotation. I am using the module Aruco to receive marker position. Then I use the function Rodrigues () to receive a rotation matrix. I would like to pull out of the matrix as a single element needs to calculate the orientation of the marker. But all the time I error. The following code:

cv::Mat rvecs, tvecs;

    // detect markers and estimate pose
    aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected);
    if (estimatePose && ids.size() > 0)
        aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs, tvecs);
    double currentTime = ((double)getTickCount() - tick) / getTickFrequency();

    Mat R = Mat::zeros(3, 3, CV_64F);
    Rodrigues(rvecs, R);

Here is the formula:

Mat Thz = (atan2 (R (3), R (0))) * (180 / M_PI)

But the problem lies is in the variables.

When you I'm use R.at <double> (1, 1) displays a single element matrix. For example, when I give Mat thz = atan2 (R.at <double> (1, 1), R.at <double> (1, 2)); ,

displays error C2440: 'initializing': can not convert from 'double' this' cv :: Mat

How do I convert the matrix R so I can use them with designs and functions atan2?