예제 #1
0
        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:
            # calibrating again each time actually seems to work better idk
            #fingers = ax.calibrate(BGR_frame, hull, palmCenter)
            fingers = ax.find_fingers(
                BGR_frame, hull, indices, cnt,
                palmCenter)  #ax.calibrate(BGR_frame, hull, palmCenter)

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

            if len(fingers) < 5:
                axis = ax.axis_2d
            else:
                img_pts = ax.get_img_pts(fingers, palmCenter)
                axis = ax.get_axis_2d(img_pts)

            cv2.fillPoly(BGR_frame,
                         [np.array([axis[1], axis[3], axis[0], axis[6]])],
                         (225, 202, 0))
            cv2.fillPoly(BGR_frame,