leggedrobotics / darknet_ros

YOLO ROS: Real-Time Object Detection for ROS
BSD 3-Clause "New" or "Revised" License
2.14k stars 1.17k forks source link

darknet_ros node crashes with a single channel (mono / grayscale) image input [exit code -11] #422

Open nickyblanch opened 5 months ago

nickyblanch commented 5 months ago

Describe the bug When the darknet_ros node is fed an image topic that is single-channel, it instantly reaches a segmentation fault. The fault originates from the rgbgr_image() function inside of image.c. (first and second screenshots below)

If that function is not used, more errors arise (third screenshot below).

YoloObjectDetector.cpp appears to have some functionality for handling mono images (fourth screenshot below).

Is there any way that grayscale images can be fed in for YOLOv3 object detection? I've changed channels=3 to channels=1 to in yolov3.cfg and provided weights for a custom trained YOLOv3 model that was trained on the same mono/grayscale image format.

To Reproduce Steps to reproduce the behavior:

  1. Build darknet_ros.
  2. Set up custom weights and change params to search for those weights.
  3. Play a rosbag file including a grayscale sensor_msgs/Image topic.
  4. Launch darknet_ros_gdb.launch and see segementation fault.

Expected behavior darknet_ros node should continue executing after subscribing to the sensor_msgs/Image topic.

Screenshots image image

image

image

System (please complete the following information):