/detectron2_ros

A ROS Node for detecting objects using Detectron2.

Primary LanguageCMakeMIT LicenseMIT

Detectron2 Object Detector for ROS

A ROS Node for detecting objects using Detectron2.

Installation

It is necessary to install Detectron2 requirements in a python virtual environment as it requires Python 3.6 and ROS works with Python 2.7

  1. Install python Virtual Environment
sudo apt-get install python-pip
sudo pip install virtualenv
mkdir ~/.virtualenvs
sudo pip install virtualenvwrapper
export WORKON_HOME=~/.virtualenvs
echo '. /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc 
  1. Creating Virtual Environment
mkvirtualenv --python=python3.6 detectron2_ros
  1. Install the dependencies in the virtual environment
pip install -U torch==1.4+cu100 torchvision==0.5+cu100 -f https://download.pytorch.org/whl/torch_stable.html
pip install cython pyyaml==5.1
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
pip install opencv-python
pip install rospkg

Downloading the Package

Clone the package to the ROS workspace using git tools

git clone https://github.com/DavidFernandezChaves/detectron2_ros.git
cd detectron2_ros
git pull --all
git submodule update --init
workon detectron2_ros
python -m pip install -e detectron2

Compilation

Attention: DO NOT USE the python virtual environment previously built to compile catking packages.

catkin_make
source $HOME/.bashrc

Running

  1. Open a new terminal and use the virtual environment created.
workon detectron2_ros
  1. Running the node
roslaunch detectron2_ros detectron2_ros.launch

Arguments

The following arguments can be set on the roslaunch above.

  • input: image topic name
  • detection_threshold: threshold to filter the detection results [0, 1]
  • visualization: True or False to pubish the result like a image
  • publish_rate: Published frequency
  • model: path to the training model file. For example: /detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml

Citing Detectron

If you use Detectron2 in your research or wish to refer to the baseline results published in the Model Zoo, please use the following BibTeX entry.

@misc{wu2019detectron2,
  author =       {Yuxin Wu and Alexander Kirillov and Francisco Massa and
                  Wan-Yen Lo and Ross Girshick},
  title =        {Detectron2},
  howpublished = {\url{https://github.com/facebookresearch/detectron2}},
  year =         {2019}
}