4. Astra object tracking

4.1. Introduction

Function package: ~/yahboomcar_ws/src/yahboomcar_astra

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

Object tracking is to locate an object in consecutive video frames. This definition sounds straightforward, but in computer vision and machine learning, tracking is a very broad term that encompasses conceptually similar but technically different concepts. For example, the following are all different but related ideas commonly studied under object tracking:

(1) Dense Optical flow DOF: These algorithms help estimate the motion vector of each pixel in a video frame.

(2) Sparse optical flow: For example, the Kanade-Lucas-Tomashi (KLT) feature tracking algorithm tracks the positions of several feature points in the image.

(3) Kalman Filtering: A very popular signal processing algorithm based on prior motion information, used to predict the position of moving targets. One of the early applications of this algorithm was in missile guidance! The onboard computer that guided the Apollo 11 lunar module to the moon had a Kalman filter.

(4) Meanshift and Camshift: This is an algorithm for locating the maximum value of the density function. They are also used for tracking.

(5) Single object trackers: In this type of trackers, the first frame is marked with a rectangle to indicate the location of the object to be tracked. The object is then tracked in subsequent frames using a tracking algorithm. In most real-world applications, these trackers are used together with object detectors.

(6) Multiple object track finding algorithms: When we have a fast object detector, detect multiple objects in each frame, and then run a tracking finding algorithm to identify which object in a frame It makes sense for the rectangle to correspond to the rectangle in the next frame.

AlgorithmSpeedAccuracyDescription
BOOSTINGSlowPoorThe same machine learning algorithm used behind Haar casades (AdaBoost),
but it has been around for more than ten years and is a veteran algorithm.
MILSlowPoorMore accurate than BOOSTING, but has a higher failure rate.
KCFFastHighFaster than BOOSTING and MIL, but does not perform well in occlusion situations.
TLDGeneralGeneralThere are many false positives, and the phenomenon of skewing is serious.
MEDIANFLOWGeneral +GeneralThere are very few false positives. For fast jumping or fast moving objects, the model will fail.
GOTURNGeneralGeneralDeep learning based object detector, which requires additional models to run.
MOSSEFastestHigh -The speed is really fast, but it is not as accurate as CSRT and KCF. If you are pursuing speed, you can choose it.
CSRTFast -HighestSlightly more accurate than KCF, but not as fast.

4.2, KCF object tracking

KCF stands for Kernel Correlation Filter Kernel Correlation Filtering Algorithm. It was proposed by Joao F. Henriques, Rui Caseiro, Pedro Martins, and Jorge Batista in 2014. After the algorithm came out, it was considered a sensation. This algorithm has very outstanding performance in both tracking effect and tracking speed. Therefore, a large number of scholars have been studying this algorithm, and the industry has also gradually applied this algorithm in actual scenarios. This [Algorithm Home Page] (http://www.robots.ox.ac.uk/~joao/circulant/index.html) contains papers and codes that can be downloaded here, as well as some introductions, etc. This article was published by the author on TPAMI in 2015, so you may see two versions, but there are no changes and both can be seen. Paper download address The related filtering algorithm is considered discriminative tracking. It mainly uses the given samples to train a discriminative classifier to determine whether the target or the surrounding background is tracked. information. The rotation matrix is mainly used to collect samples, and the fast Fourier transform is used to accelerate the calculation of the algorithm.

4.2.1. How to use

Note: [R2] on the remote control handle has the [pause/start] function for this gameplay.

One-click startup (robot side)

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 recognition.

image-20210913174837340

4.2.2. Keyboard control

<PI5 needs to open another terminal to enter the same docker container

image-20240408144126098

【r】: Reset mode, you can use the mouse to select the area to identify the target.

[q]: Exit the program.

[Spacebar]: Target tracking; just move the target slowly while following. If you move too fast, you will lose the target.

image-20220223113755759

Parameter analysis:

[linear_Kp], [linear_Ki], [linear_Kd]: PID control of linear speed during car following.

[angular_Kp], [angular_Ki], [angular_Kd]: PID control of angular velocity during car following.

[minDist]: Follow the distance and keep this distance.

When the parameters are adjusted to the optimal state, the corresponding parameters are modified into the file, and no adjustment is required when using again.

According to the optimal parameters of the [rqt_reconfigure] debugging tool, enter the [src] folder of the [yahboomcar_astra] function package and modify the parameters corresponding to the [KCF_Tracker.cpp] file, as shown below

The minDist parameter is modified in the [KCF_Tracker.h] file

[rqt_reconfigure] Modification of the initial value of the debugging tool

Enter the [cfg] folder of the [yahboomcar_astra] function package and modify the initial values of the parameters corresponding to the [KCFTracker.cfg] file.

Take the above article as an example to analyze

ParametersAnalysisCorresponding parameters
namename of the parameter"linear_Kp"
typeparameter data typedouble_t
levela bitmask passed to the callback0
descriptionA description parameter"Kp in PID"
defaultInitial value for node startup0.9
minparameter minimum value0
maxparameter maximum value10.0

Note: After modification, you must recompile and update the environment to be effective.

4.2.3. Node analysis

KCF_rosgraph

【KCF_Tracker】Node analysis

image-20220223120245156