def browse_mode(): cartoon_selector = 0 cartoon = [] cartoon_cursor = 1 cartoons_number = selection.count_files("/media/PAP/cartoons/") c_path = "/media/PAP/cartoons/pap_" # if no USB key named PAP containing cartoons is found, displays an error and returns. # This will crash if it contains images that are not names pap_x and are not 1280 / 1024 size. if not os.path.exists("/media/PAP/cartoons/"): cv2.imshow("window", cv2.imread("./load_failed.png")) cv2.waitKey(0) return while (len(cartoon) == 0): cv2.imshow("window", cv2.imread("background2.png")) cv2.waitKey(10) # builds and displays the image containing thumbnails of the cartoons selection.build_selection(cartoon_selector, c_path, cartoons_number) cv2.waitKey(10) button_value = button.waitpressedbutton("browse") if (button_value == "mode"): # the mode is no longer browse, so we return to go to the right mode return if (button_value == "next"): # sets the cursor to the next cartoon cartoon_selector += 1 elif (button_value == "prev"): # sets the cursor to the previous cartoon cartoon_selector -= 1 elif (button_value == "play"): # plays the cartoon cartoon = playing.load_selected(c_path + str(cartoon_selector % cartoons_number + 1) + "/") playing.play(cartoon)
def browse_mode(): cartoon_selector = -1 cartoon = [] cartoon_cursor = 1 cartoons_number = selection.count_files("/media/pi/PAP/cartoons/") c_path = "/media/pi/PAP/cartoons/pap_" # if no USB key named PAP containing cartoons is found, displays an error and returns. # This will crash if it contains images that are not names pap_x and are not 1280 / 1024 size. if not os.path.exists("/media/pi/PAP/cartoons/"): cv2.imshow("window", cv2.imread("./load_failed.png")) cv2.waitKey(0) return while (len(cartoon) == 0): cartoons_number = selection.count_files("/media/pi/PAP/cartoons/") cv2.imshow("window", cv2.imread("background2.png")) cv2.waitKey(10) # builds and displays the image containing thumbnails of the cartoons print (cartoons_number) selection.build_selection(cartoon_selector, c_path, cartoons_number) cv2.waitKey(10) button_value = button.waitpressedbutton("browse") if (button_value == "mode"): # the mode is no longer browse, so we return to go to the right mode return if (button_value == "next"): # sets the cursor to the next cartoon cartoon_selector += 1 elif (button_value == "prev"): # sets the cursor to the previous cartoo cartoon_selector -= 1 elif (button_value == "delete"): if ((cartoon_selector % cartoons_number + 1) == cartoons_number): ani_supp = cv2.imread("ani_supp.png", 1) cv2.imshow("window", ani_supp) cv2.waitKey(10) shutil.rmtree(c_path + str(cartoon_selector % cartoons_number + 1)) elif (button_value == "play"): # plays the cartoon if ((cartoon_selector % cartoons_number + 1) <= 99): num = cv2.imread("/home/pi/Pas_a_pas/img/num/num" + str(cartoon_selector % cartoons_number + 1) + ".png", 1) cv2.imshow("window", num) cv2.waitKey(10) cartoon = playing.load_selected(c_path + str(cartoon_selector % cartoons_number + 1) + "/") cartoon_selector = playing.play_other(cartoon, cartoon_selector)
def load_selected(path): img_list = [] img_number = selection.count_files(path) + 1 path_end = ".png" for i in range(1, img_number): img_list.append(cv2.imread((path + str(i) + path_end), 1)) return img_list
def load_selected(path): img_list = [] img_number = selection.count_files(path) + 1 path_end = ".png" for i in range (1, img_number): img_list.append(cv2.imread((path + str(i) + path_end), 1)) return img_list
def save(cartoon): if (len(cartoon) < 1): return import os # displays the saving message cv2.imshow("window", cv2.imread("saving.png", 1)) cv2.waitKey(10) c_number = selection.count_files("/media/PAP/cartoons/") os.makedirs("/media/PAP/cartoons/pap_" + str(c_number + 1)) for i in range (0, len(cartoon)): cv2.imwrite("/media/PAP/cartoons/pap_" + str(c_number + 1) + "/" + str(i + 1) + ".png", cartoon[i]); # displays the save success message for 5 seconds cv2.imshow("window", cv2.imread("save_success.png", 1)) cv2.waitKey(5000) return
def save(cartoon): if (len(cartoon) < 1): return import os # displays the saving message cv2.imshow("window", cv2.imread("saving.png", 1)) cv2.waitKey(10) c_number = selection.count_files("/media/PAP/cartoons/") os.makedirs("/media/PAP/cartoons/pap_" + str(c_number + 1)) for i in range(0, len(cartoon)): cv2.imwrite( "/media/PAP/cartoons/pap_" + str(c_number + 1) + "/" + str(i + 1) + ".png", cartoon[i]) # displays the save success message for 5 seconds cv2.imshow("window", cv2.imread("save_success.png", 1)) cv2.waitKey(5000) return
def save_other(cartoon): if (len(cartoon) < 1): return import os # displays the saving message cv2.imshow("window", cv2.imread("saving.png", 1)) cv2.waitKey(10) c_number = selection.count_files("/media/pi/PAP/cartoons/") os.makedirs("/home/pi/Pas_a_pas/bla/pap_" + str(c_number + 1)) for i in range (0, len(cartoon)): cv2.imwrite("/home/pi/Pas_a_pas/bla/pap_" + str(c_number + 1) + "/" + str(i + 1) + ".png", cartoon[i]); # displays the save success message for 5 seconds cv2.imshow("window", cv2.imread("img_sauv.png", 1)) cv2.waitKey(5000) if ((c_number + 1) <= 100): cv2.imshow("window", cv2.imread("/home/pi/Pas_a_pas/img/num/num" + str(c_number+1) + ".png", 1)) cv2.waitKey(20) return