blob_detection
Detects the blobs (regions of similar brightness or color) with cv::SimpleBlobDetector, filtered by their area, circularity, convexity and inertia.
opencv_apps |
3.0.0 and later |
|---|---|
ROS |
ROS One, jazzy, kilted, lyrical and later |
OpenCV |
any version of the distributions |
Group |
Features and shapes, the nodes of which publish |
Usage
# ROS 2
ros2 launch opencv_apps blob_detection.launch.xml image:=/camera/image_raw debug_view:=false
# ROS 1
roslaunch opencv_apps blob_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/ballpit.mp4
# terminal 1: publish the video as image in a loop
ros2 run image_publisher image_publisher_node ballpit.mp4 --ros-args -p publish_rate:=10.0 -r image_raw:=image
# terminal 2: run the node with the parameters of the demo
ros2 launch opencv_apps blob_detection.launch.xml image:=hsv_color_filter/image min_area:=200.0
# terminal 3: run, keep it running
ros2 launch opencv_apps hsv_color_filter.launch.xml h_limit_min:=40 h_limit_max:=70 s_limit_min:=150 s_limit_max:=255 v_limit_min:=120 v_limit_max:=255
# terminal 4: view the result
ros2 run rqt_image_view rqt_image_view /blob_detection/image
The input is the mask of the yellow balls of hsv_color_filter.
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 |
|---|---|---|---|---|
|
int |
255 (0 - 255) |
yes |
0 to extract dark blobs and 255 to extract light blobs |
|
bool |
true |
yes |
Filter the blobs by the area |
|
bool |
false |
yes |
Filter the blobs by the circularity (4*pi*area/perimeter^2) |
|
bool |
true |
yes |
Filter the blobs by the color of the center |
|
bool |
false |
yes |
Filter the blobs by the convexity (area / area of convex hull) |
|
bool |
false |
yes |
Filter the blobs by the inertia ratio (the minimum / maximum second central moment, the square of minor axis / major axis for an ellipse, 0: line, 1: circle) |
|
double |
100000.0 (0 - 1e+06) |
yes |
The maximum area (exclusive) of the blobs [pixel] |
|
double |
1.0 (0 - 1) |
yes |
The maximum circularity (exclusive) of the blobs, 1.0 means no limit |
|
double |
1.0 (0 - 1) |
yes |
The maximum convexity (exclusive) of the blobs, 1.0 means no limit |
|
double |
1.0 (0 - 1) |
yes |
The maximum inertia ratio (exclusive) of the blobs, 1.0 means no limit |
|
double |
220.0 (0 - 255) |
yes |
The maximum threshold (exclusive) to binarize the image |
|
double |
25.0 (0 - 1e+06) |
yes |
The minimum area (inclusive) of the blobs [pixel] |
|
double |
0.8 (0 - 1) |
yes |
The minimum circularity (inclusive) of the blobs |
|
double |
0.95 (0 - 1) |
yes |
The minimum convexity (inclusive) of the blobs |
|
double |
10.0 (0 - 1000) |
yes |
The blobs located closer than min_dist_between_blobs are merged |
|
double |
0.1 (0 - 1) |
yes |
The minimum inertia ratio (inclusive) of the blobs |
|
int |
2 (1 - 255) |
yes |
The minimum number of the binarized images in which a blob is detected |
|
double |
50.0 (0 - 255) |
yes |
The minimum threshold to binarize the image |
|
int |
3 |
no, restart the node |
Specify queue_size of input image subscribers |
|
double |
10.0 (1 - 255) |
yes |
Step of the thresholds from min_threshold to max_threshold |
Source
src/nodelet/blob_detection_nodelet.cpp, launch/blob_detection.launch.xml