c++ - 如何从 OpenCV rvecs 计算旋转角度

标签 c++ opencv3.0 aruco

我正在使用 aruco 标记来获取机器人的位置。从 estimatePoseSingleMarkers 获取姿势后,我获得了给定标记的 rvecs 和 tvecs。由此我如何获得标记关于每个轴的旋转角度。

我使用下面的代码来检测和绘制 aruco 标记及其轴

while(true)
{
    vector< vector<Point2f>> corners; //All the Marker corners 
    vector<int> ids;

    cap >> frame;
    cvtColor(frame, gray, CV_BGR2GRAY);

    aruco::detectMarkers(gray, dictionary, corners, ids);
    aruco::drawDetectedMarkers(frame,corners,ids);
    aruco::estimatePoseSingleMarkers(corners, arucoMarkerLength, cameraMatrix, distanceCoefficients, rvecs, tvecs);

    for(int i = 0; i < ids.size(); i++)
    {
        aruco::drawAxis(frame, cameraMatrix, distanceCoefficients, rvecs[i], tvecs[i], 0.1f);
    }

    imshow("Markers", frame);
    int key = waitKey(10);
    if((char)key == 'q')
        break;
}

最佳答案

标记相对于相机的旋转是通过首先从旋转 vector (rvec) 获取旋转矩阵然后获取欧拉角获得的。 Converting Rotation matrix to Eurler angles are given here

关于c++ - 如何从 OpenCV rvecs 计算旋转角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47194914/

相关文章:

python - 如何在numpy中优化此图像迭代?

c++ - 使用 ARUCO 的一个标记来估计引用系统中的相机位姿

c++ - 如何使 *.dll WinAmp 插件在 friend 的电脑上工作

c++ - 定义 BLECharacteristic 时 Genuino 101 不运行

opencv - 使用vector <vector <KeyPoint >>进行OpenCV,SIFT计算

opencv - 平均几个旋转矩阵的正确方法是什么?

python - OpenCV aruco 不能在 Python 中工作(Windows)

c++ - C++ 中的嵌套 try catch 问题

c++ - 如何使 cin 只接受一位数字 C++

c++ - 如何访问 cv::canny 阈值的梯度幅值图像