def dropCar(): toRemove = vedereCopac.tag_has('checked') if len(toRemove) == 0: labelWarningSelect.config(text="Selectati un username!") else: for masina_ID in toRemove: mydb.removeCar(masina_ID) vedereCopac.delete(*vedereCopac.get_children()) masiniDinBaza = mydb.listareToateMasini() for masina in masiniDinBaza: vedereCopac.insert("", "end", masina[0], values=(masina[1], masina[2], masina[3], masina[4])) controller.show_frame(cSucces.SuccesFrame) obj = cLPRDataBase.myDataBase() answer = obj.removeCar(entryNume.get()) if answer is -1: entryNume.config(highlightbackground="red", highlightthickness=1) labelWarningNume.config( text="Masina nu exista in baza de date", fg="red") else: entryNume.config(highlightthickness=0) entryNume.delete(0, END) labelWarningNume.config(text="") controller.show_frame(cSucces.SuccesFrame)
def addUser(): mydb = cLPRDataBase.myDataBase() if entryNume.get() == "": entryNume.config(highlightbackground="red", highlightthickness=1) labelUserWarning.config(text="Introduceti un username!") if entryPass.get() == "": entryPass.config(highlightbackground="red", highlightthickness=1) labelPassWarning.config(text="Introduceti o parola!") if reEntryPass.get() == "": reEntryPass.config(highlightbackground="red", highlightthickness=1) labelRePassWarning.config(text="Reintroduceti parola!") else: if mydb.checkUserExists(entryNume.get()): entryNume.config(highlightbackground="red", highlightthickness=1) labelUserWarning.config(text="Acest nume exista deja!", fg="red") else: if entryPass.get() == "": entryPass.config(highlightbackground="red", highlightthickness=1) labelPassWarning.config(text="Introduceti o parola!") if reEntryPass.get() == "": reEntryPass.config(highlightbackground="red", highlightthickness=1) labelRePassWarning.config( text="Reintroduceti parola!", fg="red") else: if reEntryPass.get() == "": reEntryPass.config(highlightbackground="red", highlightthickness=1) labelRePassWarning.config( text="Trebuie sa reintroduceti parola!", fg="red") else: if entryPass.get() != reEntryPass.get(): entryPass.config(highlightbackground="red", highlightthickness=1) reEntryPass.config(highlightbackground="red", highlightthickness=1) labelRePassWarning.config( text="Parolele trebuie sa fie identice!", fg="red") else: mydb.addUser(entryNume.get(), entryPass.get()) entryPass.config(highlightthickness=0) entryNume.config(highlightthickness=0) reEntryPass.config(highlightthickness=0) entryPass.delete(0, END) entryNume.delete(0, END) reEntryPass.delete(0, END) labelUserWarning.config(text="") labelPassWarning.config(text="") labelRePassWarning.config(text="") controller.show_frame(cSucces.SuccesFrame)
def refreshTable(): vedereCopac.delete(*vedereCopac.get_children()) mydb = cLPRDataBase.myDataBase() masiniDinBaza = mydb.listareToateMasini() for masina in masiniDinBaza: vedereCopac.insert("", "end", masina[0], values=(masina[1], masina[2], masina[3], masina[4]))
def filterAdmin(usernameEntry): if usernameEntry == "": entryNume.config(highlightbackground="red", highlightthickness=1) labelWarningNume.config(text="Introduceti un username!") else: mydb = cLPRDataBase.myDataBase() answer = mydb.listareAdminiLevenshtein(usernameEntry) vedereCopac.delete(*vedereCopac.get_children()) for row in answer: vedereCopac.insert("", "end", row[0], values=(row[1]))
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) def dropCar(): toRemove = vedereCopac.tag_has('checked') if len(toRemove) == 0: labelWarningSelect.config(text="Selectati un username!") else: for masina_ID in toRemove: mydb.removeCar(masina_ID) vedereCopac.delete(*vedereCopac.get_children()) masiniDinBaza = mydb.listareToateMasini() for masina in masiniDinBaza: vedereCopac.insert("", "end", masina[0], values=(masina[1], masina[2], masina[3], masina[4])) controller.show_frame(cSucces.SuccesFrame) obj = cLPRDataBase.myDataBase() answer = obj.removeCar(entryNume.get()) if answer is -1: entryNume.config(highlightbackground="red", highlightthickness=1) labelWarningNume.config( text="Masina nu exista in baza de date", fg="red") else: entryNume.config(highlightthickness=0) entryNume.delete(0, END) labelWarningNume.config(text="") controller.show_frame(cSucces.SuccesFrame) def goBack(): entryNume.config(highlightthickness=0) entryNume.delete(0, END) labelWarningNume.config(text="") controller.show_frame(cAdminMenu.AdminFrame) def refreshTable(): vedereCopac.delete(*vedereCopac.get_children()) mydb = cLPRDataBase.myDataBase() masiniDinBaza = mydb.listareToateMasini() for masina in masiniDinBaza: vedereCopac.insert("", "end", masina[0], values=(masina[1], masina[2], masina[3], masina[4])) def filterCar(usernameEntry): if usernameEntry == "": entryNume.config(highlightbackground="red", highlightthickness=1) labelWarningNume.config(text="Introduceti un username!") else: mydb = cLPRDataBase.myDataBase() answer = mydb.listareMasiniLevenshtein(entryNume.get()) vedereCopac.delete(*vedereCopac.get_children()) for row in answer: vedereCopac.insert("", "end", row[0], values=(row[1], row[2], row[3], row[4])) backgroundImage = PhotoImage(file="GUIPhotos/065.png") label = ttk.Label(self, image=backgroundImage) label.pack(fill=BOTH, expand=YES) label.image = backgroundImage # username userImage = PhotoImage(file="GUIPhotos/068.png") labelNume = Label(label, image=userImage) labelNume.place(x=45, y=73, width='250', height='40') labelNume.image = userImage entryNume = Entry(label) entryNume.place(x=40, y=120, width=250, height=24) labelWarningNume = Label(self, text="", font="TimesNewRoman 10 bold", fg="red") labelWarningNume.place(x=40, y=144) # buton cautare dupa nume butonCautareImage = PhotoImage(file="GUIPhotos/066.png") butonCautare = Button(self, image=butonCautareImage, relief=RIDGE, command=lambda: filterCar(entryNume.get())) butonCautare.place(x=340, y=120, width='120', height='24') butonCautare.image = butonCautareImage #buton refresh butonRefreshImage = PhotoImage(file="GUIPhotos/067.png") butonRefresh = Button(self, image=butonRefreshImage, relief=RIDGE, command=lambda: refreshTable()) butonRefresh.place(x=20, y=210, height=30, width=460) butonRefresh.image = butonRefreshImage #Vedere copac scrollbar = Scrollbar(self) scrollbar.pack(side=RIGHT, fill=Y, pady=(250, 150)) scrollbar.place(x=480, y=250, height=200) vedereCopac = cMasinaTreeView.CheckboxTreeview( self, columns=("nume", "prenume", "functie", "numar"), yscrollcommand=scrollbar.set) scrollbar.config(command=vedereCopac.yview) vedereCopac.place(x=20, y=250, height=200, width=460) mydb = cLPRDataBase.myDataBase() masiniDinBaza = mydb.listareToateMasini() for masina in masiniDinBaza: vedereCopac.insert("", "end", masina[0], values=(masina[1], masina[2], masina[3], masina[4])) # label warning select labelWarningSelect = Label(self, text="", fg="red", font="TimesNewRoman 10 bold") labelWarningSelect.place(x=20, y=450) #buton sterge buttonImage = PhotoImage(file="GUIPhotos/047.png") logButton = Button(label, image=buttonImage, relief=RIDGE, command=lambda: dropCar()) logButton.place(y=480, x=117, width="266", height='35') logButton.image = buttonImage # buton back buttonImage = PhotoImage(file="GUIPhotos/036.png") logButton = Button(label, image=buttonImage, relief=RIDGE, command=lambda: goBack()) logButton.place(y=530, x=117, width="266", height='35') logButton.image = buttonImage
def __init__(self, parent, controller, settingsVal, securityVal): '''Ar trebui mutata pe butonul de selectare tip de algoritm''' x, y_true, y_pred_cls, session = ConvolutionalIndividual.buildGraph() #create DB Object mydb = cLPRDataBase.myDataBase() def labelImageResize(LastRecognized): newWidth = 200 newHeight = int( (newWidth / LastRecognized.size[0]) * LastRecognized.size[1]) resizedLastRecognized = LastRecognized.resize( (newWidth, newHeight)) LastRecognizedTk = ImageTk.PhotoImage(resizedLastRecognized) return LastRecognizedTk def veziInfo(): controller.frames[cVeziInfo.VeziInfo].externCall() controller.show_frame(cVeziInfo.VeziInfo) def resize_image(event): new_width = event.width new_height = event.height image = copy_of_image.resize((new_width, new_height)) photo = ImageTk.PhotoImage(image) label.config(image=photo) label.image = photo # avoid garbage collection LastNumber.place(y=new_height * 0.27 + 200) tk.Frame.__init__(self, parent) image = Image.open('GUIPhotos/026.png') copy_of_image = image.copy() photo = ImageTk.PhotoImage(image) label = ttk.Label(self, image=photo) label.bind('<Configure>', resize_image) label.pack(fill=BOTH, expand=YES) def getCameraImage(): '''generarea de imagini se face atata timp cat utilizatorul lasa sa ruleze un anumit algoritm. Cand acesta apa pe opreste recunoastere, nu va mai rula threadul, deci nu se vor mai genera imagini, iar daca nu se vor mai genera imagini, nu va mai rula nici functia de recunoastere, ea bazandu-se pe un for pe imaginile generate de aceasta functie.''' picNum = -1 t = threading.currentThread() while getattr(t, "run", True): dirName = "PozeCamera/" picNum = (picNum + 1) % NUM_PHOTOS yield dirName + "car" + str(picNum) + ".jpg" def cnnIndividualCall(imagePath): numberPlate = ConvolutionalIndividual.predictConvolutionalIndividual( imagePath, session, x, y_true, y_pred_cls) return numberPlate def cnnIntregCall(imagePath): numberPlate = detect.myDetect(controller.assign_ops, controller.x, controller.y, imagePath) return numberPlate def plateLastProcess(plateNum): # daca numarul e de bucuresti nu merge sa iau al 3 -lea caracter . de aceea fac procesarea # incepand cu finalul tupleCifre = ['0', '1', '2'] tupleLitere = ['O', 'I', 'Z'] lungime = len(plateNum) digitsPlace = lungime - 5 digitsPlace = [digitsPlace, digitsPlace + 1] listPlate = list(plateNum) for i in range(0, lungime): if i in digitsPlace: if plateNum[i] in tupleLitere: indexCif = tupleLitere.index(plateNum[i]) listPlate[i] = tupleCifre[indexCif] else: if plateNum[i] in tupleCifre: indexLit = tupleCifre.index(plateNum[i]) listPlate[i] = tupleLitere[indexLit] plateNum = "".join(listPlate) return plateNum def threadFunctionButonPornire(): securitySw = { 0: mydb.levenshteinSecuritateMica, 1: mydb.levenshteinSecuritateMedie, 2: mydb.securitateRidicata } switch = { 0: prediction.mainSVCfunc, 1: cnnIndividualCall, 2: cnnIntregCall } f = open('rezultateSVM', 'a') for picturePath in getCameraImage(): licensePlateNum = switch[controller.algorithmVal](picturePath) LastRecognizedImage = Image.open(picturePath) LastRecognizedImageTk = labelImageResize(LastRecognizedImage) if licensePlateNum == '': licensePlateNum = 'Niciun numar' labelStare.config(text="Nu a fost detectata o masina") else: licensePlateNum = plateLastProcess(licensePlateNum) placutaDinBaza = securitySw[controller.securityVal]( licensePlateNum) if placutaDinBaza is not "False": mydb.adaugaIntrareInBaza(placutaDinBaza) labelStare.config(text="Deschidere bariera!") print("Deschid bariera!") else: labelStare.config( text="Vehicul neidentificat la poarta") ###delete #### f.write(licensePlateNum) f.write("\n") ###delete #### LastNumber.config(text=licensePlateNum) labelImagineNumar.config(image=LastRecognizedImageTk) labelImagineNumar.image = LastRecognizedImageTk # sleep(1) print("Exiting thread...") def incepeRecunoastere(): imageOpresteRecunoastere = PhotoImage(file="GUIPhotos/032.png") butonDeschideBariera.config(image=imageOpresteRecunoastere) butonDeschideBariera.image = imageOpresteRecunoastere butonDeschideBariera.config( command=lambda: opresteRecunoastere(thread)) thread = Thread(target=threadFunctionButonPornire) thread.start() def opresteRecunoastere(thread): imageOpresteRecunoastere = PhotoImage(file="GUIPhotos/033.png") butonDeschideBariera.config(image=imageOpresteRecunoastere) butonDeschideBariera.image = imageOpresteRecunoastere thread.run = False butonDeschideBariera.config(command=lambda: incepeRecunoastere()) #buton deschidere bariera imageDeschide = PhotoImage(file="GUIPhotos/033.png") butonDeschideBariera = tk.Button(self, relief=RIDGE, image=imageDeschide, cursor="hand2", compound=CENTER, anchor=CENTER, command=lambda: incepeRecunoastere()) butonDeschideBariera.place(relx=0.1, rely=0.27, height=30, width=266) butonDeschideBariera.image = imageDeschide #buton vezi informatii imageInfo = PhotoImage(file="GUIPhotos/034.png") butonVeziInformatii = tk.Button(self, relief=RIDGE, image=imageInfo, anchor=CENTER, compound=CENTER, cursor="hand2", command=lambda: veziInfo()) butonVeziInformatii.place(relx=0.1, rely=0.47, height=30, width=266) butonVeziInformatii.image = imageInfo #label cu stare curenta labelStare = tk.Label(self, text="LPR functioneaza normal", anchor=CENTER, bg="white") labelStare.place(relx=0.1, rely=0.66, height=30, width=266) #Afisarea ultimului numar recunoscut LastRecognized = Image.open("GUIPhotos/010.png") LastRecognizedTk = labelImageResize(LastRecognized) labelImagineNumar = tk.Label(self, image=LastRecognizedTk, bg="white") labelImagineNumar.place(relx=0.7, rely=0.27, width=200, height=200) labelImagineNumar.image = LastRecognizedTk LastNumber = tk.Label(self, text="BT 83 KNQ", relief=FLAT, font=fonts.TIMES_NEW_ROMAN) LastNumber.place(relx=0.7, width=200, height=20)
def refreshTable(): vedereCopac.delete(*vedereCopac.get_children()) mydb = cLPRDataBase.myDataBase() adminiDinBaza = mydb.listareTotiAdmini() for admin in adminiDinBaza: vedereCopac.insert("", "end", admin[0], values=(admin[1]))
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) def dropAdmin(): toRemove = vedereCopac.tag_has('checked') if len(toRemove) == 0: labelWarningSelect.config(text="Selectati un username!") else: for admin_ID in toRemove: mydb.removeUser(admin_ID) vedereCopac.delete(*vedereCopac.get_children()) adminiDinBaza = mydb.listareTotiAdmini() for admin in adminiDinBaza: vedereCopac.insert("", "end", admin[0], values=(admin[1])) controller.show_frame(cSucces.SuccesFrame) def filterAdmin(usernameEntry): if usernameEntry == "": entryNume.config(highlightbackground="red", highlightthickness=1) labelWarningNume.config(text="Introduceti un username!") else: mydb = cLPRDataBase.myDataBase() answer = mydb.listareAdminiLevenshtein(usernameEntry) vedereCopac.delete(*vedereCopac.get_children()) for row in answer: vedereCopac.insert("", "end", row[0], values=(row[1])) def refreshTable(): vedereCopac.delete(*vedereCopac.get_children()) mydb = cLPRDataBase.myDataBase() adminiDinBaza = mydb.listareTotiAdmini() for admin in adminiDinBaza: vedereCopac.insert("", "end", admin[0], values=(admin[1])) def goBack(): entryNume.config(highlightthickness=0) labelWarningNume.config(text="") labelWarningSelect.config(text="") entryNume.delete(0, END) controller.show_frame(cAdminMenu.AdminFrame) backgroundImage = PhotoImage(file="GUIPhotos/062.png") label = ttk.Label(self, image=backgroundImage) label.place(x=0, y=0, relwidth=1, relheigh=1) label.image = backgroundImage # username userImage = PhotoImage(file="GUIPhotos/052.png") labelNume = Label(label, image=userImage) labelNume.place(x=80, y=70, width='250', height='40') labelNume.image = userImage entryNume = Entry(label) entryNume.place(x=40, y=120, width=250, height=24) labelWarningNume = Label(self, text="", font="TimesNewRoman 10 bold", fg="red") labelWarningNume.place(x=40, y=144) #buton cautare dupa nume butonCautareImage = PhotoImage(file="GUIPhotos/066.png") butonCautare = Button(self, image=butonCautareImage, relief=RIDGE, command=lambda: filterAdmin(entryNume.get())) butonCautare.place(x=340, y=120, width='120', height='24') butonCautare.image = butonCautareImage #buton refresh table butonRefreshImage = PhotoImage(file="GUIPhotos/067.png") butonRefresh = Button(self, image=butonRefreshImage, relief=RIDGE, command=lambda: refreshTable()) butonRefresh.place(x=20, y=210, height=30, width=460) butonRefresh.image = butonRefreshImage #TreeView scrollbar = Scrollbar(self) scrollbar.pack(side=RIGHT, fill=Y, pady=(250, 150)) scrollbar.place(x=480, y=250, height=200) vedereCopac = cButtonTreeView.CheckboxTreeview( self, columns=("username", ), yscrollcommand=scrollbar.set) scrollbar.config(command=vedereCopac.yview) vedereCopac.place(x=20, y=250, height=200, width=460) mydb = cLPRDataBase.myDataBase() adminiDinBaza = mydb.listareTotiAdmini() for admin in adminiDinBaza: vedereCopac.insert("", "end", admin[0], values=(admin[1])) #label warning labelWarningSelect = Label(self, text="", fg="red", font="TimesNewRoman 10 bold") labelWarningSelect.place(x=20, y=450) #buton sterge buttonImage = PhotoImage(file="GUIPhotos/047.png") logButton = Button(label, image=buttonImage, relief=RIDGE, command=lambda: dropAdmin()) logButton.place(y=480, x=117, width="266", height='35') logButton.image = buttonImage # buton inapoi buttonImage = PhotoImage(file="GUIPhotos/036.png") logButton = Button(label, image=buttonImage, relief=RIDGE, command=lambda: goBack()) logButton.place(y=530, x=117, width="266", height='35') logButton.image = buttonImage
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) mydb = cLPRDataBase.myDataBase() def verificaDate(): if entryNume.get() == "": if entryPass.get() == "": entryPass.config(highlightbackground="red", highlightthickness=1) entryNume.config(highlightbackground="red", highlightthickness=1) labelWarningUser.config(text="Trebuie sa intorduceti un nume!", fg="red", font="TimesNewRoman 10 bold") labelWarningPass.config( text="Trebuie sa introduceti o parola!", fg="red", font="TimesNewRoman 10 bold") else: entryNume.config(highlightthickness=0) labelWarningUser.config(text="") if entryPass.get() == "": entryPass.config(highlightbackground="red", highlightthickness=1) labelWarningPass.config( text="Trebuie sa introduceti o parola!", fg="red", font="TimesNewRoman 10 bold") else: labelWarningUser.config(text="") labelWarningPass.config(text="") if mydb.loginUser(entryNume.get(), entryPass.get()): controller.show_frame(cAdminMenu.AdminFrame) entryPass.config(highlightbackground="red", highlightthickness=1) entryNume.config(highlightbackground="red", highlightthickness=1) labelWarning = tk.Label( self, text="Username sau parola gresite!", font="TimesNewRoman 10 bold", fg="red") labelWarning.place(relx=0.5, rely=0.65, anchor=CENTER) backgorundImage = PhotoImage(file="GUIPhotos/056.png") label = ttk.Label(self, image=backgorundImage) label.place(x=0, y=0) label.image = backgorundImage # username userImage = PhotoImage(file="GUIPhotos/055.png") labelNume = Label(label, image=userImage) labelNume.place(relx=0.3, rely=0.4, anchor=CENTER, width=250, height=40) labelNume.image = userImage entryNume = Entry(label) entryNume.place(relx=0.75, rely=0.4, anchor=CENTER, relwidth="0.4", relheight='0.04') labelWarningUser = tk.Label(label, text="") labelWarningUser.place(relx=0.55, rely=0.425, anchor=NW) # password passwordImage = PhotoImage(file="GUIPhotos/053.png") labelPass = Label(label, image=passwordImage) labelPass.place(relx=0.3, rely=0.52, anchor=CENTER, width=250, height=40) labelPass.image = passwordImage entryPass = Entry(label, show="*") entryPass.place(relx=0.75, rely=0.52, anchor=CENTER, relwidth="0.4", relheight='0.04') labelWarningPass = tk.Label(label, text="") labelWarningPass.place(relx=0.55, rely=0.545, anchor=NW) #buton buttonImage = PhotoImage(file="GUIPhotos/031.png") logButton = Button(label, image=buttonImage, relief=RIDGE, command=lambda: verificaDate()) logButton.place(rely=0.8, relx=0.5, anchor=CENTER, width="266", height='35') logButton.image = buttonImage
def externCall(self): dbObj = cLPRDataBase.myDataBase() valoriPentruTabel = dbObj.getInfoLastEntered() self.showInfo(valoriPentruTabel)
def addMasina(): goOn = True if numeEntry.get() is "": numeEntry.config(highlightbackground="red", highlightthickness=1) labelWarningNume.config(text="Introduceti nume!") goOn = False else: labelWarningNume.config(text="") numeEntry.config(highlightthickness=0) if prenumeEntry.get() is "": prenumeEntry.config(highlightbackground="red", highlightthickness=1) labelWarningPrenume.config(text="Introduceti prenume!") goOn = False else: labelWarningPrenume.config(text="") prenumeEntry.config(highlightthickness=0) if functieEntry.get() is "": functieEntry.config(highlightbackground="red", highlightthickness=1) labelWarningFunctie.config(text="Introduceti functie!") goOn = False else: labelWarningFunctie.config(text="") functieEntry.config(highlightthickness=0) if modelEntry.get() is "": modelEntry.config(highlightbackground="red", highlightthickness=1) labelWarningModel.config(text="Introduceti model!") goOn = False else: labelWarningModel.config(text="") modelEntry.config(highlightthickness=0) if marcaEntry.get() is "": marcaEntry.config(highlightbackground="red", highlightthickness=1) labelWarningMarca.config(text="Introduceti producator!") goOn = False else: labelWarningMarca.config(text="") marcaEntry.config(highlightthickness=0) if culoareEntry.get() is "": culoareEntry.config(highlightbackground="red", highlightthickness=1) labelWarningCuloare.config(text="Introduceti culoare!") goOn = False else: labelWarningCuloare.config(text="") culoareEntry.config(highlightthickness=0) if numarEntry.get() is "": numarEntry.config(highlightbackground="red", highlightthickness=1) labelWarningNumar.config(text="Introduceti numar!") goOn = False else: labelWarningNumar.config(text="") numarEntry.config(highlightthickness=0) if goOn is True: mydb = cLPRDataBase.myDataBase() ans = mydb.addNumar(numarEntry.get(), culoareEntry.get(), modelEntry.get(), marcaEntry.get(), numeEntry.get(), prenumeEntry.get(), functieEntry.get()) if ans == 1: numeEntry.config(highlightthickness=0) prenumeEntry.config(highlightthickness=0) functieEntry.config(highlightthickness=0) modelEntry.config(highlightthickness=0) marcaEntry.config(highlightthickness=0) culoareEntry.config(highlightthickness=0) numarEntry.config(highlightthickness=0) numeEntry.delete(0, END) prenumeEntry.delete(0, END) functieEntry.delete(0, END) modelEntry.delete(0, END) marcaEntry.delete(0, END) culoareEntry.delete(0, END) numarEntry.delete(0, END) controller.show_frame(cSucces.SuccesFrame) else: numarEntry.config(highlightbackground="red", highlightthickness=1) labelWarningNumar.config(text="Numarul exista deja!", fg="red")