Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This seems to work:

In [1]: import cv2

In [2]: objectPoints = np.random.random((10,3,1))

In [3]: imagePoints = np.random.random((10,2,1))

In [4]: cameraMatrix = np.eye(3)

In [5]: distCoeffs = np.zeros((5,1))

In [6]: cv2.solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs)

Out[6]:

(True, array([[ 0.15797798], [ 0.48352235], [-0.25566527]]), array([[ 0.36711979], [ 1.02124737], [ 1.83962556]]))

Image points of shape (N, 1, 2) and object points of shape (N,1,3) also works (your case number 2) for me. Perhaps you had a bad shape for distCoeffs?