3、HD camera object tracking

3.1、Introduction

Website:https://learnopencv.com/object-tracking-using-opencv-cpp-python/#opencv-tracking-api

Object tracking is to locate an object in consecutive video frames.

AlgorithmSpeedAccuracyDescription
BOOSTINGSlowLowIt is the same as the machine learning algorithm behind Haar casades (AdaBoost),
but it has been born for more than ten years, a veteran algorithm.
MILSlowLowIt is more accurate than BOOSTING, but the failure rate is higher.
KCFFastHighFaster than BOOSTING and MIL, but it is not effective when there is occlusion
TLDMiddleMiddleThere are a lot of erro
MEDIANFLOWMiddle+MiddleThe model will fail for fast-jumping or fast-moving objects.
GOTURNMiddleMiddleA deep learning-based object detector requires additional models to run.
MOSSEFastestHighThe speed is really fast, but not as high as the accuracy of CSRT and KCF. If you are looking for speed, you can choose it.
CSRTFast -HigherSlightly more accurate than KCF, but not as fast as KCF.

3.2、Steps

Note: The [R2] of the handle remote controller can [Pause/Open] for all functions of robot car

3.2.1、Start up

Start the bottom driver control, and it can also be placed in other launch files. (Jetson nano side)

Method 1

Start up HD camera(Raspberry Pi side)

Start HS camera target tracking control(virtual machine)

Method 2

Note: press【q】key to exit.

This method can only be activated in the master controller that the camera is connected.

 

Set the parameters according to your needs, and you can also modify the launch file directly, so you don't need to attach parameters when you start.

3.2.2、Identify

After starting, enter the selection mode, use the mouse to select the location of the object, as shown in the figure below, release it to start recognize.

image-20210913174837340

Keyboard key control:

【r】:Color selection mode, the mouse can be used to select the area of the color to be recognized (cannot exceed the area range).

【f】: Switching algorithm: ['BOOSTING','MIL','KCF','TLD','MEDIANFLOW','MOSSE','CSRT','color'].

【q】: Exit the program.

【Space key】: Color follow. When following, we need to move the target slowly, moving too fast it will lose the target.

3.2.3、PID adjustment

Dynamic parameter

image-20210910124448214

 

Select [mono_Tracker] node, [Hmin], [Smin], [Vmin], [Hmax], [Smax], [Vmax] these six parameters do not need to be adjusted. When the slider is in the dragging state, no data will be transferred to the system. When we release the slider, the data will be transferred to the system; we can also select a row and then slide the mouse wheel.

Parameter analysis:

[Kp], [Ki], [Kd]: PID control during the movement of the robot car.

[Scale]: PID scaling.

3.2.4、Target follow

After identifying is ok, click [Space key] on the keyboard to execute the color following program.

image-20210910161042829

Subscribe to image topics; publish gimbal servo topics

image-20210910161428484

Subscribe to image topics; control gimbal servo following target object.