opencv —— getTickCount、getTickFrequency 计时函数

getTickCount 函数

返回 CPU 自某个事件(如启动电脑)以来走过的时钟周期数。

getTickFrequency 函数

返回 CPU 一秒钟所走过的时钟周期数。

 

代码演示:

#include<opencv.hpp>
using namespace cv;
int main() {
    Mat src = imread("C:/Users/齐明洋/Desktop/1.jpg");
    Mat gray;
    double time_start = static_cast<double>(getTickCount());
    cvtColor(src, gray, COLOR_BGR2GRAY);
    double time_end = static_cast<double>(getTickCount());
    double cost_time = (time_end - time_start) / getTickFrequency();
    printf("%lf s", cost_time);
    imshow("gray", gray);
    waitKey(0);
}

猜你喜欢

转载自www.cnblogs.com/bjxqmy/p/12291425.html
今日推荐