Ask Your Question

# openCV 3.0 recoverPose wrong results

Does anyone can using openCV 3.0 recoverPose function with good results? I've got:

Mat r;
cv::Mat t;
cv::Mat E = cv::findEssentialMat(features1, features2);
cv::recoverPose(E, features1, features1, r, t);

float xAngle = radToDeg(atan2f(r.at<float>(2, 1), r.at<float>(2, 2)));
float yAngle = radToDeg(atan2f(-r.at<float>(2, 0), sqrtf(r.at<float>(2, 1) * r.at<float>(2, 1) + r.at<float>(2, 2) * r.at<float>(2, 2))));
float zAngle = radToDeg(atan2f(r.at<float>(1, 0), r.at<float>(0, 0)));


As input I use one image 1836x1836 dimensions and another image 1836x1836 which is just rotated 90 degrees to the left. I have rotated it using computer program so it is exactly rotate 90 degrees.

I expect result:

xAngle: 0
yAngle: 0
zAngle: 90 (or -90 depending on Z direction)


Unfortunately my results are:

xAngle: 90
yAngle: 0.113659
zAngle: 180


Can anyone help me with it?

edit retag close merge delete

## 2 answers

Sort by » oldest newest most voted

I'm not sure whether the recoverPose function provide an wrong angle. But, I have the similar opinion with yours. I had compared two functions ( cv::decomposeEssentialMat and cv::recoverPose() ) and confirmed that the results were different.

[The number of function results] (A)cv::decomposeEssentialMat : two (R1, R2) (B)cv::recoverPose() : one (R1)

When I rotated an web-cam by 25 degree (Axis angle) (A) function gave us two rotation matrix R1 (25 degree) and R2 (wrong value). (B) function gave us one ratation matrix R1 (sometimes 25 degree. but some times wrong value)

I also couldn't know the reason why the fuction's results are not reliable.

more

Well, my impression so far is that translation is computed rather well, but rotation is almost always bullshit, unless there is none between the two frames. But rotation around the z axis like in your case seems to work occasionally. I'm not sure about the equations, but you can use the RQdecomp3x3 function to decompose the matrix to euler angles

 Mat mtxR, mtxQ;
Vec3d angles = RQDecomp3x3(R, mtxR, mtxQ);
cout << "Translation: " << t.t() << endl;
cout << "Euler angles [x y z] in degrees: " << angles.t() << endl;


I'm not sure though if x, y, z is really the order of axes here.

Also, you need to pay attention to whether feature coordinates are normalised or not, and possibly try various combination of input parameters when performing undistortion and then finding E (I've outlined the issue here), so something like this may be requires depending on your specific case.

Mat E = findEssentialMat(imgpts1, imgpts2, 1.0, Point2d(0,0), RANSAC, 0.999, 3, mask);
correctMatches(E, imgpts1, imgpts2, imgpts1, imgpts2);
recoverPose(E, imgpts1, imgpts2, R, t, 1.0, Point2d(0,0), mask);
`
more

Official site

GitHub

Wiki

Documentation

## Stats

Asked: 2015-03-02 16:28:24 -0500

Seen: 2,882 times

Last updated: Jul 10 '15