예제 #1
0
    # find finger tips and palm
    cnt, hull, indices = 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('c'):

        cv2.imwrite("calibration.jpg", BGR_frame)
        print "Calibrating"
        fingers = ax.calibrate(BGR_frame, hull, indices, cnt, palmCenter)

        for finger in fingers:
            cv2.circle(BGR_frame, finger, 5, [0, 0, 255], 2)

        img_pts = ax.get_img_pts(fingers, palmCenter)
        axis = ax.get_axis_2d(img_pts)
        cv2.line(BGR_frame, axis[3], axis[0], (255, 0, 0), 5)
        cv2.line(BGR_frame, axis[3], axis[1], (0, 255, 0), 5)
        cv2.line(BGR_frame, axis[3], axis[2], (0, 0, 255), 5)
        cv2.imshow('frame', BGR_frame)
        curr_time = time.time()

    else:

        if ax.calibrated: