Example #1
0
def free_mode():

    takes_list = []

    background = cv2.imread("background2.png", 1)
    cv2.imshow("window", background)
    cv2.waitKey(50)            
    while ("true"):

        mode = GPIO.input(13) # reads the circle switch

        if (mode == False or len(takes_list) < 3):
            cv2.imshow("window", background)
        else:
            cv2.imshow("window", image.averager(takes_list)) # displays a weighed average of the last 3 pictures taken
        cv2.waitKey(100)

        button_value = button.waitpressedbutton("free")

        if (button_value == "mode"):         # The mode is no longer freemode, we have to return to go to the selected mode
            return

        if (button_value == "record"):                        # takes and displays a picture
            cv2.imshow("window", background)
            cv2.waitKey(10)
            takes_list.append(camera.get_image())
            cv2.imshow("window", takes_list[len(takes_list) - 1])
            cv2.waitKey(200)

        if (button_value == "delete" and len(takes_list) > 0): # deletes the last picture taken
            img_supp = cv2.imread("img_supp.png", 1)
            cv2.imshow("window", img_supp)
            cv2.waitKey(10)
            del takes_list[-1]
            cv2.imshow("window", background)
            cv2.waitKey(300)
        if (button_value == "save"):                        # saves the cartoon and returns

            if (len(os.listdir("/media")) >= 2):
                os.system("mount /dev/sdb1 /home/pi/Pas_a_pas/bla")
                playing.save_other(takes_list)
                os.system("umount /home/pi/Pas_a_pas/bla")
            playing.save(takes_list)
            return
        if (button_value == "play"):                        # plays the cartoon
            playing.play(takes_list)
Example #2
0
def free_mode():

    takes_list = []

    background = cv2.imread("background2.png", 1)
    cv2.imshow("window", background)
    cv2.waitKey(50)
    while ("true"):

        mode = GPIO.input(13)  # reads the circle switch

        if (mode == False or len(takes_list) < 3):
            cv2.imshow("window", background)
        else:
            cv2.imshow(
                "window", image.averager(takes_list)
            )  # displays a weighed average of the last 3 pictures taken
        cv2.waitKey(100)

        button_value = button.waitpressedbutton("free")

        if (
                button_value == "mode"
        ):  # The mode is no longer freemode, we have to return to go to the selected mode
            return

        if (button_value == "record"):  # takes and displays a picture
            cv2.imshow("window", background)
            cv2.waitKey(10)
            takes_list.append(camera.get_image())
            cv2.imshow("window", takes_list[len(takes_list) - 1])
            cv2.waitKey(200)

        if (button_value == "delete"
                and len(takes_list) > 0):  # deletes the last picture taken
            del takes_list[-1]
            cv2.imshow("window", background)
            cv2.waitKey(300)
        if (button_value == "save"):  # saves the cartoon and returns
            playing.save(takes_list)
            return
        if (button_value == "play"):  # plays the cartoon
            playing.play(takes_list)
Example #3
0
def assisted_mode():

    # The model is loaded first
    model_list = selection.select_cartoon("/media/PAP/models/", "assisted")
    if model_list == None:
        return

    takes_list = []
    background = cv2.imread("background2.png", 1)
    model_cursor = 0
    takes_cursor = 0

    # When this condition is false, the program saves automatically the cartoon and returns
    while (len(model_list) > len(takes_list)):

        if ((GPIO.input(6) == False) or (len(takes_list) == 0)):
            cv2.imshow("window", model_list[model_cursor % len(model_list)])
            cv2.waitKey(100)
        else:
            cv2.imshow("window", takes_list[takes_cursor % len(takes_list)])
            cv2.waitKey(100)

        # I move the window again because of a window issue, that still occurs the first time model_cursor = 1
        cv2.moveWindow("window", 0, -30)

        button_value = button.waitpressedbutton("assisted")
        if (button_value == "mode"):
            return

        if (button_value == "record"):  # take the picture
            model_cursor += 1
            cv2.imshow("window", background)
            cv2.waitKey(20)
            takes_list.append(camera.get_image())

        if (button_value == "delete" and len(takes_list) >
                0):  # delete the last picture from takes_list
            del (takes_list[-1])
            cv2.waitKey(300)

        if (button_value == "save"):  # save the cartoon and returns
            if not os.path.exists("/media/PAP/cartoons"):
                cv2.imshow("window", cv2.imread("./save_failed"))
                cv2.waitKey(100)
            else:
                playing.save(takes_list)
                return

        if (button_value == "play"):  # plays the cartoon
            playing.play(takes_list)
        if (button_value == "next"):  # move to next image
            if (GPIO.input(6) == False):
                model_cursor += 1
            else:
                takes_cursor += 1
            cv2.waitKey(100)

        if (button_value == "prev"):  # move to previous image
            if (GPIO.input(6) == False):
                model_cursor -= 1
            else:
                takes_cursor -= 1
            cv2.waitKey(100)

    # end of while loop, save and return
    if not os.path.exists("/media/PAP/cartoons"):
        cv2.imshow("window", cv2.imread("./save_failed"))
        cv2.waitKey(100)
    else:
        playing.save(takes_list)
        return
Example #4
0
def assisted_mode():

    # The model is loaded first
    model_list = selection.select_cartoon("/media/PAP/models/", "assisted")
    if model_list == None:
        return

    takes_list = []
    background = cv2.imread("background2.png", 1)
    model_cursor = 0
    takes_cursor = 0

    # When this condition is false, the program saves automatically the cartoon and returns
    while len(model_list) > len(takes_list):

        if (GPIO.input(6) == False) or (len(takes_list) == 0):
            cv2.imshow("window", model_list[model_cursor % len(model_list)])
            cv2.waitKey(100)
        else:
            cv2.imshow("window", takes_list[takes_cursor % len(takes_list)])
            cv2.waitKey(100)

        # I move the window again because of a window issue, that still occurs the first time model_cursor = 1
        cv2.moveWindow("window", 0, -30)

        button_value = button.waitpressedbutton("assisted")
        if button_value == "mode":
            return

        if button_value == "record":  # take the picture
            model_cursor += 1
            cv2.imshow("window", background)
            cv2.waitKey(20)
            takes_list.append(camera.get_image())

        if button_value == "delete" and len(takes_list) > 0:  # delete the last picture from takes_list
            del (takes_list[-1])
            cv2.waitKey(300)

        if button_value == "save":  # save the cartoon and returns
            if not os.path.exists("/media/PAP/cartoons"):
                cv2.imshow("window", cv2.imread("./save_failed"))
                cv2.waitKey(100)
            else:
                playing.save(takes_list)
                return

        if button_value == "play":  # plays the cartoon
            playing.play(takes_list)
        if button_value == "next":  # move to next image
            if GPIO.input(6) == False:
                model_cursor += 1
            else:
                takes_cursor += 1
            cv2.waitKey(100)

        if button_value == "prev":  # move to previous image
            if GPIO.input(6) == False:
                model_cursor -= 1
            else:
                takes_cursor -= 1
            cv2.waitKey(100)

    # end of while loop, save and return
    if not os.path.exists("/media/PAP/cartoons"):
        cv2.imshow("window", cv2.imread("./save_failed"))
        cv2.waitKey(100)
    else:
        playing.save(takes_list)
        return