def loadProcessedImage(frame): # tell users to make google vision call or place an item based on the satus of the image global app renderingUtil.refresh(app.frames[frame].instruction) try: tryOpen = Image.open(workingDir + objectImg) app.frames[frame].instruction = tk.Label( app.frames[frame], text="Your item is ready to be scanned", font=('helvetica', 15)) except OSError: print('cannot open') app.frames[frame].instruction = tk.Label( app.frames[frame], text="Please place an item in front of the camera", font=('helvetica', 15)) app.frames[frame].instruction.pack() # update the image when a new image is generated and cropped renderingUtil.refresh(app.frames[frame].promptLabel) readImg = renderingUtil.resizeImage(objectImg) app.frames[frame].img = ImageTk.PhotoImage(readImg) app.frames[frame].promptLabel = tk.Label(app.frames[frame], image=app.frames[frame].img) app.frames[frame].promptLabel.pack()
def __init__(self, controller, parent, message, scanFunction, *args, **kwargs): self.infoButtonList = [] self.counter = 0 self.itemList = [None]*20 #20 items max self.ingredientsList = [None]*20 self.subcanvas = tk.Canvas() readImg = renderingUtil.resizeImage("/images/Capture.jpg") self.img = ImageTk.PhotoImage(readImg) self.alert = tk.Label() # buttons to check ingredients, go back to home page and instructions labels for the users label = tk.Label(self, text=message) label.config(font=('helvetica', 30)) label.pack(padx=10, pady=10) scan_items = tk.Button(self, text="Check Ingredients", height = 2, font=('helvetica', 15), command=lambda: scanFunction("customer1")) scan_items.pack() start_page = tk.Button(self, text="Back to Home Page", height = 2, font=('helvetica', 15), command=lambda: self.backToHomePage(controller)) start_page.pack() self.instruction = tk.Label(self, text="Place item inside box with ingredients list facing camera", font=('helvetica', 15)) self.instruction.pack() self.promptLabel = tk.Label(self, image=self.img) self.promptLabel.pack()
def test_resize_image(self): for filename in os.listdir(workingDir + "/images"): img = dut.resizeImage("/images/" + filename) imgplot = plt.imshow(img) plt.show() # test if the image is smaller than expected size assert img.width < 500 and img.height < 500 img.close()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) # welcome labels, buttons to navigate to different pages of the app label = tk.Label(self, text="You have successfully loged in") label.config(font=('helvetica', 30)) label.pack(padx=10, pady=10) regular_page = tk.Button( self, text="Regular Items", height=2, font=('helvetica', 15), command=lambda: controller.show_frame(RegularItems)) regular_page.pack() custom_page = tk.Button( self, text="Custom Items", height=2, font=('helvetica', 15), command=lambda: controller.show_frame(CustomItems)) custom_page.pack() user_list = tk.Button( self, text="View personalized list", height=2, font=('helvetica', 15), command=lambda: self.show_plist(LandingPage, controller)) user_list.pack() login_page = tk.Button( self, text="Log out", height=2, font=('helvetica', 15), command=lambda: controller.show_frame(LoginPage)) login_page.pack() self.user_list = tk.Label() # welcome image of a cute cat readImg = renderingUtil.resizeImage("/images/cat.gif") self.img = ImageTk.PhotoImage(readImg) welcomeImg = tk.Label(self, image=self.img) welcomeImg.pack()