这是错误:
cv2.solvePnP(obj_points, image_points, mtx, dist)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\calib3d\src\solvepnp.cpp:754: error:
(-215:Assertion failed) ( (npoints >= 4) || (npoints == 3 && flags == SOLVEPNP_ITERATIVE &&
useExtrinsicGuess) ) && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2,
CV_64F)) in function 'cv::solvePnPGeneric'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
mtx = np.load("./camera_params/mtx.npy")
dist = np.load("./camera_params/dist.npy")
obj_points = np.array([[0, 0, 0], [297, 0, 0], [297, 210, 0], [0, 210, 0]])
image_points = np.array([[416, 268], [422, 535], [826, 543], [829, 264]])
cv2.solvePnP(obj_points, image_points, mtx, dist)
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决它。我试图玩弄争论,但没有帮助。如果您知道解决此错误的方法,那将会非常有帮助。