OpenCV error: assertion failed in undistort.cpp on line 293

Found solution https://github.com/opencv/opencv/issues/4943

OpenCV Error:

The statement failed (CV_IS_MAT (_src) && CV_IS_MAT (_dst) && (_src-> rows == 1 || _src-> cols == 1) && & (_dst-> rows == 1 || _dst-> cols == 1) && & & _src-> cols + _src-> rows - 1 == _dst-> rows + _dst-> cols - 1 && & & (CV_MAT_TYPE (_src-> type) == CV_32FC2 || CV_MAT_TYPE (_src-> type) == CV_64FC2) && (CV_MAT_TYPE (_dst-> type) == CV_32FC2 || CV_MAT_TYPE (_dst-> type) == CV_64FC2)) in cvUndistortPoints, file / home / javvaji / opencv -3.2.0 / modules / imgproc /src/undistort.cpp, line 293

retval, rvec, tvec = cv2.solvePnP(cam.object_points, cam.image_points, cam.camera_matrix, cam.dist_coefficients, None, None, False, cv2.SOLVEPNP_P3P)

I am using the solvePnP function with the SOLVEPNP_P3P flag. It gives an assertion error. The same solvePnP code works fine with the SOLVEPNP_ITERATIVE flag. With the P3P flag, it internally calls the undistortPoints function, which gives an error.

solvePnP code ref: https://github.com/opencv/opencv/blob ...

How to resolve this?

+4
source share
1 answer

Incomplete documents - solvePnP in python (problem - open problem in opensv github repo)   https://github.com/opencv/opencv/issues/4943

  • , solvePnP ( cv:: Mat:: checkVector() 55 /calib 3d/src/solvepnp.cpp 2.4 0,9)

  • P3P , (N, 1,2) - cv:: undistortPoints ( 75 /calib 3d/src/solvepnp.cpp) 2.4.9), .

  • , D = np.array(...), D.shape = (N, M), , , imagePoints, : imagePoints = np.ascontiguousarray(D [:,: 2]). reshape ((N, 1,2))

+1

Source: https://habr.com/ru/post/1677436/


All Articles