opencv timer
时间: 2023-12-14 16:34:41 浏览: 132
以下是使用OpenCV计时器的示例代码:
```cpp
#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
TickMeter tm;
tm.start();
// 待测试的代码
// ...
tm.stop();
printf("Time elapsed: %fms\n", tm.getTimeMilli());
return 0;
}
```
另外,你也可以使用C++11的chrono库来计时:
```cpp
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
auto start = std::chrono::high_resolution_clock::now();
// 待测试的代码
// ...
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start;
std::cout << "Time elapsed: " << elapsed.count() << "ms\n";
return 0;
}
```
阅读全文