Python – What are Python constants for cv2.solvePnP method flag

opencvpython

I need to use the CV_P3P solvePnP method, but there doesn't seem to be any documentation of the python equivalents of the C++ flags, which are CV_ITERATIVE, CV_P3P and CV_EPNP. I've tried cv2.CV_P3P, cv2.P3P, cv2.cv.P3P, etc.

I've found a few questions asking this, including these:

http://opencv-users.1802565.n2.nabble.com/solvePNP-name-of-flag-constants-in-Python-td7484093.html

http://answers.opencv.org/question/8861/what-opencv-constants-are-available/

But no answers, apart from a link to this source page, which defines python constants. But there seem to be no references to the constants I'm looking for.
https://github.com/Itseez/opencv/blob/e3ae36dcb3c1d523802f8642e5c3984db43637c4/modules/python/src2/defs

I also tried just passing integers for that argument, but it still seems to be using the default method.

Is it possible the other solve methods don't exist in the python version of opencv?

Best Answer

I found that the following constants worked:

cv2.SOLVEPNP_ITERATIVE

cv2.SOLVEPNP_P3P

cv2.SOLVEPNP_EPNP

cv2.SOLVEPNP_DLS

E.g:

retval, orvec, otvec = cv2.solvePnP(object_points, image_points, 
            camera_matrix, None, None, None, False, cv2.SOLVEPNP_ITERATIVE)