4. KCF object tracking

1. Program function description

After the program starts, select the object to be tracked by the mouse and press the space bar, the cart enters the tracking mode. The cart will keep a distance of 1 meter from the object to be tracked, and always make sure the object to be tracked stays in the center of the screen. Press R to enter selection mode and Q to exit the program. After the joystick program is started, you can also pause/resume tracking by using the R2 key on the joystick.

2. Code reference path

After entering the docker container, the location of the source code for this feature is located at.

3. Program startup

3.1 Startup Commands

After entering the docker container, depending on the actual model, terminal input, the

image-20230424211626952

Use the mouse to frame the object to be tracked and release it to select the target. Then press spacebar to start tracking, move the object slowly, the cart will follow and keep 1m distance from the object.

You can also use the Dynamic Parameter Adjuster to debug the parameters by typing into the Docker terminal.

image-20230424212128263

The adjustable parameters are the PID of linear velocity and angular velocity of the trolley and the distance of tracking, after modifying the parameters, click "refresh" to refresh the data.

3.2 Viewing Node Topic Communication Map

The following commands can be used to view the topic communication between nodes.

image-20230512174302775

4. Core code

The principle of function implementation is similar to color tracking, both are based on the center coordinates of the target and the depth information fed by the depth camera to calculate the linear velocity and angular velocity, and then released to the chassis, part of the code into the following.