solvePnP not woking

asked 2017-10-03 02:01:19 -0500

ajayramesh gravatar image

I'm trying to run the simplest possible example in solvePnP in pyOpenCV (3.3)

camera_matrix_left = np.eye(3)
dist_left = np.zeros((5, 1))

image_points = np.array([[1,2], [2,3]])
object_points = np.array([[1,2,0], [2,3,0]])


cv2.solvePnP(image_points, object_points, camera_matrix_left, dist_left)

This is the error I'm getting:

OpenCV Error: Assertion failed (npoints >= 4 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F))) in solvePnP, file /Users/travis/miniconda3/conda-bld/opencv_1506476120161/work/opencv-3.3.0/modules/calib3d/src/solvepnp.cpp, line 64
Traceback (most recent call last):
  File "/Users/me/Documents/Code/my_project/file.py", line 140, in <module>
    cv2.solvePnP(image_points, object_points, camera_matrix_left, dist_left)
cv2.error: /Users/travis/miniconda3/conda-bld/opencv_1506476120161/work/opencv-3.3.0/modules/calib3d/src/solvepnp.cpp:64: error: (-215) npoints >= 4 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function solvePnP

I'd really appreciate some help, as I'm at a loss for how to continue.

edit retag flag offensive close merge delete

Comments

1

you need 4 or more points :OpenCV Error: Assertion failed (npoints >= 4

LBerger gravatar imageLBerger ( 2017-10-03 02:08:54 -0500 )edit