()
| 104 | |
| 105 | |
| 106 | def main(): |
| 107 | pTime = 0 |
| 108 | cTime = 0 |
| 109 | cap = cv2.VideoCapture(0) |
| 110 | detector = HandDetector() |
| 111 | while True: |
| 112 | success, img = cap.read() |
| 113 | img = detector.findHands(img) |
| 114 | lmList, bbox = detector.findPosition(img) |
| 115 | if len(lmList) != 0: |
| 116 | print(lmList[4]) |
| 117 | |
| 118 | cTime = time.time() |
| 119 | fps = 1 / (cTime - pTime) |
| 120 | pTime = cTime |
| 121 | |
| 122 | cv2.putText( |
| 123 | img, str(int(fps)), (10, 70), cv2.FONT_HERSHEY_PLAIN, 3, (255, 0, 255), 3 |
| 124 | ) |
| 125 | |
| 126 | cv2.imshow("Image", img) |
| 127 | if cv2.waitKey(1) & 0xFF == ord("q"): |
| 128 | break |
| 129 | |
| 130 | cap.release() |
| 131 | cv2.destroyAllWindows() |
| 132 | |
| 133 | |
| 134 | if __name__ == "__main__": |
no test coverage detected