Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Error: Assertion failed in undistort.cpp at line 293

OpenCV Error:

Assertion 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)

Parameter values: (all are numpy arrays)

 Image points: 
[[ 433.   50.]
 [ 512.  109.]
 [ 425.  109.]
 [ 362.  106.]]
Object points: 
[[ 0.   0.   0. ]
 [ 6.5  0.   0. ]
 [ 0.   0.   6.5]
 [ 0.   6.5  0. ]]
Cam mat:
[[ 811.13275146    0.          322.47589111]
 [   0.          811.27490234  225.78684998]
 [   0.            0.            1.        ]]
Dist Coff:
[[-0.07649349 -0.02313312 -0.00911118 -0.0049251   0.74063563]]

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

How to resolve this?

OpenCV Error: Assertion failed in undistort.cpp at line 293

OpenCV Error:

Assertion 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)

Parameter values: (all are numpy arrays)

 Image points: 
[[ 433.   50.]
 [ 512.  109.]
 [ 425.  109.]
 [ 362.  106.]]
Object points: 
[[ 0.   0.   0. ]
 [ 6.5  0.   0. ]
 [ 0.   0.   6.5]
 [ 0.   6.5  0. ]]
Cam mat:
[[ 811.13275146    0.          322.47589111]
 [   0.          811.27490234  225.78684998]
 [   0.            0.            1.        ]]
Dist Coff:
[[-0.07649349 -0.02313312 -0.00911118 -0.0049251   0.74063563]]

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

solvePnP code ref: https://github.com/opencv/opencv/blob/3.2.0/modules/calib3d/src/solvepnp.cpp

How to resolve this?