The KCF (Kernelized Correlation Filter) tracking algorithm is used to track any object manually selected with a bounding box, and the car rotates to track so that the target stays at the center of the frame.
2. Experiment Principle
1. Keyword Explanation
Keyword
Description
KCF Tracking Algorithm
Kernelized Correlation Filter, which uses circulant matrices and the kernel trick to quickly learn the target appearance model
Circulant Matrix Sampling
KCF uses cyclic shifts to generate many training samples and accelerates matrix operations via FFT to achieve high-speed tracking
HOG Features
Histogram of Oriented Gradients, the target appearance feature used by KCF by default
ROI Selection
Drag with the mouse on the image to define the region of interest, used as the initialization target for the tracker
└── Body control timer (10Hz): pixel error → PD angular velocity → /cmd_vel (BEST_EFFORT)
Note: This feature only supports track (tracking) mode; follow and control modes are not supported. Once the KCF tracker loses the target, it cannot recover automatically.
3. Core Topic Quick Reference
Firmware Downlink
Topic
Message Type
QoS
Field
Range
Direction
/cmd_vel
geometry_msgs/Twist
best_effort + keep_last(1)
angular.z
-0.60~0.60 rad/s
+= turn left, −= turn right
3. Experiment Steps
1. Hardware Preparation
Hardware
Requirement
PTZ version
❌
No-PTZ version
✅
Required peripheral
ESP32 camera (bracket-mounted)
2. Start the Agent + Camera + Joint Model (Terminal 1)
kcf_tracker_node uses the OpenCV Tracker API. Core workflow:
Initialization: waits for the user to select an ROI with the mouse → press Space → create cv.TrackerKCF_create() (or MIL/CSRT) → tracker.init(frame, bbox)
Tracking loop (15Hz): each frame ok, bbox = tracker.update(frame) → on success, update the tracking box position + compute the centroid deviation → PD outputs angular velocity
Loss detection: ok=False or bbox out of the frame → mark as lost (Lost), wait for re-selection
KCF limitation: no automatic re-detection after loss; the user must manually re-initialize