1. TickMeter是一个计时的类
https://docs.opencv.org/4.x/d9/d6f/classcv_1_1TickMeter.html#details

1.1 计算耗时
TickMeter tm;
tm.start();
tm.stop();
cout << "Total time: " << tm.getTimeSec() << endl;
1.2 计算循环的平均耗时和FPS
TickMeter tm;
for (int i = 0; i < COUNT; i++)
{
tm.start();
tm.stop();
cout << "Last iteration: " << tm.getLastTimeSec() << endl;
}
cout << "Average time per iteration in seconds: " << tm.getAvgTimeSec() << endl;
cout << "Average FPS: " << tm.getFPS() << endl;
1.3 function
index |
function |
1 |
getAvgTimeMilli |
2 |
getAvgTimeSec |
3 |
getCounter |
4 |
getFPS |
5 |
getTimeMicro |
6 |
getTimeMilli |
7 |
getTimeSec |
8 |
getTimeTicks |
9 |
reset |
10 |
start |
11 |
stop |
2. 案例
import time
import cv2
tm = cv2.TickMeter()
index = 0
print(f"|index|function|")
print