Repository navigation
Description
System information (version)
- OpenCV => 3.4.2
- Operating System / Platform => Raspbian Stretch
- Python => 3.5.3
Detailed description
When adding the CALIB_USE_EXTRINSIC_GUESS flag, stereoCalibrate will fail the CV_IS_MAT tests. When calling the same method without that flag, and with same arguments it completes without issue. Also calling stereoCalibrateExtended works both with and without the USE_EXTRINISC_GUESS flag.
Not sure if this is related to #11085
Steps to reproduce
flags = cv2.CALIB_FIX_INTRINSIC
ret, mtx1, dist1, mtx2, dist2, R, T, E, F = cv2.stereoCalibrate(objpoints, imgpointsA, imgpointsB, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, grayA.shape[::-1], R=R, T=T, flags=flags, **kws)
flags += cv2.CALIB_USE_EXTRINSIC_GUESS
ret, mtx1, dist1, mtx2, dist2, R, T, E, F = cv2.stereoCalibrate(objpoints, imgpointsA, imgpointsB, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, grayA.shape[::-1], R=R, T=T, flags=flags, **kws)Error output is:
cv2.error: OpenCV(3.4.2) /home/pi/opencv-3.4.2/modules/calib3d/src/calibration.cpp:1781: error: (-215:Assertion failed) (((_imagePoints1) != __null && (((const CvMat*)(_imagePoints1))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(_imagePoints1))->cols > 0 && ((const CvMat*)(_imagePoints1))->rows > 0) && ((const CvMat*)(_imagePoints1))->data.ptr != __null) && (((_imagePoints2) != __null && (((const CvMat*)(_imagePoints2))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(_imagePoints2))->cols > 0 && ((const CvMat*)(_imagePoints2))->rows > 0) && ((const CvMat*)(_imagePoints2))->data.ptr != __null) && (((_objectPoints) != __null && (((const CvMat*)(_objectPoints))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(_objectPoints))->cols > 0 && ((const CvMat*)(_objectPoints))->rows > 0) && ((const CvMat*)(_objectPoints))->data.ptr != __null) && (((_npoints) != __null && (((const CvMat*)(_npoints))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(_npoints))->cols > 0 && ((const CvMat*)(_npoints))->rows > 0) && ((const CvMat*)(_npoints))->data.ptr != __null) && (((matR) != __null && (((const CvMat*)(matR))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(matR))->cols > 0 && ((const CvMat*)(matR))->rows > 0) && ((const CvMat*)(matR))->data.ptr != __null) && (((matT) !=__null && (((const CvMat*)(matT))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(matT))->cols > 0 && ((const CvMat*)(matT))->rows > 0) && ((const CvMat*)(matT))->data.ptr != __null) in function 'cvStereoCalibrateImpl'
# This one does not fail
flags = cv2.CALIB_FIX_INTRINSIC
flags += cv2.CALIB_USE_EXTRINSIC_GUESS
cv2.stereoCalibrateExtended(objpoints, imgpointsA, imgpointsB, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, grayA.shape[::-1], R, T, flags=flags)
Activity
alalek commentedon Jul 19, 2018
Please add dump (via Python
print/pprint) of all passed matrices or at least their "shape".qenops commentedon Jul 19, 2018
Here is the data I'm using:
marcozmonteiro commentedon Jul 24, 2018
I've also encountered this issue. Using suggestion from @qenops, switched to stereoCalibrateExtended and it did work passing R and T.
alalek commentedon Jul 24, 2018
I added some dumpers for OpenCV's
InputArray/InputArrayOfArraysfunction's parameters: #12054It would be nice to dump metadata of your arguments via these functions?
Try to split assertion line (to get exact parameter name with problem):
qenops commentedon Aug 3, 2018
Sorry it took a while to circle back to this. It looks like matR is causing the problem:
cv2.error: OpenCV(3.4.2) /home/pi/opencv-3.4.2/modules/calib3d/src/calibration.cpp:1783: error: (-215:Assertion failed) (((matR) != __null && (((const CvMat*)(matR))->type & 0xFFFF0000)== 0x42420000 && ((const CvMat*)(matR))->cols > 0 && ((const CvMat*)(matR))->rows > 0) && ((const CvMat*)(matR))->data.ptr != __null) in function 'cvStereoCalibrateImpl'qenops commentedon Aug 3, 2018
Output of the new tests is:
If I update the kind values in the unit test to 0x100200010000 and 0x100200050000, it passes all tests in the Arguments class.
alalek commentedon Aug 3, 2018
It seems failed Python test is my mistake (invalid format: expects "long long int", passed "int" only - garbage is printed).
Please add dump of these statements (right before
stereoCalibratecall):print(cv.utils.dumpInputArray(R))print(cv.utils.dumpInputArray(cameraMatrix1))qenops commentedon Aug 3, 2018
alalek commentedon Aug 3, 2018
stereoCalibrateExtendedhas this declaration of R/T parameters:stereoCalibratehas this:There is no way to pass initial values of R/T into
stereoCalibrate()call.So
CALIB_USE_EXTRINSIC_GUESScan be used withstereoCalibrateExtended()only.Need to add check with more adequate error message.
fix opencv#12012
fix opencv#12012
fix opencv#12012
Merge pull request opencv#12731 from UnderscoreAsterisk:fix-12012