Convert tf::Matrix3x3 to cv::Mat [closed]

asked 2021-07-26 09:51:00 -0500

Elektron97 gravatar image

updated 2022-02-22 11:07:18 -0500

lucasw gravatar image

Hi everyone, i tried to convert tf::Matrix3x3 to cv::Mat, but having NaN result. I don't understand why... This is my function:

Mat quat2Mat(geometry_msgs::Quaternion quat)
{
    tf::Quaternion q(quat.x, quat.y, quat.z, quat.w);
    tf::Matrix3x3 m(q);

    Mat rotm_mat(3, 3, CV_64F);

    for(int i = 0; i < 3; i++)
    {
        tf::Vector3 test = m.getRow(i);

        rotm_mat.at<double>(i, 0) = test.getX();
        rotm_mat.at<double>(i, 1) = test.getY();
        rotm_mat.at<double>(i, 2) = test.getZ();
    }

    return rotm_mat;
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Elektron97
close date 2021-07-27 17:00:52.958861