1

I've calibrated a camera and obtained 0.17 reprojection error, the file is saved as camera.yml. Then, I imported this file to my aruco detection algorithm and when I run this algorithm, everything starts out fine until an aruco marker is detected, however, the moment an aruco marker is detected, the code throws the following error and stops running.

cv exception: OpenCV(3.4.2) error: (-215:Assertion failed) (((objectPoints) != __null && (((const CvMat*)(objectPoints))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(objectPoints))->cols > 0 && ((const CvMat*)(objectPoints))->rows > 0) && ((const CvMat*)(objectPoints))->data.ptr != __null) && (((imagePoints) != __null && (((const CvMat*)(imagePoints))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(imagePoints))->cols > 0 && ((const CvMat*)(imagePoints))->rows > 0) && ((const CvMat*)(imagePoints))->data.ptr != __null) && (((A) != __null && (((const CvMat*)(A))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(A))->cols > 0 && ((const CvMat*)(A))->rows > 0) && ((const CvMat*)(A))->data.ptr != __null) && (((rvec) != __null && (((const CvMat*)(rvec))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(rvec))->cols > 0 && ((const CvMat*)(rvec))->rows > 0) && ((const CvMat*)(rvec))->data.ptr != __null) && (((tvec) != __null && (((const CvMat*)(tvec))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(tvec))->cols > 0 && ((const CvMat*)(tvec))->rows > 0) && ((const CvMat*)(tvec))->data.ptr != __null) in function 'cvFindExtrinsicCameraParams2'

The error is caused by

CV_Assert( CV_IS_MAT(objectPoints) && CV_IS_MAT(imagePoints) && CV_IS_MAT(A) && CV_IS_MAT(rvec) && CV_IS_MAT(tvec) );

that can be found in opencv/modules/calib3d/src/calibration.cpp, line #996 (https://github.com/opencv/opencv/blob/3.4/modules/calib3d/src/calibration.cpp).

I know that Rvecs and TVecs are generated with the help of calibration file. It looks like something in the calibration isn’t in the right format.

I have a sample calibration file (sample.yml) that belongs to another camera. When I import that file while running the aruco detection algorithm, it runs without any errors.

The contents of these files (in case you want to compare them) are available here:

I'm using OpenCV 3.4.2.

csg
  • 8,096
  • 3
  • 14
  • 38
  • Can you also post the code you use? – Kani Aug 29 '19 at 23:55
  • @Kani it isn't an open source code, but (tomorrow) I can share a snippet of it for the sake of completeness. – csg Aug 30 '19 at 01:33
  • I am sorry, I was confused. Are you trying the calibration.cpp in the OpenCV repository? – Kani Aug 30 '19 at 13:57
  • @Kani yes, I used `calibration.cpp` to generate the camera calibration file: `camera.yml` – csg Aug 30 '19 at 14:10
  • I am sorry, I am still confused. The first sentence in your question says you did the calibration and you obtained a re-projection error of 0.17. But then again you say "I imported this file to my aruco detection algorithm". Doesn't that mean that the `calibration.cpp` worked fine, but your detection code is not working? – Kani Aug 30 '19 at 17:07
  • @Kani I recorded a video for you: https://youtu.be/bBntRMxSobw – csg Aug 30 '19 at 17:50

1 Answers1

2

The entire problem is the discrepancy in the naming conventions between the two files. I copied the names from sample.yml to camera.yml and it started working. Sometimes the solution is that simple.

csg
  • 8,096
  • 3
  • 14
  • 38
  • Glad that you figured that out. It's probably a version related issue between OpenCV and ArUco. – Kani Aug 31 '19 at 19:59
  • Wait, it's just that the names are lowercase in camera.yml and capitalized in sample.yml? Grr. – Dave X May 13 '21 at 04:38
  • I had a similiar issue with https://docs.opencv.org/master/df/d4a/tutorial_charuco_detection.html -- I worked around it by changing the `fs["camera_matrix"] >> camMatrix;` line to match the field name in the calibration file. It would be cleaner if the `readCameraParameters()` routine was unable to read both calibration matrices from the config file would fault rather than pass a null. – Dave X May 13 '21 at 04:49
  • I raised an issue here https://github.com/opencv/opencv_contrib/issues/2949 and a bit of an error-check here https://github.com/opencv/opencv_contrib/pull/2950 – Dave X May 13 '21 at 18:36