This project implements a human detection by an artificial neural network based on ROS 2.
The available detectors are
Notice: All data is included in this repository and the installation of those networks is executed during the following instructions.
Notice: For the online person detection a cognex camera is required but it is also possible to use the detection part on offline images and videos.
Ubuntu 20.04, Python 3.8+
Please make sure that you have installed all the required components before building the project.
- Go here for installation of ROS 2 Foxy. Make sure to install the ros-foxy-desktop package.
- If this is the first distribution of ROS that you installed on your PC, please execute (if not already done in the ROS Foxy installation):
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
- If you already installed a ROS distribution on your PC, go to your home directory and check the file ".bashrc" for the line
"source /opt/ros/.../setup.bash"
and replace the distribution with "foxy". If you can't see the file ".bashrc" in your home directory press "Strg + H".
- For using rosdep:
sudo apt-get install python3-rosdep
- For using colcon:
sudo apt-get install python3-colcon-common-extensions
- For the different detectors:
sudo apt-get install python3-venv
- For the usage of git:
sudo apt-get install git
- For linking the env to python3:
sudo apt-get install python-is-python3
- Create new development workspace
mkdir -p ~/dev_ws/src
- Go to the source folder of your workspace
cd ~/dev_ws/src
- Clone the repository
git clone <link_to_repo>
- Go to models
cd ros2_person_detection/detection_driver/models/
- Create a virtual environment
python3 -m venv ~/venv
- Enter the virtual environment
source ~/venv/bin/activate
- Install pip wheels
pip3 install wheel
- Install requirements
pip3 install -r requirements.txt
- Install Detectron2
pip3 install -e detectron2
- Exit from virtual environment
deactivate
- Go back to top level
cd ~/dev_ws
- Build the project
colcon build --symlink-install
-
Check the configurations inside the packages
package_name -> configs
-
If config was changed make sure to rebuild. You can avoid this by copying a config file to your home directory and use the param_file launch parameter (equivalent to venv) to refer to this config file.
cd ~/dev_ws && colcon build --symlink-install
-
Source the workspace
source ~/dev_ws/install/setup.bash
-
Run the Desired Programm:
Available Launch Parameters:
- venv -> absolute path to the python interpreter of your virtual environment
- param_file -> absolute path to the config file that should be used
Attention:
- Make sure to replace /path/to/ in the venv launch parameter with the absolute path to your virutal environment python interpreter.
- The venv parameter for the Cognex driver is only required if OpenCV is not installed on your system.
Programm Requirements Command Person Detection Connected Cognex camera, Check the config file person_detection/configs/default.yaml
, Rebuild if necessaryros2 launch person_detection person_detection.launch.py venv:=/path/to/venv/bin/python
Person Detection Testing No Cognex is required, Set the test_data parameter in person_detection/configs/test.yaml
, Rebuildros2 launch person_detection person_detection_test.launch.py venv:=/path/to/venv/bin/python
Cognex Camera Driver Connected Cognex camera, Check the config file cognex_driver/configs/default.yaml
, Rebuild if necessaryros2 launch cognex_driver cognex_driver.launch.py venv:=/path/to/venv/bin/python
Detection Driver No Cognex required, Check the config file detection_driver/configs/default.yaml
, Rebuild if necessaryros2 launch detection_driver detection_driver.launch.py venv:=/path/to/venv/bin/python
- If there are errors about missing modules like cv_bridge or similar. Make sure that you installed the ros-foxy-desktop and not the ros-foxy-base.
- If there are errors about missing modules of the detetction_driver you might have forgot the venv parameter at the launch command.