dnn_edge_detection
Detect the edges with a DNN model, e.g. DexiNed.
Edge detection with DexiNed of opencv_zoo (MIT License), whose ~/image is the edges in mono8 as edge_detection, the probability of the edge of each pixel (0 - 255). The model needs OpenCV 4.12 or later (OpenCV 4.6 and 4.10 cannot read it).
opencv_apps |
3.1.0 and later |
|---|---|
ROS |
any, with OpenCV built from source; not ROS One (OpenCV 4.6), jazzy (OpenCV 4.6), kilted (OpenCV 4.6), lyrical (OpenCV 4.10); not on lyrical, whose OpenCV 4.10 cannot read DexiNed |
OpenCV |
OpenCV 4.12 or later, which reads DexiNed (4.10 fails on DequantizeLinear) |
Group |
Image filters, the nodes of which publish the processed image in |
Usage
# ROS 2
ros2 launch opencv_apps dnn_edge_detection.launch.xml image:=/camera/image_raw debug_view:=false
# ROS 1
roslaunch opencv_apps dnn_edge_detection.launch image:=/camera/image_raw debug_view:=false
Try it with the demo video
Download the input video of the demo above, publish it as image with image_publisher, and run the node on it, in the terminals:
wget https://ros-perception.github.io/opencv_apps/media/clips/street.mp4
# terminal 1: publish the video as image in a loop
ros2 run image_publisher image_publisher_node street.mp4 --ros-args -p publish_rate:=10.0 -r image_raw:=image
# terminal 2: run the node
ros2 launch opencv_apps dnn_edge_detection.launch.xml image:=image
# terminal 3: view the result
ros2 run rqt_image_view rqt_image_view /dnn_edge_detection/image
DexiNed of opencv_zoo (MIT License), the same clip as edge_detection; needs OpenCV 4.12 or later.
In ROS 1:
# terminal 1
rosrun image_publisher image_publisher street.mp4 _publish_rate:=10 __name:=camera
# terminal 2
roslaunch opencv_apps dnn_edge_detection.launch image:=camera/image_raw
See Credits of the demo videos for the license of the video.
Subscribed topics
Topic |
Type |
|---|---|
|
|
Published topics
Topic |
Type |
|---|---|
|
|
Parameters
See also the common parameters.
Name |
Type |
Default (range) |
Changed at run time |
Description |
|---|---|---|---|---|
|
string |
“auto” |
yes |
Backend of cv::dnn: auto, cpu, opencl, opencl_fp16, cuda or cuda_fp16. auto uses CUDA when OpenCV is built with CUDA and a CUDA device is found, and the CPU otherwise. |
|
int |
512 (1 - 4096) |
yes |
Height of the network input, 512 for DexiNed |
|
int |
512 (1 - 4096) |
yes |
Width of the network input, 512 for DexiNed |
|
string |
“” |
yes |
Path or URL of the model (onnx) of the same input and output as DexiNed, empty for DexiNed of opencv_zoo (OpenCV 4.12 or later). The URL is downloaded to ~/.ros/opencv_apps/models/ at the first time |
|
int |
3 |
no, restart the node |
Specify queue_size of input image subscribers |
Source
src/nodelet/dnn_edge_detection_nodelet.cpp, launch/dnn_edge_detection.launch.xml