Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getTickCount time unit confusion

Tags:

opencv

At the answer to the question on Stack and in the book at here on page 52 I found the normal getTickCount getTickFrequency combination to measure time of execution gives time in milliseconds . However the OpenCV website says its time in seconds. I am confused. Please help...

like image 591
rotating_image Avatar asked Nov 30 '22 01:11

rotating_image


1 Answers

There is no room for confusion, all the references you have given point to the same thing.

getTickCount gives you the number of clock cycles after a certain event, eg, after machine is switched on.

A = getTickCount()  // A = no. of clock cycles from beginning, say 100
process(image)      // do whatever process you want
B = getTickCount()  // B = no. of clock cycles from beginning, say 150

C = B - A           // C = no. of clock cycles for processing, 150-100 = 50,
                    // it is obvious, right?

Now you want to know how many seconds are these clock cycles. For that, you want to know how many seconds a single clock takes, ie clock_time_period. If you find that, simply multiply by 50 to get total time taken.

For that, OpenCV gives second function, getTickFrequency(). It gives you frequency, ie how many clock cycles per second. You take its reciprocal to get time period of clock.

time_period = 1/frequency.

Now you have time_period of one clock cycle, multiply it with 50 to get total time taken in seconds.

Now read all those references you have given once again, you will get it.

like image 55
Abid Rahman K Avatar answered Dec 04 '22 04:12

Abid Rahman K