leggedrobotics / darknet_ros

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

Slow detections because a detection image is generated even when there are no subscribers #364

Open blakermchale opened 2 years ago

blakermchale commented 2 years ago

Describe the bug On these lines the detection image is generated and significantly slows down the detection speed since it is copying pixels in an image with a for loop. This doesn't need to occur at this stage and can be moved after it is checked if anyone is subscribing to the detection topic (here).

To Reproduce Steps to reproduce the behavior:

  1. Run darknet_ros

Expected behavior The detection image should not be generated unless there are subscribers.

System specs (please complete the following information):

Additional context I've tested this locally on a fork of PR #319. It increases the FPS from a max of 120 to 150, along with the average FPS being higher.