/isaac_ros_object_detection

Hardware-accelerated, deep learned model support for object detection including DetectNet

Primary LanguageC++Apache License 2.0Apache-2.0

Isaac ROS Object Detection

original image bounding box predictions using DetectNet

Overview

Isaac ROS Object Detection contains an ROS 2 package to perform object detection. isaac_ros_detectnet provides a method for spatial classification using bounding boxes with an input image. Classification is performed by a GPU-accelerated DetectNet model. The output prediction can be used by perception functions to understand the presence and spatial location of an object in an image.

graph of nodes using DetectNet

isaac_ros_detectnet is used in a graph of nodes to provide a bounding box detection array with object classes from an input image. A DetectNet model is required to produce the detection array. Input images may need to be cropped and resized to maintain the aspect ratio and match the input resolution of DetectNet; image resolution may be reduced to improve DNN inference performance, which typically scales directly with the number of pixels in the image. isaac_ros_dnn_image_encoder provides a DNN encoder to process the input image into Tensors for the DetectNet model. Prediction results are clustered in the DNN decoder to group multiple detections on the same object. Output is provided as a detection array with object classes.

DNNs have a minimum number of pixels that need to be visible on the object to provide a classification prediction. If a person cannot see the object in the image, it’s unlikely the DNN will. Reducing input resolution to reduce compute may reduce what is detected in the image. For example, a 1920x1080 image containing a distant person occupying 1k pixels (64x16) would have 0.25K pixels (32x8) when downscaled by 1/2 in both X and Y. The DNN may detect the person with the original input image, which provides 1K pixels for the person, and fail to detect the same person in the downscaled resolution, which only provides 0.25K pixels for the person.

Note: DetectNet is similar to other popular object detection models such as YOLOV3, FasterRCNN, and SSD, while being efficient at detecting multiple object classes in large images.

comparison of bounding box detection to segmentation

Object detection classifies a rectangle of pixels as containing an object, whereas image segmentation provides more information and uses more compute to produce a classification per pixel. Object detection is used to know if, and where in a 2D image, the object exists. If a 3D spacial understanding or size of an object in pixels is required, use image segmentation.

DNN Models

To perform DNN inferencing a DNN model is required. NGC provides DetectNet pre-trained models for use in your robotics application. Using TAO these pre-trained models can be fine-tuned for your application.

Isaac ROS NITROS Acceleration

This package is powered by NVIDIA Isaac Transport for ROS (NITROS), which leverages type adaptation and negotiation to optimize message formats and dramatically accelerate communication between participating nodes.

Performance

The performance results of benchmarking the prepared pipelines in this package on supported platforms are below:

Sample Graph Input Size AGX Orin Orin NX Orin Nano 8GB x86_64 w/ RTX 4060 Ti
DetectNet Object Detection Graph 544p 252 fps
8.7 ms
110 fps
13 ms
77.9 fps
18 ms
--

Note: These numbers are reported with defaults parameter values found in params.yaml.

These data have been collected per the methodology described here.

ROS 2 Graph Configuration

To run the DetectNet object detection inference, the following ROS 2 nodes should be set up and running:

