MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / main

Function main

computer-vision/hand_tracking.py:106–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104
105
106def 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
134if __name__ == "__main__":

Callers 1

hand_tracking.pyFile · 0.70

Calls 3

findHandsMethod · 0.95
findPositionMethod · 0.95
HandDetectorClass · 0.85

Tested by

no test coverage detected