ret, BGR_frame = cap.read() BGR_frame = cv2.flip(BGR_frame, 1) #vertical flip # thresholding to find hand if option == 1: BGR_frame = pre.deNoise(BGR_frame) gray_frame = pre.im2Gray(BGR_frame) skinMask = pre.thresholdHand(gray_frame) # skin segmentation to find hand if option == 2: roi = pre.getHandROI(BGR_frame) if roi != None: lower, upper = pre.updateHSV(roi) skinMask = pre.getSkinMask(lower, upper, BGR_frame) BGR_frame = pre.applyMask(skinMask, BGR_frame) # find finger tips and palm cnt, hull = hand.getConvexHull(skinMask) cv2.drawContours(BGR_frame, [hull], 0, (255, 0, 0), 2) palmCenter = hand.centerOfPalm(cnt) cv2.circle(BGR_frame, palmCenter, 5, [0, 0, 255], 2) # Display the resulting frame cv2.imshow('frame', BGR_frame) # Record a video # out.write(frame) if cv2.waitKey(1) & 0xFF == ord('q'): break