I’m working with some points that I’m transforming using cv::solvePnP() to get a rough estimation of planar pose and it’s going pretty strangely so far. I’m puzzled about what exactly solvePnP() returns (it looks like Eulerian angles) and how to use those in the OF GL view. I’ve tried something like:
if(hasRunPNP) {
cv::solvePnP(modelPts, imgPts, m, distortion_coefficients, outR, outT, true);
} else {
cv::solvePnP(modelPts, imgPts, m, distortion_coefficients, outR, outT);
hasRunPNP = true;
}
// really simplified smoothing
if(planarRotationVecBuffer.size() > 20)
planarRotationVecBuffer.erase(planarRotationVecBuffer.begin());
planarRotationVecBuffer.push_back(outR);
planarRotationVec.zeros(3, 1, CV_64F);
for ( int i = 0; i < planarRotationVecBuffer.size(); i++) {
planarRotationVec += planarRotationVecBuffer[i];
}
// trying this out but passing the result into glMultMatrix or glLoadMatrix looks insane
planarRotationVec = planarRotationVec/planarRotationVecBuffer.size();
Rodrigues(planarRotationVec,rotM);
// euler angles to matrix
m2[0] = rotM.ptr()[0];
m2[1] = -rotM.ptr()[3];
m2[2] = -rotM.ptr()[6];
m2[3] = 0;
m2[4] = rotM.ptr()[1];
m2[5] = -rotM.ptr()[4];
m2[6] = -rotM.ptr()[7];
m2[7] = 0;
m2[8] = rotM.ptr()[2];
m2[9] = -rotM.ptr()[5];
m2[10] = -rotM.ptr()[8];
m2[11] = 0;
m2[12] = outT.ptr()[0];
m2[13] = -outT.ptr()[1];
m2[14] = -outT.ptr()[2];
m2[15] = 1;
Curious if anyone has worked with this before. I know that it can work outside of OF, but I can’t get it to work in OF.