Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error opening file: /camera/image during preprocessing in direct_visual_lidar_calibration #141

Open
BreCaspian opened this issue Feb 19, 2025 · 3 comments

Comments

@BreCaspian
Copy link

Issue Title:

Error opening file: /camera/image during preprocessing in direct_visual_lidar_calibration

Description:

I am facing a recurring issue while using the direct_visual_lidar_calibration package to preprocess ROSbag files. The tool fails during the preprocessing step, and throws the following error:

terminate called after throwing an instance of 'rosbag::BagIOException'
  what():  Error opening file: /camera/image
Aborted (core dumped)

more

yao@RM:~/catkin_ws$ rosrun direct_visual_lidar_calibration preprocess /media/yao/RM/livox_ros1 /media/yao/RM/rosbag_preprocessed -a --camera_model plumb_bob --camera_intrinsic 1452.0,1453.1,0.2897,0.2058 --camera_distortion_coeffs 0.1392,-1.6770,0.0,0.0,0.0
data_path: /media/yao/RM/livox_ros1
dst_path : /media/yao/RM/rosbag_preprocessed
input_bags:
- /media/yao/RM/livox_ros1/rosbag2_2023_03_09-13_42_46.bag
- /media/yao/RM/livox_ros1/rosbag2_2023_03_09-13_44_10.bag
- /media/yao/RM/livox_ros1/rosbag2_2023_03_09-13_44_54.bag
- /media/yao/RM/livox_ros1/rosbag2_2023_03_09-13_46_10.bag
- /media/yao/RM/livox_ros1/rosbag2_2023_03_09-13_46_54.bag
topics in /media/yao/RM/livox_ros1/rosbag2_2023_03_09-13_42_46.bag:
- /livox/points : sensor_msgs/PointCloud2
- /livox/imu : sensor_msgs/Imu
- /image : sensor_msgs/Image
- /camera_info : sensor_msgs/CameraInfo
selected topics:
- camera_info: /camera_info
- image      : /image
- points     : /livox/points
intensity_channel: intensity
terminate called after throwing an instance of 'rosbag::BagIOException'
  what():  Error opening file: /image
Aborted (core dumped)

This issue occurs consistently when trying to preprocess ROSbag files containing the /camera/image or /image topic. The error prevents me from continuing with the calibration process.

Steps to Reproduce:

  1. Run the following preprocessing command for the first ROSbag:

    rosrun direct_visual_lidar_calibration preprocess /media/yao/RM/rosbag_test /media/yao/RM/rosbag_preprocessed -a --camera_model plumb_bob --camera_intrinsic 1452.0,1453.1,0.2897,0.2058 --camera_distortion_coeffs 0.1392,-1.6770,0.0,0.0,0.0
  2. The tool tries to process the ROSbag lidar_camera_data_test1.bag and its topics:

    • /camera/camera_info (sensor_msgs/CameraInfo)
    • /camera/image (sensor_msgs/Image)
    • /cloudpoints (sensor_msgs/PointCloud2)
  3. The tool fails and returns the following error:

    terminate called after throwing an instance of 'rosbag::BagIOException'
    what():  Error opening file: /camera/image
    Aborted (core dumped)
    
  4. I also ran the same preprocessing command for another set of ROSbags:

    rosrun direct_visual_lidar_calibration preprocess /media/yao/RM/livox_ros1 /media/yao/RM/rosbag_preprocessed -a --camera_model plumb_bob --camera_intrinsic 1452.0,1453.1,0.2897,0.2058 --camera_distortion_coeffs 0.1392,-1.6770,0.0,0.0,0.0
  5. The same error occurs while processing the rosbag2_2023_03_09-13_42_46.bag in the livox_ros1 directory.

Expected Behavior:

The preprocessing step should process the /camera/image or /image topic and other selected topics successfully, without errors, and output the preprocessed data to the destination directory (/media/yao/RM/rosbag_preprocessed).

Actual Behavior:

The preprocessing fails with the error Error opening file: /camera/image. The tool is unable to read or process the image data from the /camera/image or /image topic in the ROSbag files.

Troubleshooting Steps Taken:

  1. Verified the availability and content of /camera/image and /image topics:

    • I ran rostopic echo /camera/image and confirmed that messages are being published.
    • I played the ROSbag files and viewed the image data using rqt_image_view to ensure the image data is valid and visible.
  2. Checked the ROSbag file contents using rosbag info:

    • I confirmed the presence of /camera/image or /image topics in the ROSbags, and checked their message count:
      rosbag info /media/yao/RM/rosbag_test/lidar_camera_data_test1.bag
      The output showed that the /camera/image topic has 93 messages, and /cloudpoints has 97 messages.
  3. Re-indexed the ROSbag files:

    • I attempted to re-index the ROSbag file using:
      rosbag reindex /media/yao/RM/rosbag_test/lidar_camera_data_test1.bag
  4. Checked file permissions:

    • I ensured that the file permissions are set correctly:
      sudo chmod -R 755 /media/yao/RM/rosbag_test
  5. Tried processing the files individually:

    • I attempted to process only the lidar_camera_data_test1.bag file with no success:
      rosrun direct_visual_lidar_calibration preprocess /media/yao/RM/rosbag_test/lidar_camera_data_test1.bag /media/yao/RM/rosbag_preprocessed -a --camera_model plumb_bob --camera_intrinsic 1452.0,1453.1,0.2897,0.2058 --camera_distortion_coeffs 0.1392,-1.6770,0.0,0.0,0.0
  6. Checked for correct topic paths and message types:

    • I verified that the topic paths and message types are correctly specified and match those in the ROSbag:
      rostopic type /camera/image
      The output confirmed that /camera/image has the correct sensor_msgs/Image type.

System Information:

  • OS: Ubuntu 20.04
  • ROS Version: ROS Noetic
  • OpenCV Version: 4.10.0

Logs:

Error log:

terminate called after throwing an instance of 'rosbag::BagIOException'
what():  Error opening file: /camera/image
Aborted (core dumped)

Questions:

  1. Could there be an issue with how the /camera/image or /image topic is being serialized or read by the direct_visual_lidar_calibration tool?
  2. Is there a potential mismatch between the image encoding format in the ROSbag and the tool's expectations?
  3. Could the issue be related to the OpenCV version installed? Could an incompatible OpenCV version be causing this issue?
  4. Have you encountered this issue before?
  5. What steps should I take to thoroughly resolve this issue? Are there any specific debug or logging options I should enable to gather more information about the cause?

Thank you very much !

@huanghuzz
Copy link

我遇见了和你一样的问题,请问您是否解决了该问题

@BreCaspian
Copy link
Author

Hi, sorry for the late reply due to recent work commitments.

I’ve actually encountered the same issue as you described. Unfortunately, I haven’t found a direct solution either. After some investigation, I believe the root cause lies in the compatibility issues between the source code and the specific versions of ROS and OpenCV. As of now, this problem cannot be resolved without modifying the original source code.

I’ve already submitted a detailed issue regarding this to the original repository and am currently waiting for the maintainers to respond or push an update.

That said, there is a good workaround — using Docker. If you're familiar with Docker, you’ll know that it eliminates the need to manually configure complex local environments. In fact, this reflects one of Docker’s core advantages: providing a consistent and reproducible environment across systems.

Fortunately, the author has already provided an official Docker-based solution in the project’s documentation. You can simply follow those instructions to run the tool and get your calibration results without dealing with local environment issues.

Hope this helps!

Best regards.

@BreCaspian
Copy link
Author

BreCaspian commented Mar 25, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants