lk_flow
Tracks the feature points with the sparse Lucas-Kanade optical flow (cv::calcOpticalFlowPyrLK()). The points are given by the services, or by the corner detection.
opencv_apps |
1.11 and later (ROS 1), 3.0.0 and later (ROS 2) |
|---|---|
ROS |
noetic, ROS One, jazzy, kilted, lyrical and later |
OpenCV |
any version of the distributions |
Group |
Optical flow and motion, the nodes of which publish |
Usage
# ROS 2
ros2 launch opencv_apps lk_flow.launch.xml image:=/camera/image_raw debug_view:=false
# ROS 1
roslaunch opencv_apps lk_flow.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/keybridge.mp4
# terminal 1: publish the video as image in a loop
ros2 run image_publisher image_publisher_node keybridge.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 lk_flow.launch.xml image:=image_rect_throttle use_camera_info:=false
# terminal 3: run, keep it running
ros2 run topic_tools throttle messages image 5 image_rect_throttle
# terminal 4: then run once
ros2 service call /lk_flow/initialize_points std_srvs/srv/Empty
# terminal 5: view the result
ros2 run rqt_image_view rqt_image_view /lk_flow/image
The input is throttled to 5 Hz, and the points to track are initialized by the service.
See Credits of the demo videos for the license of the video.
Subscribed topics
Topic |
Type |
|---|---|
|
|
Published topics
Topic |
Type |
|---|---|
|
|
|
|
Services
Service |
Type |
|---|---|
|
|
|
|
|
|
Parameters
See also the common parameters.
Name |
Type |
Default (range) |
Changed at run time |
Description |
|---|---|---|---|---|
|
int |
3 (1 - 100) |
yes |
Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. |
|
double |
0.04 (0.001 - 10) |
yes |
Free parameter of the Harris detector |
|
int |
10 (1 - 100) |
yes |
Minimum possible Euclidean distance between the returned corners. |
|
double |
0.01 (0.001 - 10) |
yes |
Parameter characterizing the minimal acceptance quality of image corners. |
|
int |
3 |
no, restart the node |
Specigy queue_size of input image subscribers |