-
Notifications
You must be signed in to change notification settings - Fork 21
Object detection
Christopher Strøm edited this page Sep 30, 2021
·
6 revisions
Stereolabs ZED camera can be integrated for use with Darknet ROS package for object detection and distance estimation.
Prerequisites:
- ZED SDK setup
- Nvidia CUDA setup
- Create catkin workspace:
mkdir ~/zed_ros_wrapper
cd ~/darknet_ws
mkdir src
- Clone ZED ROS wrapper:
cd src
git clone https://github.com/stereolabs/zed-ros-wrapper
- Get ROS dependencies:
cd ..
rosdep install --from-paths src --ignore-src -r -y
- Build catkin workspace:
catkin build
- Source catkin workspace:
source ./devel/setup.bash
- Create catkin workspace:
mkdir ~/darknet_ws
cd ~/darknet_ws
mkdir src
- Clone ZED Darknet ROS wrapper:
cd src
git clone --recursive https://github.com/leoll2/darknet_ros_zed.git
- Update (CUDA) compute capability (version) of your GPU:
Nvidia GPUs support different compute versions according to its model, which needs to be taken into account for compiling the workspace. Find your GPU in the list of supported GPUs in CUDA and edit darknet_ros/CMakeLists.txt with the appropriate compute version.
Example for Nvidia GTX 1070 (compute version 6.1):
-
- Go to darknet_ros/CMakeLists.txt
cd ~/darknet_ws/src/darknet_ros_zed/darknet_ros
nano CMakeLists.txt
-
- Delete lines 24-30
-O3
-gencode arch=compute_30,code=sm_30
-gencode arch=compute_35,code=sm_35
-gencode arch=compute_50,code=[sm_50,compute_50]
-gencode arch=compute_52,code=[sm_52,compute_52]
-gencode arch=compute_61,code=sm_61
-gencode arch=compute_62,code=sm_62
-
- Add compute version 6.1
-O3 -gencode arch=compute_61,code=sm_61
- Build workspace with catkin:
cd ~/darknet_ws
catkin build
- Source workspace:
source devel/setup.bash
- Enable ZED camera in ROS launch:
# line 16 in /darknet_ros/launch/darknet_ros.launch
<arg name="zed" default="true"/>
- Change subscribed topics in darknet ROS config to match published topics from ZED camera:
# line 4 in /darknet_ros/config/ros.yaml
topic: /zed2/zed_node/stereo_raw/image_raw_color
# line 6
dmap_topic: /zed2/zed_node/depth/depth_registered
- Download weights:
cd darknet_ws/src/darknet_ros_zed/darknet_ros/yolo_network_config/weights/
wget http://pjreddie.com/media/files/yolov2.weights
wget http://pjreddie.com/media/files/yolov2-tiny.weights
wget http://pjreddie.com/media/files/yolov2-voc.weights
wget http://pjreddie.com/media/files/yolov2-tiny-voc.weights
- (Optional) Use your own detection objects
In order to use your own detection objects you need to provide your weights and your cfg file inside the directories:
darknet_ws/src/darknet_ros_zed/darknet_ros/yolo_network_config/weights/
darknet_ws/src/darknet_ros_zed/darknet_ros/yolo_network_config/cfg/
In addition, you need to create your config file for ROS where you define the names of the detection objects. You need to include it inside:
catkin_workspace/src/darknet_ros/darknet_ros/config/
Then in the launch file you have to point to your new config file in the line:
<rosparam command="load" ns="darknet_ros" file="$(find darknet_ros)/config/your_config_file.yaml"/>
- (Optional) Unit Tests
Run the unit tests using the Catkin Command Line Tools:
catkin build darknet_ros --no-deps --verbose --catkin-make-args run_tests
You will (maybe) see an image popping up.
- Run Darknet using ROS launch:
roslaunch darknet_ros darknet_ros.launch
HOME User Manual
- Git key setup
- Software installation
- Beluga
- Manta
- Pool testing at MC-Lab
- Using services to launch packages
Development Guidelines
Documentation
Theory and Resources