ethz-asl / kalibr

The Kalibr visual-inertial calibration toolbox
Other
4.43k stars 1.4k forks source link

I encountered an issue while running Kalibr: "OpenCV Error: Assertion failed (isIdentity(expr))". How can I resolve this problem? #679

Closed 12moon28 closed 3 months ago

12moon28 commented 7 months ago

My issue is as follows: When I run the following code:

rosrun kalibr kalibr_calibrate_cameras  --target ./cam0/april_6x6.yaml  --models pinhole-radtan pinhole-radtan  --topics /cam0/image_raw /cam1/image_raw  --bag ./cam0/cam_april.bag

Output the following content:

OpenCV Error: Assertion failed (isIdentity(expr)) in _InputArray, file /home/kong/opencv/modules/core/src/matrix_expressions.cpp, line 1843
Traceback (most recent call last):
  File "/home/kong/kalibr_ws/src/Kalibr/aslam_offline_calibration/kalibr/python/kalibr_calibrate_cameras", line 465, in <module>
    main()
  File "/home/kong/kalibr_ws/src/Kalibr/aslam_offline_calibration/kalibr/python/kalibr_calibrate_cameras", line 188, in main
    if not cam.initGeometryFromObservations(observations):
  File "/home/kong/kalibr_ws/src/Kalibr/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraCalibrator.py", line 69, in initGeometryFromObservations
    success = kcc.calibrateIntrinsics(self, observations)
  File "/home/kong/kalibr_ws/src/Kalibr/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraIntializers.py", line 220, in calibrateIntrinsics
    success, T_t_c = cam_geometry.geometry.estimateTransformation(obs)
RuntimeError: /home/kong/opencv/modules/core/src/matrix_expressions.cpp:1843: error: (-215) isIdentity(expr) in function _InputArray

OpenCV Error: Assertion failed (tlsSlots.size() > slotIdx) in releaseSlot, file /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/system.cpp, line 1092
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/system.cpp:1092: error: (-215) tlsSlots.size() > slotIdx in function releaseSlot

According to the information I found online, the issue might be caused by incompatible versions of OpenCV (I'm using 3.4.20 while ROS is installed with 3.2). However, even after modifying the corresponding parameters in the files to match version 3.4.20, the problem persists.

thankyou!

goldbattle commented 3 months ago

Yep looks like an OpenCV install issue. I would recommend installing again from source and making sure you are linking to the correct location. Otherwise you can always try the docker containers which should help avoid this issue.