apoorva aa265edfb1 Add 'darknet_ros2/' from commit 'be4fd04c0ea8fbed80b3549283701e16145422c6'
git-subtree-dir: darknet_ros2
git-subtree-mainline: f33742e6e8ae5b436aa1ce48d8c40cb5e5e5562e
git-subtree-split: be4fd04c0ea8fbed80b3549283701e16145422c6
2023-03-10 18:40:03 +05:30

1.8 KiB

Open Robotics Darknet ROS

This is a ROS 2 wrapper around darknet, an open source neural network framework.

Example image with bounding boxes created using darknet and the yolov3-tiny network

DetectorNode

This node can run object detectors like YOLOv3 on images.

Subscribers

  • ~/images (type sensor_msgs/msg/Image) - Input mages to feed to the detector

Publishers

  • ~/detections (type vision_msgs/msg/Detection2DArray) - Objects detected in an image (if any)

Parameters

  • network.config - a path to a file describing a darknet detector network
  • network.weights - a path to a file with weights for the given network
  • network.class_names - a path to a file with names of classes the network can detect (1 per line)
  • detection.threshold - Minimum probability of a detection to be published
  • detection.nms_threshold - Non-maximal Suppression threshold - controls filtering of overlapping boxes

Example

Download YOLOv3-tiny.

wget https://raw.githubusercontent.com/pjreddie/darknet/f86901f6177dfc6116360a13cc06ab680e0c86b0/cfg/yolov3-tiny.cfg
wget https://pjreddie.com/media/files/yolov3-tiny.weights
wget https://raw.githubusercontent.com/pjreddie/darknet/c6afc7ff1499fbbe64069e1843d7929bd7ae2eaa/data/coco.names

Save the following as detector_node_params.yaml

/**:
  ros__parameters:
    network:
      config: "./yolov3-tiny.cfg"
      weights: "./yolov3-tiny.weights"
      class_names: "./coco.names"
    detection:
      threshold: 0.25
      nms_threshold: 0.45

Then run the node.

ros2 run openrobotics_darknet_ros detector_node __params:=detector_node_params.yaml

The node is now running. Publish images on ~/images to get the node to detect objects.