DetectNet output image showing 2 tennis balls correctly identified

  1. Isaac ROS DNN Image encoder: This will take an image message and convert it to a tensor (TensorList that can be processed by the network.

  2. Isaac ROS DNN Inference - Triton: This will execute the DetectNet network and take as input the tensor from the DNN Image Encoder.

    Note: The Isaac ROS TensorRT package is not able to perform inference with DetectNet models at this time.

    The output will be a TensorList message containing the encoded detections. Use the parameters model_name and model_repository_paths to point to the model folder and set the model name. The .plan file should be located at $model_repository_path/$model_name/1/model.plan

  3. Isaac ROS Detectnet Decoder: This node will take the TensorList with encoded detections as input, and output Detection2DArray messages for each frame. See the following section for the parameters.

Table of Contents

Latest Update

Update 2023-05-25: Performance improvements.

Supported Platforms

This package is designed and tested to be compatible with ROS 2 Humble running on Jetson or an x86_64 system with an NVIDIA GPU.

Note: Versions of ROS 2 earlier than Humble are not supported. This package depends on specific ROS 2 implementation features that were only introduced beginning with the Humble release.

Platform Hardware Software Notes
Jetson Jetson Orin
Jetson Xavier
JetPack 5.1.1 For best performance, ensure that power settings are configured appropriately.
x86_64 NVIDIA GPU Ubuntu 20.04+
CUDA 11.8

Docker

To simplify development, we strongly recommend leveraging the Isaac ROS Dev Docker images by following these steps. This will streamline your development environment setup with the correct versions of dependencies on both Jetson and x86_64 platforms.

Note: All Isaac ROS Quickstarts, tutorials, and examples have been designed with the Isaac ROS Docker images as a prerequisite.

Quickstart

  1. Set up your development environment by following the instructions here.

  2. Clone this repository and its dependencies under ~/workspaces/isaac_ros-dev/src.

    cd ~/workspaces/isaac_ros-dev/src
    git clone https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_object_detection
    git clone https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_dnn_inference
    git clone https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_image_pipeline
    git clone https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_nitros
    git clone https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_common
  3. Pull down a ROS Bag of sample data:

    cd ~/workspaces/isaac_ros-dev/src/isaac_ros_object_detection/isaac_ros_detectnet && \
      git lfs pull -X "" -I "resources/rosbags"
  4. Launch the Docker container using the run_dev.sh script:

    cd ~/workspaces/isaac_ros-dev/src/isaac_ros_common && \
      ./scripts/run_dev.sh
  5. Inside the container, build and source the workspace:

    cd /workspaces/isaac_ros-dev && \
      colcon build --symlink-install && \
      source install/setup.bash
  6. (Optional) Run tests to verify complete and correct installation:

    colcon test --executor sequential
  7. Run the quickstart setup script which will download the PeopleNet Model from NVIDIA GPU Cloud(NGC)

    cd /workspaces/isaac_ros-dev/src/isaac_ros_object_detection/isaac_ros_detectnet && \
      ./scripts/setup_model.sh --height 632 --width 1200 --config-file resources/quickstart_config.pbtxt
  8. Run the following launch file to spin up a demo of this package:

    cd /workspaces/isaac_ros-dev && \
      ros2 launch isaac_ros_detectnet isaac_ros_detectnet_quickstart.launch.py
  9. Visualize and validate the output of the package in the rqt_image_view window. After about a minute, your output should look like this:

    DetectNet output image showing a tennis ball correctly identified

Next Steps

Try More Examples

To continue your exploration, check out the following suggested examples:

This package only supports models based on the Detectnet_v2 architecture. Some of the supported DetectNet models from NGC:

Model Name Use Case
TrafficCamNet Detect and track cars
PeopleNet People counting, heatmap generation, social distancing
DashCamNet Identify objects from a moving object
FaceDetectIR Detect faces in a dark environment with IR camera

Customize your Dev Environment

To customize your development environment, reference this guide.

Package Reference

isaac_ros_detectnet

Usage

ros2 launch isaac_ros_detectnet isaac_ros_detectnet.launch.py label_list:=<list of labels> enable_confidence_threshold:=<enable confidence thresholding> enable_bbox_area_threshold:=<enable bbox size thresholding> enable_dbscan_clustering:=<enable dbscan clustering> confidence_threshold:=<minimum confidence value> min_bbox_area:=<minimum bbox area value> dbscan_confidence_threshold:=<minimum confidence for dbscan algorithm> dbscan_eps:=<epsilon distance> dbscan_min_boxes:=<minimum returned boxes> dbscan_enable_athr_filter:=<area-to-hit-ratio filter> dbscan_threshold_athr:=<area-to-hit ratio threshold> dbscan_clustering_algorithm:=<choice of clustering algorithm> bounding_box_scale:=<bounding box normalization value> bounding_box_offset:=<XY offset for bounding box>

ROS Parameters

ROS Parameter Type Default Description
label_list string[] {"person", "bag", "face"} The list of labels. These are loaded from labels.txt(downloaded with the model)
confidence_threshold double 0.35 The min value of confidence used to threshold detections before clustering
min_bbox_area double 100 The min value of bouding box area used to threshold detections before clustering
dbscan_confidence_threshold double 0.35 Holds the epsilon to control merging of overlapping boxes. Refer to OpenCV groupRectangles and DBSCAN documentation for more information on epsilon.
dbscan_eps double 0.7 Holds the epsilon to control merging of overlapping boxes. Refer to OpenCV groupRectangles and DBSCAN documentation for more information on epsilon.
dbscan_min_boxes int 1 The minimum number of boxes to return.
dbscan_enable_athr_filter int 0 Enables the area-to-hit ratio (ATHR) filter. The ATHR is calculated as: ATHR = sqrt(clusterArea) / nObjectsInCluster.
dbscan_threshold_athr double 0.0 The area-to-hit ratio threshold.
dbscan_clustering_algorithm int 1 The clustering algorithm selection. (1: Enables DBScan clustering, 2: Enables Hybrid clustering, resulting in more boxes that will need to be processed with NMS or other means of reducing overlapping detections.
bounding_box_scale double 35.0 The scale parameter, which should match the training configuration.
bounding_box_offset double 0.0 Bounding box offset for both X and Y dimensions.

ROS Topics Subscribed

ROS Topic Interface Description
tensor_sub isaac_ros_tensor_list_interfaces/TensorList The tensor that represents the inferred aligned bounding boxes.

ROS Topics Published

ROS Topic Interface Description
detectnet/detections vision_msgs/Detection2DArray Aligned image bounding boxes with detection class.

Troubleshooting

Isaac ROS Troubleshooting

For solutions to problems with Isaac ROS, please check here.

Deep Learning Troubleshooting

For solutions to problems with using DNN models, please check here.

Updates

Date Changes
2023-05-25 Performance improvements
2023-04-05 Source available GXF extensions
2022-10-19 Updated OSS licensing
2022-08-31 Update to use NITROS for improved performance and to be compatible with JetPack 5.0.2
2022-06-30 Support for ROS 2 Humble and miscellaneous bug fixes
2022-03-21 Initial release