homography vs SolvePNP for pose detection, how and why?
I have mutiple planar markers where I can detect 100-200 points each in a reliable manner. In each frame I see one or two markers at most; I need to calculate the camera pose.
I am not sure whether I should use solvePNP or findhomography for the pose detection.
1) OpenCV homography page states that solvePnp should be used for planar objects as well, and findhomography is just for demo in terms of pose detection. See https://docs.opencv.org/3.4.1/d9/dab/... On the other hand, solvePNP is using POSIT, right? Which should be less accurate on planar features, please correct me here if the implementation is actually taking care of the planar case. So, should I ever consider findHomography or not for pose estimation?
2) In case findhomography still makes sense, how should I use it? Should I use two frames and feed 2d-2d coordinates to the findhomography, or use the "3d object coordinates without Z" as the source?
Thanks for any hint.
solvePnP()
does not use POSIT. See the documentation for the references.Just use
solvePnP()
, the implemented methods can handle planar and non planar cases.for 2. have a look e.g here
Ok, this sounds like a conclusive answer, thanks. In order to "handle the planar cases", is it required that Z=0 on the object points, or should the 3d coords be "just planar enough", or it does not matter and the accuracy is always the same? Just want to check if I need to somehow "trigger" the detection of the planar case or not.
In this tutorial, yes
Z=0
is required. If you usesolvePnP()
you can use an arbitrary planar configuration (not onlyZ=0
).If you want to go further:
rvec
and a translation vectortvec
rvec
andtvec
) parameterssolvePnP()
the 3D object points, the 2D image points, ...rvec
andtvec
should be close to the real onesIf you want to understand more, you can:
solvePnP()
method, for instanceEPnP
method explains both planar and non planar cases or read the corresponding source codesolvePnP()
withSOLVEPNP_ITERATIVE
, set a breakpoint here or add acout
and you should see that the method should go to the planar case (this method is pose from homography with general configuration)