A ROS2 package for 2D and 3D object detection using RGB-D camera data.
object_detection_rgbd
is a ROS2 package that performs real-time 2D and 3D object detection using data from depth cameras. It leverages pre-trained models to detect objects and can convert 2D detections into 3D bounding boxes and point clouds. The package supports any COCO detection model with minimal adjustments and allows filtering of specific classes.
- 2D Object Detection: Performs detection using only color images.
- 3D Object Detection: Converts 2D detections into 3D bounding boxes and point clouds using depth data.
- RGB-D Support: Subscribes directly to RGB-D topics if available.
- Flexible Model Integration: Supports any COCO detection model with minimal porting.
- Class Filtering: Option to detect all classes or a specified subset.
- Visualization:
- Annotated images with bounding boxes.
- 3D markers for visualization in RViz.
- Point clouds of detected objects.
Check out a demo video of the package in action:
- ROS2 Jazzy: Ensure you have ROS2 Jazzy installed. Installation Guide
- Depth Camera: Tested with Intel RealSense D435 camera.
-
Clone the Repository
cd ~/ros2_ws/src git clone https://github.com/IliaLarchenko/object_detection_rgbd.git
-
Source ROS2
source /opt/ros/jazzy/setup.bash
-
Install Dependencies
rosdep install -i --from-path src --rosdistro jazzy -y
-
Build the Workspace
colcon build --symlink-install
-
Source the Workspace
source install/setup.bash
-
Create and Activate a Virtual Environment
python3.12 -m venv .venv source .venv/bin/activate
-
Install Python Dependencies
pip install -r requirements.txt
-
Source ROS2 and the Workspace
source /opt/ros/jazzy/setup.bash source install/setup.bash source .venv/bin/activate
-
Launch the Object Detection Node
ros2 launch object_detection_rgbd object_detection.launch.py
Modify topics or parameters in the launch file if necessary.
-
It works now, you can visualize it in RViz
Adjust parameters in the object_detection.launch.py
file to suit your setup:
-
Topics
image_topic
: Color image topic (default:/camera/color/image_raw
).depth_image_topic
: Depth image topic (default:/camera/aligned_depth_to_color/image_raw
).camera_info_topic
: Camera info topic (default:/camera/depth/camera_info
).rgbd_topic
: RGB-D topic (if using RGB-D input).use_rgbd
: Set toTrue
to subscribe to RGB-D topic instead of separate image and depth topics.
-
Publishers
detected_objects_topic
: Topic to publish detected objects.annotated_image_topic
: Topic for annotated images.publish_markers_topic
: Topic for 3D markers.output_pointcloud_topic
: Topic for point clouds of detected objects.
-
Detection Model Parameters
model_type
: Type of detection model (e.g.,detr
).model_name
: Name of the pre-trained model (e.g.,facebook/detr-resnet-50
).use_gpu
: Enable GPU acceleration (True
orFalse
).confidence_threshold
: Minimum confidence for detections (e.g.,0.9
).filter_classes
: List of classes to detect (e.g.,['person']
).
-
Visualization Parameters
publish_annotated_image
: Publish images with bounding boxes (True
orFalse
).publish_3d
: Publish 3D markers (True
orFalse
).publish_pointcloud
: Publish point clouds (True
orFalse
).pointcloud_color_mode
: Color mode for point clouds ('rgb'
,'class'
, or'none'
).
- Adjusting Topics: Ensure the topics match those provided by your camera. Modify them in the launch file if they differ.
- Model Selection: You can switch to different COCO models by changing the
model_name
parameter. - Filtering Classes: To detect specific classes, set the
filter_classes
parameter with the desired class names. - Visualization: Use RViz to visualize 3D markers and point clouds. Ensure the relevant parameters are set to
True
.
- Hobby Project: This package is developed as a hobby and is not professionally maintained.
- Performance: Performance optimization has not been a focus, I am pretty sure you can do it better.
- Testing: Tested only with Intel RealSense D435 camera on ROS2 Jazzy.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.