-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyqt.py
97 lines (89 loc) · 3.05 KB
/
pyqt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import sys
import Tkinter
import tkFileDialog
from thread import start_new_thread
import threading
from PyQt4 import QtCore, QtGui, uic
import train
import time
import test
import os
global Image_path,Train_path,a
form_class = uic.loadUiType("example.ui")[0] # Load the UI
class MyWindowClass(QtGui.QMainWindow, form_class):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.setupUi(self)
self.pushButton.clicked.connect(self.Browse) # Bind the event handlers
self.pushButton_3.clicked.connect(self.Browse2) # to the buttons
self.pushButton_2.clicked.connect(self.final)
# self.pushButton_4.clicked.connect(self.caltra)
self.label_2.setPixmap(QtGui.QPixmap("default.jpg"))
self.label_3.setPixmap(QtGui.QPixmap("default.jpg"))
self.progressBar.setValue(0)
def Browse(self):
global Train_path
self.onStart()
self.label_2.setPixmap(QtGui.QPixmap("default.jpg"))
self.label_3.setPixmap(QtGui.QPixmap("default.jpg"))
self.label_6.clear()
self.lineEdit_3.setText("")
root = Tkinter.Tk()
root.withdraw() # button event handler
Train_path=tkFileDialog.askdirectory()
#filedialog= QtGui.QFileDialog()
#Train_path=str(filedialog.getExistingDirectory(self,"Select Train Directory"))
x=Train_path.split('/')
l=len(x)
self.lineEdit.setText(x[l-1])
self.caltra()
def caltra(self):
a=1
global Train_path
self.label_8.setText("Please wait..Training database!! ")
t1=threading.Thread(target=train.Train,args=(Train_path,))
t1.start()
self.onStart()
self.pushButton.setEnabled(False)
self.pushButton_2.setEnabled(False)
self.pushButton_3.setEnabled(False)
while(1):
QtCore.QCoreApplication.processEvents()
if(t1.isAlive()==0):
self.onFinished()
self.label_8.setText("Trained!! Choose Test Image.. ")
self.pushButton.setEnabled(True)
self.pushButton_2.setEnabled(True)
self.pushButton_3.setEnabled(True)
break
else:
self.onStart()
#self.label_5.setText("Trained!!!")
def onStart(self):
self.progressBar.setRange(0,0)
def onFinished(self):
# Stop the pulsation
self.progressBar.setRange(0,1)
self.progressBar.setValue(1)
def Browse2(self):
global Image_path
self.label_5.setText("")
self.label_6.clear() # button event handler
Image_path =tkFileDialog.askopenfilename()
self.label_2.setPixmap(QtGui.QPixmap(Image_path))
self.label_3.setPixmap(QtGui.QPixmap("default.jpg"))
self.lineEdit_3.setText(Image_path)
def final(self):
global Image_path,Train_path
path=test.Test(Image_path)
for i in range(1,path+1):
path2=Train_path+"/"+str(i)
QtCore.QCoreApplication.processEvents()
self.label_3.setPixmap(QtGui.QPixmap(path2))
time.sleep(.1)
self.label_5.setText("MATCH FOUND!")
self.label_6.setPixmap(QtGui.QPixmap("Tick4.jpg"))
app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
myWindow.show()
app.exec_()