opencv笔记(三十五)——测试一帧图像的处理时间

timeGetTime()函数

函数以 毫秒 计的系统时间。该时间为从系统开启算起所经过的时间
在SDK中,可以用 DWORD timeGetTime(VOID)函数获取系统时间,其返回值是毫秒单位的。可以用其实现延时功能的函数。

 void Delay(DWORD delayTime)
    {
        DWORD delayTimeBegin;
        DWORD delayTimeEnd;
        delayTimeBegin = timeGetTime();
        do{delayTimeEnd = timeGetTime();}
        while(delayTimeEnd - delayTimeBegin < delayTime)
    }

注:在使用timeGetTime()函数之前应

1)先包含头文件#include <Mmsystem.h>#include <Windows.h>

并在project->settings->link->Object/library modules中添加winmm.lib(可不做)
2)也可以在文件头部添加 #pragma comment( lib,"winmm.lib" )

解释:
命令行:#pragma comment( lib,"xxx.lib" )时预编译处理指令,让vc将winmm.lib添加到工程中去进行编译。

备注:

  • 该函数与timeGetSystemTime()函数的唯一不同是timeGetSystemTime()函数使用MMTIME结构返回系统时间。TimeGetSystemTime()比timeGetTime()需要更多的系统开销。注意timeGetTime()函数是一个双字。这个值在0到2^32之间。大约49.71天。如果在代码中直接将该值用于计算,会导致一些问题,特别是用该值来控制代码的执行。一般利用两个timeGetTime()函数返回值的不同来用于计算。
  • Windows NT:该函数的时间精度是五毫秒或更大一些,这取决于机器的性能。
  • 可用timeBeginPeriod和timeEndPeriod函数提高timeGetTime函数的精度。如果使用了,连续调用timeGetTime函数,一系列返回值的差异由timeBeginPeriod和timeEndPeriod决定。
  • QueryPerformanceCounter QueryPerformanceFrequency函数用于分辨率要求更高的时间测量。
  • Windows95 默认分辨率是1毫秒,无论是否调用timeBeginPeriod和timeEndPeriod函数。

参考文章:

timeGetTime()函数的用法 https://blog.csdn.net/hbtj_1216/article/details/50503284

cv::getTickCount()与GetTickCount()的区别 https://blog.csdn.net/flyyufenfei/article/details/79207842

猜你喜欢

转载自blog.csdn.net/qq_37764129/article/details/84943468