from PIL import Image
# import cv2 as cv
# import os

# CODE Move arm to starting position
# Ask for the user's color preference, if input not on list repeat until user selects option


def get_choice():
    options = ["RED", "BLUE", "GREEN"]
    print("Hi, Baxter will remove any unwanted color block")
    print("Options are RED, GREEN and BLUE")
    while True:
        choice1 = input("Which color would you like to keep?\n")
        selection = choice1.upper()  # Make input uppercase
        if selection in options:
            return selection
        else:
            print(selection,"is not an option. Please try again")


choice = get_choice()
print("You have chosen",choice)
# CODE Move Baxter Arm X distance to the right


img = Image.open(filename)
color = img.getpixel((320, 240))  # Get the RGB values at coordinate x = 320, y = 240.
red = (227, 0, 0)
green = (0, 227, 0)
blue = (0, 0, 227)

# Determine action from colors

if choice == "RED" and color == red:
    print("RedCorrect")
        # CODE Baxter will X distance to the right for next block
elif choice == "BLUE" and color == blue:
    print("BlueCorrect")
        # CODE Baxter will X distance to the right for next block
elif choice == "GREEN" and color == green:
    print("BlueCorrect")
        # CODE Baxter will X distance to the right for next block
else:
    print("Not", choice)
        # Baxter arm perform pick and place exercise
