OpenCV统计时间

来源:互联网 发布:windows pe 编辑:程序博客网 时间:2024/06/04 01:31
 OpenCV计时

所用函数为getTickCount()和getTickFrequency()。

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

getTickFrequency():返回CPU一秒中所走的时钟周期数。所以可以以秒为单位对某运算时间计时。

使用方法:

    double start = static_cast<double>(getTickCount());
    double time = ((double)getTickCount() - start) / getTickFrequency();
    cout << "所用时间为:" << time << "秒" << endl;

也可用函数cvGetTickCount()和cvGetTickFrequency()。但注意,此时得到的单位是us级的统计时间。

    double start = static_cast<double>(cvGetTickCount());
    double time = ((double)cvGetTickCount() - start) / cvGetTickFrequency();
    cout << "所花费时间为:" << time << "us" << endl;
0 0