mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 21:40:49 +08:00
Added Multi-tracker functionality and example
1. Multi-tracker classes (multiTracker.cpp) 2. Multi-tracker example (multiTracker_test.cpp) 3. Fixed a rare bug (OpenCL runtime error)
This commit is contained in:
@@ -49,7 +49,11 @@ using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
#define NUM_TEST_FRAMES 100
|
||||
<<<<<<< HEAD
|
||||
#define TEST_VIDEO_INDEX 15 //TLD Dataset Video Index from 1-10 for TLD and 1-60 for VOT
|
||||
=======
|
||||
#define TEST_VIDEO_INDEX 7 //TLD Dataset Video Index from 1-10
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
//#define RECORD_VIDEO_FLG
|
||||
|
||||
static Mat image;
|
||||
@@ -119,8 +123,17 @@ int main()
|
||||
|
||||
//From TLD dataset
|
||||
selectObject = true;
|
||||
<<<<<<< HEAD
|
||||
Rect2d boundingBox1 = tld::tld_InitDataset(TEST_VIDEO_INDEX, "D:/opencv/VOT 2015", 1);
|
||||
Rect2d boundingBox2(470, 490, 50, 120);
|
||||
=======
|
||||
Rect2d boundingBox1 = tld::tld_InitDataset(TEST_VIDEO_INDEX, "D:/opencv/TLD_dataset");
|
||||
Rect2d boundingBox2;
|
||||
boundingBox2.x = 280;
|
||||
boundingBox2.y = 60;
|
||||
boundingBox2.width = 40;
|
||||
boundingBox2.height = 60;
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
|
||||
frame = tld::tld_getNextDatasetFrame();
|
||||
frame.copyTo(image);
|
||||
@@ -129,14 +142,22 @@ int main()
|
||||
#ifdef RECORD_VIDEO_FLG
|
||||
String outputFilename = "test.avi";
|
||||
VideoWriter outputVideo;
|
||||
<<<<<<< HEAD
|
||||
outputVideo.open(outputFilename, -1, 15, Size(image.cols, image.rows));
|
||||
=======
|
||||
outputVideo.open(outputFilename, -1, 30, Size(image.cols, image.rows));
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
|
||||
if (!outputVideo.isOpened())
|
||||
{
|
||||
std::cout << "!!! Output video could not be opened" << std::endl;
|
||||
getchar();
|
||||
<<<<<<< HEAD
|
||||
return 0;
|
||||
|
||||
=======
|
||||
return;
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -180,17 +201,26 @@ int main()
|
||||
{
|
||||
//initializes the tracker
|
||||
mt.addTarget(frame, boundingBox1, tracker_algorithm_name);
|
||||
<<<<<<< HEAD
|
||||
rectangle(frame, boundingBox1, mt.colors[0], 2, 1);
|
||||
|
||||
|
||||
mt.addTarget(frame, boundingBox2, tracker_algorithm_name);
|
||||
rectangle(frame, boundingBox2, mt.colors[1], 2, 1);
|
||||
=======
|
||||
rectangle(image, boundingBox1, mt.colors[0], 2, 1);
|
||||
|
||||
|
||||
mt.addTarget(frame, boundingBox2, tracker_algorithm_name);
|
||||
rectangle(image, boundingBox2, mt.colors[1], 2, 1);
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//updates the tracker
|
||||
if (mt.update(frame))
|
||||
<<<<<<< HEAD
|
||||
{
|
||||
for (int i = 0; i < mt.targetNum; i++)
|
||||
rectangle(frame, mt.boundingBoxes[i], mt.colors[i], 2, 1);
|
||||
@@ -201,6 +231,16 @@ int main()
|
||||
|
||||
#ifdef RECORD_VIDEO_FLG
|
||||
outputVideo << frame;
|
||||
=======
|
||||
for (int i=0; i < mt.targetNum; i++)
|
||||
rectangle(image, mt.boundingBoxes[i], mt.colors[i], 2, 1);
|
||||
}
|
||||
}
|
||||
imshow("Tracking API", image);
|
||||
|
||||
#ifdef RECORD_VIDEO_FLG
|
||||
outputVideo << image;
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
#endif
|
||||
|
||||
|
||||
@@ -209,7 +249,11 @@ int main()
|
||||
double t1 = (e2 - e1) / getTickFrequency();
|
||||
cout << frameCounter << "\tframe : " << t1 * 1000.0 << "ms" << endl;
|
||||
|
||||
<<<<<<< HEAD
|
||||
//waitKey(0);
|
||||
=======
|
||||
waitKey(0);
|
||||
>>>>>>> Added Multi-tracker functionality and example
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user