First on the code
Compare two methods of calculating time:
GetTickCount function: It returns the number of ticks that have been initiated from the operating system to the current period.
Gettickfrequency function: Returns the number of ticks per second.
#include <iostream> #include <string> #include <fstream> #include <omp.h> //Turn on multi-core CPU Calculation mode # Include <cv.h>using namespace std;using namespace Cv;int main () {double t1= (double) getTickCount ();cout<< " T1 = "<<t1<<endl;int sum=0;for (int i=0;i<10000;i++) {sum+=i;} Double t2= (double) getTickCount ();cout<< "t2 =" <<t2<<endl;double time = (t2-t1)/gettickfrequency (); cout<< "time =" <<time<<endl;int64 e1 = GetTickCount ();cout<< "e1 =" <<e1<<endl; int sum1=0;for (int i=0;i<10000;i++) {sum1+=i;} Int64 e2 = GetTickCount ();cout<< "e2 =" <<e2<<endl;double time1 = (e2-e1)/gettickfrequency ();cout< < "time1 =" <<time1<<endl;system ("pause"); return 0;}
Code results:
GetTickCount and Gettickfrequency calculation time in OpenCV