change the timer using flann, higher precission

pull/300/head
Kurnianggoro 10 years ago
parent ba6f122d5e
commit ddfcaf9bd5
  1. 18
      modules/tracking/samples/multitracker.cpp

@ -11,6 +11,7 @@
#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.hpp>
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
@ -66,7 +67,7 @@ int main( int argc, char** argv ){
} }
// timer // timer
clock_t timer; cvflann::StartStopTimer timer;
// for showing the speed // for showing the speed
double fps; double fps;
@ -116,18 +117,23 @@ int main( int argc, char** argv ){
if(frame.rows==0 || frame.cols==0) if(frame.rows==0 || frame.cols==0)
break; break;
// update the tracking result // start the timer
timer=clock(); timer.start();
//update the tracking result
trackers.update(frame); trackers.update(frame);
timer=clock()-timer;
fps=(double)CLOCKS_PER_SEC/(double)timer; // calculate the processing speed
timer.stop();
fps=1.0/timer.value;
timer.reset();
// 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++)
rectangle( frame, trackers.objects[i], Scalar( 255, 0, 0 ), 2, 1 ); rectangle( frame, trackers.objects[i], Scalar( 255, 0, 0 ), 2, 1 );
// draw the processing speed // draw the processing speed
sprintf (buffer, "speed: %.02f fps", fps); sprintf (buffer, "speed: %.0f fps", fps);
text = buffer; text = buffer;
putText(frame, text, Point(20,20), FONT_HERSHEY_PLAIN, 1, Scalar(255,255,255)); putText(frame, text, Point(20,20), FONT_HERSHEY_PLAIN, 1, Scalar(255,255,255));

Loading…
Cancel
Save