What are the requirements for solvePnP and how to improve my results?
My goal is to estimate the camera pose by using a camara-matrix, a distortion matrix, and a set of image-to-object-coordinate-correspondences.
I am having issues with the solvePnP function which I do use to estimate my camera pose. My results seem to be inaccurate, especially for the pitch axis. I am using co-planar points, which even also have only a little variation in the y-axis, so that they are almost in a line.
What are the requirements for solvePnP and how to improve my results?
I am using the Calib3d.CV_ITERATIVE flag to select this of the three algorithms, because the other two performed obviously completly wrong. But P3P was closer than EPNP. I am using the latest OpenCV 2.4.8.0 java-wrapper.
I created an evaluation dataset. On my Roll-Axis, and on my Yaw-Axis (in world coordinates) the median of the difference between the calculated and expected results are small. But the differences within one sample are +-5 (for roll) and +3/-7 for (yaw) expect outliners, which can be 20° off but occour seldom in my testdataset.
Big problems I observe for the pitch angle. The median of the difference between expectation and estimated values is 9.6. the accurancy drifts arround 30°.
Will I have more success with other algorithms, which solve the PnP problem, or if I do add more points, e.g. ones which are moved along the (open-cv) Z-axis to my szene?
Here is an Xml-File which contains the points of my test-dataset.
And here is an Xls-File with my current evaluation.
Here you find the images of the test-dataset and containing an (incomplete) projection of a cube.
Here you find the code I use to generate the xml file, and test solvePnP and generate my xml file.
Here you find a not yet used dataset of a test szene, with two points with variation in the Z-Axis. Do you recommend to create the full-annotations for this testset?
I assume no important information to be mentioned here, but for completness I am appending the related question I asked at the 13th of march on stackoverflow.
Some other people will provide better answer than me, but I think you will need at least 4 points (more are better of course) for solvePnP.
"I am using co-planar points, which even also have only a little variation in the y-axis, so that they are almost in a line. "
I think this is not good to use 3D points that are on a line as reference points. For me, you have to use as reference points at least 4 3D points that have a good variation on at least 2 axis.