3. Color tracking

1. Program function description

After the program starts, the default tracking color is red, you can press r/R to enter the color selection mode, select a color by mouse, the cart will lock this color, press space bar to enter the tracking mode. The cart will keep a distance of 1 meter from the object being tracked, and always make sure the object being tracked stays in the center of the screen. Press q/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. Program code reference path

3. Program Startup

3.1. Startup Commands

After entering the docker container, according to the actual model, terminal input, the

In the case of Tracking Red, for example, when the program starts, the following screen will appear.

image-20230424180311934

Then press the r/R key on the keyboard to enter the color selection mode, and use the mouse to frame an area (the area can only have one of the colors), the

image-20230424180532030

After the selection, the effect is as follows.

image-20230424180632000

Then, press the spacebar to enter the tracking mode, move the object slowly, the cart will follow and keep a distance of 1 meter.

3.2. Dynamic Parameter Adjustment

Docker terminal input.

image-20230424182403959

After modifying the parameters, click on the GUI blank to write the parameter values. From the above figure, we can see that

4. Core Code

4.1, colorHSV.py

This program has the following main functions:

Some of the core code is as follows.

4.2, colorTracker.py

This program has the following main functions: receive /Current_point and depth image topic data, calculate the speed magnitude, and then publish the speed data.

Part of the code is as follows.