# marker to gl-matrix via OpenCV.js

Let's assume we get rvecs and tvecs via cv.estimatePoseSingleMarkers()

Then going through each marker, we can get the 1x3 vectors like this (found in online samples):

const rotation = [rvecs.doublePtr(0, i)[0], rvecs.doublePtr(0, i)[1], rvecs.doublePtr(0, i)[2]];
const translation = [tvecs.doublePtr(0, i)[0], tvecs.doublePtr(0, i)[1], tvecs.doublePtr(0, i)[2]];


How can this be converted so it's compatible with gl-matrix's fromRotationTranslation?

Specifically - it seems gl-matrix expects the rotation in a quaternion... I see some sample C++ code to do that conversion here, but it assumes a Rodrigues function in OpenCV to get from the 1x3 vector to a 3x3 rotation matrix - I think?

The Rodrigues function seems to be missing in OpenCV.js... and it's not clear to me what exactly cv.estimatePoseSingleMarkers() is returning in each rvec (is it euler radians? something else?)

edit retag close merge delete

Sort by ยป oldest newest most voted

you can construct a quat directly from the rvec, using fromEuler(), see here:

https://github.com/toji/gl-matrix/blo...

more

is a Rodrigues vector the same as Euler? If so - why is it called "Rodrigues" ? (wanted to upvote your answer in the meantime - but don't have enough karma yet :)

( 2018-11-15 02:34:55 -0500 )edit

no, Rodrigues makes a 3x3 rotation Mat from a 1x3 vector, or the other way round, and it's named after it's inventor ;) (while fromEuler() makes a quat from a rotation vector)

wanted to upvote

kind of you, but i really don't need more karma here, heeh ;)

( 2018-11-15 02:38:15 -0500 )edit
1

Cool! So the vector I get from cv.estimatePoseSingleMarkers() is in euler radians?

( 2018-11-15 02:42:17 -0500 )edit

good point, but sorry, idk (never used aruco)

( 2018-11-15 03:01:52 -0500 )edit
1

oh but that's the question. edited to make that clearer

( 2018-11-15 03:06:01 -0500 )edit

well, it can only be rad or deg. fromEuler() expects degrees (and internally converts to radians)

maybe you have to print out some measurements. if you see any number larger than +-pi, then you know it's deg ;)

( 2018-11-15 03:11:14 -0500 )edit
1

ah okay - I thought maybe there's some other possibility like the 3 values being something other than Euler. The docs on estimatePoseSingleMarkers aren't very clear - it simply says "see Rodrigues" o_O. I'll play around with it later and see what happens. Thanks!

( 2018-11-15 03:30:51 -0500 )edit

Official site

GitHub

Wiki

Documentation

## Stats

Asked: 2018-11-14 16:30:02 -0500

Seen: 75 times

Last updated: Nov 15 '18