# SolvePnp rvec suddenly begins to give opposite/unexpected values , is this observed before?

I want to smooth motion of head by getting moving average of last 3 rvec and tvec vectors. But suddenly comes unexpected values of rvec,all values became negative :

3.15671 0.096776 0.32789 3.18738 0.0878376 0.336211 3.15005 0.0896022 0.337018 -3.06086 -0.0907339 -0.339971 -3.07529 -0.0846121 -0.343904 -3.08211 -0.0861078 -0.349439 ..... -3.03756 0.257243 -0.510188 -3.00875 0.241385 -0.505155 -3.0265 0.255717 -0.504729 3.13553 -0.306111 0.507516 3.12246 -0.339343 0.507442 3.11797 -0.409513 0.505041

edit retag close merge delete

Sort by ยป oldest newest most voted

If you want to average rotations together, the only sane method is quaternions.

First convert the rvec to a rotation matrix with the Rodrigues method.

Then convert the rotation matrix to a quaternion and average them. Convert the quaternion back to a rotation, then back to an rvec, if you need to.

more

Thank you very much.Could you recomend a reliable code for conversion pls.

( 2017-03-17 05:47:11 -0500 )edit

You see that link to euclidean space? That's the reliable code.There are version of that code all over the place, such as in Boost/Quaternions, but that's what they do.

( 2017-03-17 16:37:03 -0500 )edit

Thanks for the suggestion of http://www.boost.org/doc/libs/1_46_1/libs/math/doc/quaternion/html/ (Boost/Quaternions) - that library is surprisingly rarely referenced.

( 2017-04-26 01:32:31 -0500 )edit

Official site

GitHub

Wiki

Documentation