6. KCF object tracking

1. Start the program

image-20230620175704193

After the program is successfully started, the mouse will select the object to be tracked, and it will be framed when it is released, as shown in the picture below.

image-20230620175836978

Then press the space bar to start tracking the object. The terminal prints out the center coordinates of the tracking object and the distance,

image-20230620180035573

Similarly, since there is no robot chassis driver, the object tracking phenomenon cannot be visually seen, but the object tracking can be reflected by the terminal information and the change of the /cmd_vel topic data. To view the speed topic data, enter the following command,

image-20230620180336180

Move the object being tracked, and the speed data here will also change.

View communication between nodes, terminal input,

image-20230620180648415

2. Core code

Code reference path,

The principle of functional implementation is similar to color tracking, which is based on the central coordinates of the target and the depth information fed by the depth camera to calculate the linear speed and angular speed, and then released to the chassis, part of the code is as follows.