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?)