CMT Tracking Algorithm Learning notes (i)

Source: Internet
Author: User
Tags comments
Introduction

Recently, in the process of learning target tracking algorithm, it is found that the code of CMT algorithm is very good. Compared to the previously learned SCM and other based on sparse representation of the tracking algorithm, the robustness of CMT is not necessarily higher, but the sparse representation of the method is generally time-consuming is serious, resulting in it can not be applied to the actual project, and CMT is able to take into account the real-time and robustness.

Consult the data found that CMT corresponding to the paper has won the 2014 WACV Conference of the best Paper award. The author then further perfected the algorithm, and published the relevant papers on CVPR2015, so it seems that CMT algorithm is worthy of research. It is commendable that the author has published the complete algorithm source code on the paper home page http://www.gnebehay.com/cmt/, which contains all of C + + and Python all the codes. Because do not understand python, these days carefully read the C + + source code, have to say, the author's style is very standardized, comments are written in very detailed, read up hearty. In addition, the homepage of this site also has the author's own profile, in fact, he is the author of Opentld code, this shows the depth of its programming skills.

By the way, previously downloaded from the website of C + + source, may compile the M_PI not declared and int s[2*n-1] N is not a constant, such as errors, now the author has modified the source of GitHub on these small errors, we download the latest version of the source code on the line. In addition, the author in the Code project to add a very friendly command line parameter parsing code, as to how to use webcam or video or sequence test, the source folder has detailed instructions, not to repeat.

Combined with the paper, understanding the source of CMT is not too difficult, the author in the code to do some engineering treatment, mainly reflected in the key points of two matches and fusion, looks simple but very effective. Here I use Visio to draw a flowchart of the entire algorithm, in order to more clearly understand the core idea of CMT algorithm and concrete implementation method.

void CMT: processing flow for:p rocessframe (Mat im_gray) function


Source Summary

All the functions of the CMT algorithm are implemented in the CMT class, which consists of 4 large components, packaged into 4 classes: Tracker, Matcher, Consensus, Fusion. In addition, the CMT class also includes fast detector and brisk descriptor.


Tracker – Using the pyramid LK Optical Flow method

Tracker.track (Im_prev, Im_gray, points_active, points_tracked, status);

The valid key points in the t-1 frame are known points_active, by calculating the forward optical flow (t-1 frame to T frame) and the back light flow (frame T to frame t-1), and then comparing the distance between the corresponding key points obtained twice, and the key points with distance greater than the threshold are excluded, The remaining key points are the key points to follow. Matcher – Feature description match with "bruteforce-hamming" type


Matcher Initialization

Matcher.initialize (points_normalized, DESCS_FG, CLASSES_FG, DESCS_BG, center);

The feature description of all foreground and background keys in the first frame is constructed into a feature description library database. Note that the feature description of the background key is stored in front of the DESC_BG, and then when the database_potential is constructed, the storage foreground key index indices_potential need to add the total number of background key points num_bg_points.


key point Global match

Matcher.matchglobal (keypoints, descriptors, Points_matched_global, Classes_matched_global);

The feature description of all the key points obtained by the detector in the current frame is knnmatch matched with database (k=2), and each feature descriptor finds the best 2 matching results in database, and excludes the matching key points that match one of the following conditions: matching to the background key; The matching distance of the best match is greater than the threshold 0.25; the match distance between best match and sub-good match is greater than the threshold 0.8 (the smaller the ratio, the better match is better than the second best match)


key point Local match

Matcher.matchlocal (keypoints, descriptors, center, scale, rotation,points_matched_local,
    classes_matched_local );
Compares the Euclidean distance between each key detected in the current frame and all foreground keys after the rotation and scale transformations in the first frame, which is less than the threshold of 20, the foreground key is likely to match, and these possible foreground keys are constructed as a feature description library database_potential , the characteristic description of each key detected in the current frame is knnmatch matched with database_potential, and each feature descriptor finds the best 2 matching results in database_potential. Policies that rule out unstable keys are similar to Matchglobal. Consensus – Conformance constraints for target key points


consensus initialization

Consensus.initialize (points_normalized);

Calculates and saves the distance distances_pairwise between all normalized foreground keys in the first frame points_normalized the angle of the x-axis (ARC-tangent) angles_pairwise and the key point 22.

evaluate the current rotation angle and scale factor

Consensus.estimatescalerotation (points_fused, classes_fused, scale, rotation);

Calculate the angle of the key points after Matchglobal match and the distance between key points 22, and find the difference between the angle of the corresponding points_normalized key points, the distance quotient, and then take the average value respectively. Evaluates the scaling factor scale and rotation angle rotation of the target in the current frame.


get target location and inliers key points

Consensus.findconsensus (points_fused, classes_fused, scale, rotation, center,
    Points_inlier, classes_inlier);
Calculate the matchglobal of the key points after the match, that is, each key point and corresponding after the scale and rotation of the points_normalized key points formed between the vector; calculates the distance between 22 votes (vectors in 1), ascending by the size of the distance; Clustering and obtaining the largest class in the result, (when the distance between two classes is less than the threshold, merging the two classes) takes all the keys in this class as points_inlier, and the coordinate mean of all points_inlier keys as the center point of the target. Fusion – combine two key points with no repetition


initial convergence of key points

Fusion.preferfirst (points_tracked, classes_tracked, Points_matched_global, Classes_matched_global,
    points_ Fused, classes_fused);

The key points that the optical flow is traced to are fused with the key points that the Matchglobal match to, and the keys are used to evaluate the rotation angle and scale of the target and to poll for the target center position.


key points two times fusion

Fusion.preferfirst (points_matched_local, classes_matched_local, Points_inlier, Classes_inlier,
    points_active, classes_active);

The key points matched to the matchlocal are fused with the Inliers key points to obtain the final effective target key points_active, which are used for the tracking of the next frame.



————————————————————————————————
The code in the main function has nothing to do with the algorithm itself, and in this case it is not summed up, with detailed comments in the source code to help the reader understand.
The details of the code and the understanding of the paper, the next time to write.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.