Esempio n. 1
0
    # Print instructions
    print("\nImage capture mode")
    print("Press the following keys to capture:")
    print("Rock gesture: r")
    print("Paper gesture: p")
    print("Scisors gesture: s or c")
    print("Press ESC or q to quit capture mode\n")

    # Main loop
    while not stop:
        # Capture image from camera
        img = cam.getOpenCVImage()

        # Crop image
        img = imp.crop(img)

        # Add framerate to copy of image
        imgFR = imp.fastRotate(img)
        txtPos = (5, imgFR.shape[0] - 10)
        cam.addFrameRateText(imgFR, txtPos, bgr=(0, 0, 255))

        # Display image
        cv2.imshow('Camera', imgFR)

        # Wait for key press
        key = cv2.waitKey(1)
        if key in [27, 113]:
            # Escape or "Q" key pressed; Stop.
            stop = True
        else:
Esempio n. 2
0
        coImgs[utils.ROCK] = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        img = cv2.imread('img/gui/paper.png', cv2.IMREAD_COLOR)
        coImgs[utils.PAPER] = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        img = cv2.imread('img/gui/scissors.png', cv2.IMREAD_COLOR)
        coImgs[utils.SCISSORS] = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

        # Load green image
        greenImg = cv2.imread('img/gui/green.png', cv2.IMREAD_COLOR)
        greenImg = cv2.cvtColor(greenImg, cv2.COLOR_BGR2RGB)

        notify = False

        while True:

            # Get image from camera
            img = imp.crop(cam.getOpenCVImage())

            # Convert image to RGB (from BGR)
            imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

            # Set player image to imgRGB
            gui.setPlImg(imgRGB)

            # Get grayscale image
            gray = imp.getGray(imgRGB, threshold=17)

            # Count non-background pixels
            nonZero = np.count_nonzero(gray)

            # Define waiting time
            waitTime = 0