OpenCV:How to use the Euler angle to determine camera orientation | بلاگ

OpenCV:How to use the Euler angle to determine camera orientation

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I got a question about how to use the EulerAngle to determine camera's orientation First, I used solvePnP function and got two output "rvec" and "tvec", then I use Rodrigues to convert rvec to rotation matrix "R". After that, I calculated EulerAngle by using the function below:

void getEulerAngles(cv::Mat matrix)

{

assert(isRotationMatrix(matrix));

float sy=sqrt(matrix.at(0,0)*matrix.at(0,0)+matrix.at(1,0)*matrix.at(1,0));

bool singular = sy<1e-6;
float theta_x=0.0,theta_y=0.0,theta_z=0.0;//theta_x means rotation around X-Axis
if(!singular)
{
    theta_x=atan2(matrix.at(2,1),matrix.at(2,2));
    theta_x= theta_x*180.0/3.1416 ;
    theta_y=atan2(-matrix.at(2,0), sy);
    theta_y= theta_y*180.0/3.1416 ;
    theta_z=atan2(matrix.at(1,0), matrix.at(0,0));
    theta_z= theta_z*180.0/3.1416 ;
}
else
{
    theta_x=atan2(-matrix.at(1,2), matrix.at(1,1));
    theta_x= theta_x*180.0/3.1416 ;
    theta_y=atan2(-matrix.at(2,0), sy);
    theta_y= theta_y*180.0/3.1416 ;
    theta_z=0;
    theta_z= theta_z*180.0/3.1416 ;
}

I know that different rotation order can make different result.So if I want to get the camera's orientation what kind of rotation order should I choose?

asked 1 min ago
V.Lee

...
نویسنده : استخدام کار بازدید : 6 تاريخ : جمعه 24 فروردين 1397 ساعت: 8:51