(capture)
| 19 | |
| 20 | |
| 21 | def show_video(capture): |
| 22 | # cap = cv2.VideoCapture(0) # Capture from camera. Adjust the number |
| 23 | cap = cv2.VideoCapture(capture) # Capture from video |
| 24 | |
| 25 | try: |
| 26 | |
| 27 | pTime = time.time() |
| 28 | while cap.isOpened(): |
| 29 | # Read from video capture device |
| 30 | success, img = cap.read() |
| 31 | |
| 32 | # FPS |
| 33 | pTime, img = calculate_fps(img, pTime) |
| 34 | |
| 35 | # Show video |
| 36 | if img is not None: |
| 37 | cv2.imshow("Video", img) |
| 38 | |
| 39 | # Wait for key to exit |
| 40 | if cv2.waitKey(10) & 0xFF == ord("q"): |
| 41 | break |
| 42 | finally: |
| 43 | cap.release() |
| 44 | cv2.destroyAllWindows() |
| 45 | |
| 46 | |
| 47 | if __name__ == "__main__": |
no test coverage detected