Commit ddfcaf9b authored by Kurnianggoro's avatar Kurnianggoro

change the timer using flann, higher precission

parent ba6f122d
...@@ -11,6 +11,7 @@ ...@@ -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 ){ ...@@ -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 ){ ...@@ -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));
......
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