(img, pTime, pos=(50, 80), color=(0, 255, 0), scale=4, thickness=4)
| 3 | |
| 4 | |
| 5 | def calculate_fps(img, pTime, pos=(50, 80), color=(0, 255, 0), scale=4, thickness=4): |
| 6 | cTime = time.time() |
| 7 | fps = 1 / (cTime - pTime) |
| 8 | pTime = cTime |
| 9 | cv2.putText( |
| 10 | img, |
| 11 | f"FPS: {int(fps)}", |
| 12 | pos, |
| 13 | cv2.FONT_HERSHEY_PLAIN, |
| 14 | scale, |
| 15 | color, |
| 16 | thickness, |
| 17 | ) |
| 18 | return pTime, img |
| 19 | |
| 20 | |
| 21 | def show_video(capture): |