17#include "samples_utility.hpp"
22int main(
int argc,
char** argv ){
26 " Usage: example_tracking_multitracker <video_name> [algorithm]\n"
28 " example_tracking_multitracker Bolt/img/%04d.jpg\n"
29 " example_tracking_multitracker faceocc2.webm MEDIANFLOW\n"
35 std::string trackingAlg =
"KCF";
39 trackingAlg = argv[2];
48 vector<Rect2d> objects;
52 std::string video = argv[1];
61 selectROIs(
"tracker",frame,ROIs);
70 std::vector<Ptr<legacy::Tracker> > algorithms;
71 for (
size_t i = 0; i < ROIs.size(); i++)
73 algorithms.push_back(createTrackerByName_legacy(trackingAlg));
74 objects.push_back(ROIs[i]);
77 trackers.
add(algorithms,frame,objects);
81 printf(
"Start the tracking process, press ESC to quit.\n");
87 if(frame.rows==0 || frame.cols==0)
97 for(
unsigned i=0;i<trackers.
getObjects().size();i++)
102 imshow(
"tracker",frame);
105 if(waitKey(1)==27)
break;
n-dimensional dense array class
Definition mat.hpp:840
Class for video capturing from video files, image sequences or cameras.
Definition videoio.hpp:786
This class is used to track multiple objects using the specified tracker algorithm.
Definition tracking_legacy.hpp:352
const std::vector< Rect2d > & getObjects() const
Returns a reference to a storage for the tracked objects, each object corresponds to one tracker algo...
bool add(Ptr< cv::legacy::Tracker > newTracker, InputArray image, const Rect2d &boundingBox)
Add a new object to be tracked.
bool update(InputArray image)
Update the current tracking status. The result will be saved in the internal storage.
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3