getTickCount时间单位混乱 [英] getTickCount time unit confusion

查看:145
本文介绍了getTickCount时间单位混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在堆栈上以及本书中的问题的答案中在第52页的此处,我发现了用于测量执行时间的常规getTickCount getTickFrequency组合给出了以毫秒为单位的时间.但是 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...

推荐答案

没有混淆的余地,您提供的所有引用都指向同一件事.

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

getTickCount在特定事件发生后(例如,在开机后)为您提供时钟周期数.

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?

现在您想知道这些时钟周期是多少秒.为此,您想知道单个时钟要花费多少秒,即 clock_time_period .如果找到了,只需乘以50就可以得到总的时间.

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.

为此,OpenCV提供了第二个功能getTickFrequency().它为您提供频率,即每秒多少个时钟周期.您以其倒数来获取时钟的时间段.

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.

现在您有一个时钟周期 time_period ,将其乘以50可得到以秒为单位的总时间.

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.

这篇关于getTickCount时间单位混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