OpenCV 利用getTickCount()与getTickFrequency()计算执行时间
来源:互联网 发布:阿里云虚拟机价 价格 编辑:程序博客网 时间:2024/05/23 09:58
其实这是个很简单的应用,贴出来是因为我经常能用到这两个函数,顺便写一下吧。
double t1 = (double)getTickCount();...double t2 = (double)getTickCount();cout<<"time:"<<(t2-t1)*1000/getTickFrequency()<<endl;
getTickCount()与getTickFrequency()都被定义在core.hpp文件下:
//! Returns the number of ticks./*! The function returns the number of ticks since the certain event (e.g. when the machine was turned on). It can be used to initialize cv::RNG or to measure a function execution time by reading the tick count before and after the function call. The granularity of ticks depends on the hardware and OS used. Use cv::getTickFrequency() to convert ticks to seconds.*/CV_EXPORTS_W int64 getTickCount();/*! Returns the number of ticks per seconds. The function returns the number of ticks (as returned by cv::getTickCount()) per second. The following code computes the execution time in milliseconds: \code double exec_time = (double)getTickCount(); // do something ... exec_time = ((double)getTickCount() - exec_time)*1000./getTickFrequency(); \endcode*/CV_EXPORTS_W double getTickFrequency();/*! Returns the number of CPU ticks. On platforms where the feature is available, the function returns the number of CPU ticks since the certain event (normally, the system power-on moment). Using this function one can accurately measure the execution time of very small code fragments, for which cv::getTickCount() granularity is not enough.*/CV_EXPORTS_W int64 getCPUTickCount();
getTickCount():用于返回从操作系统启动到当前所经的计时周期数,看名字也很好理解,get Tick Count(s)。
getTickFrequency():用于返回CPU的频率。get CPU Tick Count(s)。这里的单位是秒。
所以剩下的就很清晰了:
总次数/一秒内重复的次数 = 时间(s)
总次数*1000/一秒内重复的次数 = 时间(ms)
2 1
- OpenCV 利用getTickCount()与getTickFrequency()计算执行时间
- opencv中的getTickCount和getTickFrequency计算时间
- 【拜小白opencv】4-测量程序运行时间;getTickCount()与getTickFrequency()
- OpenCV计时函数getTickFrequency与cvGetTickFrequency之间的区别
- 利用GetTickCount 函数计算某个过程执行的时间
- 利用IHttpHandler计算页面的执行时间
- 利用IHttpHandler计算页面的执行时间
- 利用IHttpHandler计算页面的执行时间
- 利用IHttpHandler计算页面的执行时间
- 利用IHttpHandler计算页面的执行时间
- 利用IHttpHandler计算页面的执行时间
- 利用IHttpHandler计算页面的执行时间
- double frequency=cv::getTickFrequency(); const int64 start=cv::getTickCount();
- C与Java中计算程序执行时间的方法
- c与java中计算程序执行时间的方法
- C与Java中计算程序执行时间的方法
- GetTickCount
- GetTickCount
- 配置SQL Server的身份验证方式
- Android学习之自定义View详解
- 基于 Django1.10 文档的深入学习(26)—— Creating forms from models 之 基础
- 常用统计指标
- 判断互质的五种方法
- OpenCV 利用getTickCount()与getTickFrequency()计算执行时间
- 【Leetcode 4】Median of Two Sorted Arrays
- Python爬虫学习之常用技巧详解
- 判断用户终端类型(php程序)
- Linux学习之sed的使用
- JSP中文件的上传与下载示例
- LeetCode——17. Letter Combinations of a Phone Number
- Java IO流之打印流与标准流
- lasync命令模块实用工具cmdutils