Commit 5fa7b5bb authored by Kurnianggoro's avatar Kurnianggoro

Add preprocessor directive to use flann

parent bab52b03
...@@ -3,19 +3,28 @@ ...@@ -3,19 +3,28 @@
* example_tracking_multitracker <video_name> [algorithm] * example_tracking_multitracker <video_name> [algorithm]
* *
* example: * example:
* example_tracking_multitracker Bolt/img/%04.jpg * example_tracking_multitracker Bolt/img/%04d.jpg
* example_tracking_multitracker faceocc2.webm KCF * 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/core/utility.hpp>
#include <opencv2/tracking.hpp> #include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp> #include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include "opencv2/flann/timer.h" // it should be opencv2/flann.hpp
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#ifdef HAVE_OPENCV
#include <opencv2/flann.hpp>
#endif
#define RESET "\033[0m" #define RESET "\033[0m"
#define RED "\033[31m" /* Red */ #define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */ #define GREEN "\033[32m" /* Green */
...@@ -60,14 +69,22 @@ int main( int argc, char** argv ){ ...@@ -60,14 +69,22 @@ int main( int argc, char** argv ){
cout<< cout<<
" Usage: example_tracking_multitracker <video_name> [algorithm]\n" " Usage: example_tracking_multitracker <video_name> [algorithm]\n"
" examples:\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" " 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; << endl;
return 0; return 0;
} }
// timer // timer
#ifdef HAVE_OPENCV
cvflann::StartStopTimer timer; cvflann::StartStopTimer timer;
#else
clock_t timer;
#endif
// for showing the speed // for showing the speed
double fps; double fps;
...@@ -118,15 +135,26 @@ int main( int argc, char** argv ){ ...@@ -118,15 +135,26 @@ int main( int argc, char** argv ){
break; break;
// start the timer // start the timer
#ifdef HAVE_OPENCV
timer.start(); timer.start();
#else
timer=clock();
#endif
//update the tracking result //update the tracking result
trackers.update(frame); trackers.update(frame);
// calculate the processing speed // calculate the processing speed
#ifdef HAVE_OPENCV
timer.stop(); timer.stop();
fps=1.0/timer.value; fps=1.0/timer.value;
timer.reset(); timer.reset();
#else
timer=clock();
trackers.update(frame);
timer=clock()-timer;
fps=(double)CLOCKS_PER_SEC/(double)timer;
#endif
// draw the tracked object // draw the tracked object
for(unsigned i=0;i<trackers.objects.size();i++) for(unsigned i=0;i<trackers.objects.size();i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment