-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (44 loc) · 1.8 KB
/
main.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
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget,QHBoxLayout
from PyQt5.QtGui import QStandardItem
from ImageContainer import ImageContainer
from Sidebar import Sidebar
from ImageCollector import ImageCollector
from Clustering import Clustering
import multiprocessing
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("Duplicate finder")
self.layout = QHBoxLayout()
self.sb=Sidebar(self)
self.layout.addWidget(self.sb)
self.layout.addWidget(ImageContainer(self))
widget = QWidget()
widget.setLayout(self.layout)
self.setCentralWidget(widget)
self.RGBmode=False
self.Threading=False
self.clusters=dict()
def switchImages(self,imgKey):
imgList=self.clusters[imgKey]
self.layout.itemAt(1).widget().deleteLater()
self.layout.removeItem(self.layout.itemAt(1))
self.layout.addWidget(ImageContainer(self,imgList))
def start(self,searchDir,threshold):
images=ImageCollector.getImages(searchDir,self.RGBmode,self.Threading)
clusterGenerator=Clustering(images,self.RGBmode,threshold)
clusters=clusterGenerator.getClusters()
self.clusters={v[0]: v for k,v in clusters.items() if len(v)>1}
clusters=self.clusters
clusterList=self.sb.clusList.model
clusterList.clear()
for key in self.clusters.keys():
item=QStandardItem(key)
clusterList.appendRow(item)
if __name__ == '__main__':
multiprocessing.freeze_support()
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())