Git Product home page Git Product logo

srv-mrcnn-ros's Introduction

ROS Object Detection Package

This repo includes a ros_object_detection package that calls a maskrcnn inference service to run bounding box based object detection and semantic image segmentation. It considers two object classes only: person and the background.

Subscribes to the topics:

  1. /camera/depth_registered/points : contains colored point clouds published in the color optical frame of a RealSense D435 depth camera. Color images used for object detection are extracted from their reference colored point clouds.

Publishes into the topics:

  1. /object_detection/detected_objects : contains color images enhanced by segmentation masks and bounding boxes.
  2. /object_detection/results : contains Mask-RCNN person instance segmentation masks, and bounding boxes in pixels.
  3. /object_detection/pc2 : contains the original colored point cloud, published in the color optical frame.
  4. /object_detection/image_raw : contains the original RGB image extracted from the reference colored point cloud.

Installation

Requires:

  1. Ubuntu 18.4
  2. ROS Melodic
  3. Nvidia GPU
  4. Python 3.7

Installing dependencies with pip is recommended. A requirements.txt file is included in the project folder. To install the required dependencies inside a virtual environment run:

python -m virtualenv <name_of_the_virtualenv>
source <name_of_the_virtualenv>/bin/activate
pip install -r requirements.txt

Inference was done on an Nvidia GeForce GTX 1660 Ti.

Usage

For testing the ros_object_detection package, a patched version of the RealSense ROS wrapper (available under https://github.com/timeamagyar/realsense-ros/tree/ldrs_integration) must be installed on the host system. Testing requires a sample rosbag recorded with a RealSense D435 camera.

# cd into catkin ws
cd ~/catkin_ws
# in order to recognize packages run
source ~/catkin_ws/devel/setup.bash
# activate the python virtual environment
source  ~/<name_of_the_virtualenv>/bin/activate 
# check that the object detection package is registered in the local ros system
rospack list | grep object_detection
# check that the realsense row wrapper package is registered in the local ros system
rospack list | grep realsense2_camera
# start roscore
roscore
# cd into realsense2_camera package folder, and replay sample RealSense D435 bag with the realsense-ros wrapper to publish colored point clouds into the topic `/camera/depth_registered/points`
roslaunch realsense2_camera rs_from_file.launch rosbag_filename:=<path_to_realsense_raw_bag>
# cd into ros_object_detection package folder, and start object detection node
roslaunch object_detection object_detection.launch
# start rviz for visualization
rosrun rviz rviz
# to list available topics run
rostopic list

After launching the object detection package, 2D bounding box and segmentation results can be recorded into a ROS bag, needed by LDLS (3D semantic segmentation algorithm). For this run:

rosbag record --buffsize=0 /object_detection/detected_objects /object_detection/results /object_detection/pc2 /object_detection/image_raw --output-name=<file_name>.bag

Example:


rosbag record --buffsize=0 /object_detection/detected_objects /object_detection/results /object_detection/pc2 /object_detection/image_raw --output-name=rs_20191213_112223.bag

To record camera intrinsics, needed by LDLS (3D semantic segmentation algorithm) as well run:

rosbag play <realsense_raw_bag>
rosbag record --buffsize=0 /device_0/sensor_1/Color_0/info/camera_info --output-name=<file_name>_intrinsics.bag

Example:

rosbag play <realsense_raw_bag>
rosbag record --buffsize=0 /device_0/sensor_1/Color_0/info/camera_info --output-name=rs_20191213_112223_intrinsics.bag

Troubleshooting

If you encounter the following error 'ImportError: No module named rospkg' simply run:

export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

Make sure the following is on your python path:

# running echo $PYTHONPATH should return
/<path_to_catkin_ws>/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.