|
|
|
@ -3,19 +3,28 @@ |
|
|
|
|
* example_tracking_multitracker <video_name> [algorithm] |
|
|
|
|
* |
|
|
|
|
* example: |
|
|
|
|
* example_tracking_multitracker Bolt/img/%04.jpg |
|
|
|
|
* example_tracking_multitracker Bolt/img/%04d.jpg |
|
|
|
|
* example_tracking_multitracker faceocc2.webm KCF |
|
|
|
|
* |
|
|
|
|
* Note: after the OpenCV libary is installed, |
|
|
|
|
* please re-compile this code with "HAVE_OPENCV" parameter activated |
|
|
|
|
* to enable the high precission of fps computation |
|
|
|
|
*--------------------------------------------------*/ |
|
|
|
|
|
|
|
|
|
#define HAVE_OPENCV |
|
|
|
|
|
|
|
|
|
#include <opencv2/core/utility.hpp> |
|
|
|
|
#include <opencv2/tracking.hpp> |
|
|
|
|
#include <opencv2/videoio.hpp> |
|
|
|
|
#include <opencv2/highgui.hpp> |
|
|
|
|
#include "opencv2/flann/timer.h" // it should be opencv2/flann.hpp |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <cstring> |
|
|
|
|
#include <ctime> |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENCV |
|
|
|
|
#include <opencv2/flann.hpp> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#define RESET "\033[0m" |
|
|
|
|
#define RED "\033[31m" /* Red */ |
|
|
|
|
#define GREEN "\033[32m" /* Green */ |
|
|
|
@ -60,14 +69,22 @@ int main( int argc, char** argv ){ |
|
|
|
|
cout<< |
|
|
|
|
" Usage: example_tracking_multitracker <video_name> [algorithm]\n" |
|
|
|
|
" examples:\n" |
|
|
|
|
" example_tracking_multitracker Bolt/img/%04.jpg\n" |
|
|
|
|
" example_tracking_multitracker Bolt/img/%04d.jpg\n" |
|
|
|
|
" example_tracking_multitracker faceocc2.webm MEDIANFLOW\n" |
|
|
|
|
" \n" |
|
|
|
|
" Note: after the OpenCV libary is installed,\n" |
|
|
|
|
" please re-compile with the HAVE_OPENCV parameter activated\n" |
|
|
|
|
" to enable the high precission of fps computation.\n" |
|
|
|
|
<< endl; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// timer
|
|
|
|
|
#ifdef HAVE_OPENCV |
|
|
|
|
cvflann::StartStopTimer timer; |
|
|
|
|
#else |
|
|
|
|
clock_t timer; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// for showing the speed
|
|
|
|
|
double fps; |
|
|
|
@ -118,15 +135,26 @@ int main( int argc, char** argv ){ |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
// start the timer
|
|
|
|
|
#ifdef HAVE_OPENCV |
|
|
|
|
timer.start(); |
|
|
|
|
#else |
|
|
|
|
timer=clock(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
//update the tracking result
|
|
|
|
|
trackers.update(frame); |
|
|
|
|
|
|
|
|
|
// calculate the processing speed
|
|
|
|
|
#ifdef HAVE_OPENCV |
|
|
|
|
timer.stop(); |
|
|
|
|
fps=1.0/timer.value; |
|
|
|
|
timer.reset(); |
|
|
|
|
#else |
|
|
|
|
timer=clock(); |
|
|
|
|
trackers.update(frame); |
|
|
|
|
timer=clock()-timer; |
|
|
|
|
fps=(double)CLOCKS_PER_SEC/(double)timer; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// draw the tracked object
|
|
|
|
|
for(unsigned i=0;i<trackers.objects.size();i++) |
|
|
|
|