A ROS Node for detecting objects using Detectron2.
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
- 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
- Creating Virtual Environment
mkvirtualenv --python=python3.6 detectron2_ros
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
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
Attention: DO NOT USE the python virtual environment previously built to compile catking packages.
catkin_make
source $HOME/.bashrc
- Open a new terminal and use the virtual environment created.
workon detectron2_ros
- Running the node
roslaunch detectron2_ros detectron2_ros.launch
The following arguments can be set on the roslaunch
above.
input
: image topic namedetection_threshold
: threshold to filter the detection results [0, 1]visualization
: True or False to pubish the result like a imagepublish_rate
: Published frequencymodel
: path to the training model file. For example:/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml
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}
}