我正在使用cv :: Mat在地标之间创建转换矩阵。我想从这个垫子上得到欧拉角,但是我无法做到......
我的“数据”(在x,y或z轴上是纯旋转)来测试我的函数:
cq := neoism.CypherQuery{
Statement: stmt,
Parameters: params,
Result: &res,
}
我如何调用我的函数:
float rotPIx[16] = {1,0,0,0,0,cos(CV_PI),-1*sin(CV_PI),0,0,sin(CV_PI),cos(CV_PI),0,0,0,0,1};
float rotPIy[16] = {cos(CV_PI),0,sin(CV_PI),0,0,1,0,0,-1*sin(CV_PI),0,cos(CV_PI),0,0,0,0,1};
float rotPIz[16] = {cos(CV_PI),-1*sin(CV_PI),0,0,sin(CV_PI),cos(CV_PI),0,0,0,0,1,0,0,0,0,1};
const cv::Mat T_ORB_TO_WORLD = cv::Mat(4,4,CV_32F,rotPIx);
我试图获得欧拉角(在x,y,z上旋转):
cout << "full mat " << endl << T_ORB_TO_WORLD << endl;
cv::Mat m_rot = cv::Mat(T_ORB_TO_WORLD, cv::Range(0,3), cv::Range(0,3));
cout << "my rot :" << endl << m_rot << endl ;
cv:: Mat euler = getEuler(m_rot);
cout << " euler = " << euler << endl;
有人有一个很好的方法吗? 坦克为你提供帮助!
答案 0 :(得分:0)
我找到了如何,我使用了本征。我的功能现在如下:
cv::Mat getEuler(cv::Mat R){
float r_x =0, r_y=0, r_z=0;
Eigen::Matrix<float, 3, 3> m;
Eigen::Vector3f eulerAngle;
for(int i=0; i < R.rows ; i++){
for(int j=0; j < R.cols ; j++){
m(i,j) = R.at<float>(i,j);
}
}
eulerAngle = m.eulerAngles(0,1,2);
cv::Mat euler(1,3,CV_32F);
euler.at<float>(0) = eulerAngle[0];
euler.at<float>(1) = eulerAngle[1];
euler.at<float>(2) = eulerAngle[2];
return euler;
}