# source is set to inbuilt webcam by default. Pass source=1 to use an # external camera. hist = handy.capture_histogram(source=0) while True: ret, frame = cap.read() if not ret: break # to block a faces in the video stream, set block=True. # if you just want to detect the faces, set block=False # if you do not want to do anything with faces, remove this line handy.detect_face(frame, block=True) # detect the hand hand = handy.detect_hand(frame, hist) # to get the outline of the hand # min area of the hand to be detected = 10000 by default custom_outline = hand.draw_outline( min_area=10000000, color=(0, 255, 255), thickness=2) # to get a quick outline of the hand quick_outline = hand.outline # draw fingertips on the outline of the hand, with radius 5 and color red, # filled in. for fingertip in hand.fingertips: cv2.circle(quick_outline, fingertip, 5, (0, 0, 255), -1) # to get the centre of mass of the hand
print("down") pyautogui.press("f2") elif comx + 60 < comxPrev: print("Up") pyautogui.press("f3") def inCenter(x, y): if (y > (185) and y < (315)) and (x > (235) and x < (365)): return True else: return False fire, screen = cap.read() hand = handy.detect_hand(screen, hist) com = hand.get_center_of_mass() resetTime = 0 prevStatey = com[0] prevStatex = com[1] while True: fire, screen = cap.read() if not fire: break # to block a faces in the video stream, set block=True. # if you just want to detect the faces, set block=False # if you do not want to do anything with faces, remove this line handy.detect_face(screen, block=True) # detect the hand