Target tracking of opencv3 (single target, multi-target)

For opencv players who are just getting started, when they mention target tracking, they immediately think of camshift, but camshift tracking often fails to meet our tracking requirements, including stability and accuracy.

After the release of opencv3.1, it integrates multiple tracking algorithms, namely trackers, most of which are well-known algorithms on the VOT competition list in recent years. Although there are still defects, the effect is not bad.

ps: I saw an introduction to target tracking on Zhihu, and it feels good. The link is here!

Single target tracking is very simple, put an official routine for reference (opencv official):

Among them,  the creation of the tracker can be selected from the following types, which represent the tracking algorithm used;

  • ONE THOUSAND
  • BOOSTING
  • MEDIANFLOW
  • TLD
  • KCF

eg-- Ptr<Tracker> tracker = Tracker::create("KCF"); 

Multi-target tracking uses MultiTracker, such as MultiTracker myTracker("KCF") , pay attention to two points, add target with its member function myTracker.add(Mat src, Rect2d roi), get tracking result use myTracker.update( Mat src, vector <Rect2d> targets ), the serial number of the tracking result is the serial number of the vector.

The following code is to track the target selected by the mouse, and the number of targets to be tracked is about 10 (in principle, there is no upper limit, but my computer is relatively bad, and if there are too many targets, it will be stuck)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324890655&siteId=291194637