Ask Your Question
2

openCV 3.0 recoverPose wrong results

asked 2015-03-02 16:28:24 -0600

Bystysz gravatar image

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 flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-08-18 02:45:19 -0600

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.

edit flag offensive delete link more
0

answered 2015-07-10 03:35:42 -0600

themightyoarfish gravatar image

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);
edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 4,210 times

Last updated: Jul 10 '15