개정판 d17cff94
issue #000: preparing symbol training
Change-Id: I32590981c60e488fc61d034161c7601168733d12
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
85 | 85 |
''' |
86 | 86 |
def procCounter(self): # A slot takes no params |
87 | 87 |
try: |
88 |
if self.isSymbolChecked or self.isTextChecked:
|
|
88 |
if self.isSymbolChecked or self.isTrainingChecked:
|
|
89 | 89 |
Worker.executeRecognition(self.createDetectedItems, self.path, self.listWidget, self.isLineChecked, self, self.batch, self.createUnknownItems) |
90 | 90 |
|
91 | 91 |
#TODO: connect line to symbol |
92 | 92 |
#if self.isLineChecked: |
93 | 93 |
# Worker.recognizeLine(self.drawDetectedLines, self.path, self.listWidget, self.graphicsView, self) |
94 | 94 |
except Exception as ex: |
95 |
from App import App |
|
96 |
from AppDocData import MessageType |
|
97 |
|
|
95 | 98 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
96 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
|
|
99 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
97 | 100 |
self.displayLog.emit(MessageType.Error, message) |
98 | 101 |
except: |
99 | 102 |
(type, value, traceback) = sys.exc_info() |
... | ... | |
312 | 315 |
pool.submit(Worker.detectSymbolOnPid, mainRes, symbol, listWidget, worker) |
313 | 316 |
pool.shutdown(wait = True) |
314 | 317 |
|
315 |
## DEBUG |
|
316 |
#for item in searchedSymbolList: |
|
317 |
# _img = appDocData.imgSrc[round(item.getSp()[1]):round(item.getSp()[1]+item.getHeight()), round(item.getSp()[0]):round(item.getSp()[0]+item.getWidth())] |
|
318 |
# cv2.imwrite(os.path.join(project.getTempPath(), 'Tile', item.getName()+'.png'), _img) |
|
319 |
## up to here |
|
320 |
|
|
318 |
if worker.isTrainingChecked: |
|
319 |
import uuid |
|
320 |
worker.displayTitle.emit(worker.tr('Generating Data...')) |
|
321 |
|
|
322 |
for item in searchedSymbolList: |
|
323 |
path = os.path.join(project.getTempPath(), 'Tile', item.getBaseSymbol()) |
|
324 |
if not os.path.exists(path): os.makedirs(path) |
|
325 |
|
|
326 |
_img = appDocData.imgSrc[round(item.getSp()[1]):round(item.getSp()[1]+item.getHeight()), round(item.getSp()[0]):round(item.getSp()[0]+item.getWidth())] |
|
327 |
cv2.imwrite(os.path.join(path, str(uuid.uuid4()) + '.png'), _img) |
|
328 |
return |
|
329 |
|
|
321 | 330 |
pool = futures.ThreadPoolExecutor(max_workers = THREAD_MAX_WORKER) |
322 | 331 |
|
323 | 332 |
for sym in searchedSymbolList: |
... | ... | |
721 | 730 |
global maxProgressValue |
722 | 731 |
|
723 | 732 |
try: |
733 |
forTraining = worker.isTrainingChecked |
|
724 | 734 |
symbolName = targetSymbol.getName() |
725 | 735 |
#threadLock.acquire() |
726 | 736 |
#print(symbolName) |
727 | 737 |
#threadLock.release() |
728 | 738 |
symbolType = targetSymbol.getType() |
729 | 739 |
symbolPath = targetSymbol.getPath() |
730 |
symbolThreshold = targetSymbol.getThreshold() |
|
740 |
symbolThreshold = targetSymbol.getThreshold()# if not forTraining else targetSymbol.getThreshold() / 3 * 2
|
|
731 | 741 |
symbolMinMatchCount = targetSymbol.getMinMatchCount() |
732 | 742 |
isDetectOnOrigin = targetSymbol.getIsDetectOnOrigin() |
733 | 743 |
symbolRotateCount = targetSymbol.getRotationCount() |
... | ... | |
923 | 933 |
isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild , |
924 | 934 |
originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect, detectFlip=1 if index is 1 else 0) |
925 | 935 |
threadLock.release() |
926 |
else:
|
|
936 |
elif not forTraining:
|
|
927 | 937 |
searchedSymbol = searchedSymbolList[symbolIndex] |
928 | 938 |
symbolHitRate = searchedSymbol.getHitRate() |
929 | 939 |
if symbolHitRate - searchedSymbol.getThreshold() < hitRate - symbolThreshold: |
... | ... | |
1583 | 1593 |
self.ui.lineCheckBox.stateChanged.connect(self.checkBoxChanged) |
1584 | 1594 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxChanged) |
1585 | 1595 |
self.ui.checkBoxText.stateChanged.connect(self.checkBoxChanged) |
1596 |
#self.ui.checkBoxTraining.stateChanged.connect(self.checkBoxChanged) |
|
1586 | 1597 |
self.isAccepted = False |
1587 | 1598 |
self.batch = batch |
1588 | 1599 |
|
... | ... | |
1712 | 1723 |
self.obj.isSymbolChecked = self.ui.checkBoxSymbol.isChecked() |
1713 | 1724 |
self.obj.isTextChecked = self.ui.checkBoxText.isChecked() |
1714 | 1725 |
self.obj.isLineChecked = self.ui.lineCheckBox.isChecked() |
1726 |
self.obj.isTrainingChecked = self.ui.checkBoxTraining.isChecked() |
|
1715 | 1727 |
self.obj.batch = self.batch |
1716 | 1728 |
self.obj.createDetectedItems = self.parent.createDetectedItems |
1717 | 1729 |
self.obj.createUnknownItems = self.parent.createUnknownItems |
DTI_PID/DTI_PID/Recognition_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\UI\Recognition.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/Recognition.ui'
|
|
4 | 4 |
# |
5 | 5 |
# Created by: PyQt5 UI code generator 5.11.3 |
6 | 6 |
# |
... | ... | |
20 | 20 |
self.gridLayout.setObjectName("gridLayout") |
21 | 21 |
self.gridLayout_2 = QtWidgets.QGridLayout() |
22 | 22 |
self.gridLayout_2.setObjectName("gridLayout_2") |
23 |
self.lineCheckBox = QtWidgets.QCheckBox(Recognition) |
|
24 |
self.lineCheckBox.setMaximumSize(QtCore.QSize(47, 16777215)) |
|
25 |
self.lineCheckBox.setChecked(False) |
|
26 |
self.lineCheckBox.setObjectName("lineCheckBox") |
|
27 |
self.gridLayout_2.addWidget(self.lineCheckBox, 0, 2, 1, 1) |
|
28 | 23 |
self.checkBoxSymbol = QtWidgets.QCheckBox(Recognition) |
29 | 24 |
self.checkBoxSymbol.setMaximumSize(QtCore.QSize(103, 16777215)) |
30 | 25 |
self.checkBoxSymbol.setChecked(True) |
... | ... | |
32 | 27 |
self.gridLayout_2.addWidget(self.checkBoxSymbol, 0, 0, 1, 1) |
33 | 28 |
self.listWidget = QtWidgets.QListWidget(Recognition) |
34 | 29 |
self.listWidget.setObjectName("listWidget") |
35 |
self.gridLayout_2.addWidget(self.listWidget, 1, 0, 1, 5)
|
|
30 |
self.gridLayout_2.addWidget(self.listWidget, 1, 0, 1, 7)
|
|
36 | 31 |
self.progressBar = QtWidgets.QProgressBar(Recognition) |
37 | 32 |
self.progressBar.setProperty("value", 0) |
38 | 33 |
self.progressBar.setObjectName("progressBar") |
39 |
self.gridLayout_2.addWidget(self.progressBar, 2, 0, 1, 5)
|
|
34 |
self.gridLayout_2.addWidget(self.progressBar, 2, 0, 1, 7)
|
|
40 | 35 |
self.labelImage = QtWidgets.QLabel(Recognition) |
41 | 36 |
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) |
42 | 37 |
sizePolicy.setHorizontalStretch(0) |
... | ... | |
50 | 45 |
self.labelImage.setScaledContents(True) |
51 | 46 |
self.labelImage.setAlignment(QtCore.Qt.AlignCenter) |
52 | 47 |
self.labelImage.setObjectName("labelImage") |
53 |
self.gridLayout_2.addWidget(self.labelImage, 1, 5, 1, 1)
|
|
54 |
self.recognizeButton = QtWidgets.QPushButton(Recognition)
|
|
55 |
self.recognizeButton.setMinimumSize(QtCore.QSize(150, 0))
|
|
56 |
self.recognizeButton.setMaximumSize(QtCore.QSize(150, 16777215))
|
|
57 |
self.recognizeButton.setObjectName("recognizeButton")
|
|
58 |
self.gridLayout_2.addWidget(self.recognizeButton, 0, 5, 1, 1, QtCore.Qt.AlignRight)
|
|
48 |
self.gridLayout_2.addWidget(self.labelImage, 1, 7, 1, 1)
|
|
49 |
self.lineCheckBox = QtWidgets.QCheckBox(Recognition)
|
|
50 |
self.lineCheckBox.setMaximumSize(QtCore.QSize(47, 16777215))
|
|
51 |
self.lineCheckBox.setChecked(False)
|
|
52 |
self.lineCheckBox.setObjectName("lineCheckBox")
|
|
53 |
self.gridLayout_2.addWidget(self.lineCheckBox, 0, 2, 1, 1)
|
|
59 | 54 |
self.checkBoxText = QtWidgets.QCheckBox(Recognition) |
60 | 55 |
self.checkBoxText.setMaximumSize(QtCore.QSize(103, 16777215)) |
61 | 56 |
self.checkBoxText.setChecked(True) |
... | ... | |
80 | 75 |
self.labelTitle.setText("") |
81 | 76 |
self.labelTitle.setAlignment(QtCore.Qt.AlignCenter) |
82 | 77 |
self.labelTitle.setObjectName("labelTitle") |
83 |
self.gridLayout_2.addWidget(self.labelTitle, 0, 4, 1, 1) |
|
84 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
85 |
self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1) |
|
78 |
self.gridLayout_2.addWidget(self.labelTitle, 0, 6, 1, 1) |
|
86 | 79 |
self.progressBarBatch = QtWidgets.QProgressBar(Recognition) |
87 | 80 |
self.progressBarBatch.setProperty("value", 0) |
88 | 81 |
self.progressBarBatch.setObjectName("progressBarBatch") |
89 |
self.gridLayout_2.addWidget(self.progressBarBatch, 3, 0, 1, 5) |
|
82 |
self.gridLayout_2.addWidget(self.progressBarBatch, 3, 0, 1, 7) |
|
83 |
self.recognizeButton = QtWidgets.QPushButton(Recognition) |
|
84 |
self.recognizeButton.setMinimumSize(QtCore.QSize(150, 0)) |
|
85 |
self.recognizeButton.setMaximumSize(QtCore.QSize(150, 16777215)) |
|
86 |
self.recognizeButton.setObjectName("recognizeButton") |
|
87 |
self.gridLayout_2.addWidget(self.recognizeButton, 0, 7, 1, 1, QtCore.Qt.AlignRight) |
|
90 | 88 |
self.buttonBox = QtWidgets.QDialogButtonBox(Recognition) |
91 | 89 |
self.buttonBox.setEnabled(False) |
92 | 90 |
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) |
... | ... | |
99 | 97 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
100 | 98 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close) |
101 | 99 |
self.buttonBox.setObjectName("buttonBox") |
102 |
self.gridLayout_2.addWidget(self.buttonBox, 3, 5, 1, 1) |
|
100 |
self.gridLayout_2.addWidget(self.buttonBox, 3, 7, 1, 1) |
|
101 |
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
102 |
self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1) |
|
103 |
self.checkBoxTraining = QtWidgets.QCheckBox(Recognition) |
|
104 |
self.checkBoxTraining.setObjectName("checkBoxTraining") |
|
105 |
self.gridLayout_2.addWidget(self.checkBoxTraining, 0, 5, 1, 1) |
|
103 | 106 |
self.gridLayout.addLayout(self.gridLayout_2, 0, 1, 1, 1) |
104 | 107 |
|
105 | 108 |
self.retranslateUi(Recognition) |
... | ... | |
109 | 112 |
def retranslateUi(self, Recognition): |
110 | 113 |
_translate = QtCore.QCoreApplication.translate |
111 | 114 |
Recognition.setWindowTitle(_translate("Recognition", "Recognize Engineering Info.")) |
112 |
self.lineCheckBox.setText(_translate("Recognition", "Line")) |
|
113 | 115 |
self.checkBoxSymbol.setText(_translate("Recognition", "Symbol")) |
114 |
self.recognizeButton.setText(_translate("Recognition", "Recognize"))
|
|
116 |
self.lineCheckBox.setText(_translate("Recognition", "Line"))
|
|
115 | 117 |
self.checkBoxText.setText(_translate("Recognition", "Text")) |
118 |
self.recognizeButton.setText(_translate("Recognition", "Recognize")) |
|
119 |
self.checkBoxTraining.setText(_translate("Recognition", "Make Data for Training")) |
|
116 | 120 |
|
117 | 121 |
|
118 | 122 |
if __name__ == "__main__": |
DTI_PID/DTI_PID/UI/Recognition.ui | ||
---|---|---|
24 | 24 |
<layout class="QGridLayout" name="gridLayout"> |
25 | 25 |
<item row="0" column="1"> |
26 | 26 |
<layout class="QGridLayout" name="gridLayout_2"> |
27 |
<item row="0" column="2"> |
|
28 |
<widget class="QCheckBox" name="lineCheckBox"> |
|
29 |
<property name="maximumSize"> |
|
30 |
<size> |
|
31 |
<width>47</width> |
|
32 |
<height>16777215</height> |
|
33 |
</size> |
|
34 |
</property> |
|
35 |
<property name="text"> |
|
36 |
<string>Line</string> |
|
37 |
</property> |
|
38 |
<property name="checked"> |
|
39 |
<bool>false</bool> |
|
40 |
</property> |
|
41 |
</widget> |
|
42 |
</item> |
|
43 | 27 |
<item row="0" column="0"> |
44 | 28 |
<widget class="QCheckBox" name="checkBoxSymbol"> |
45 | 29 |
<property name="maximumSize"> |
... | ... | |
56 | 40 |
</property> |
57 | 41 |
</widget> |
58 | 42 |
</item> |
59 |
<item row="1" column="0" colspan="5">
|
|
43 |
<item row="1" column="0" colspan="7">
|
|
60 | 44 |
<widget class="QListWidget" name="listWidget"/> |
61 | 45 |
</item> |
62 |
<item row="2" column="0" colspan="5">
|
|
46 |
<item row="2" column="0" colspan="7">
|
|
63 | 47 |
<widget class="QProgressBar" name="progressBar"> |
64 | 48 |
<property name="value"> |
65 | 49 |
<number>0</number> |
66 | 50 |
</property> |
67 | 51 |
</widget> |
68 | 52 |
</item> |
69 |
<item row="1" column="5">
|
|
53 |
<item row="1" column="7">
|
|
70 | 54 |
<widget class="QLabel" name="labelImage"> |
71 | 55 |
<property name="sizePolicy"> |
72 | 56 |
<sizepolicy hsizetype="Ignored" vsizetype="Ignored"> |
... | ... | |
100 | 84 |
</property> |
101 | 85 |
</widget> |
102 | 86 |
</item> |
103 |
<item row="0" column="5" alignment="Qt::AlignRight"> |
|
104 |
<widget class="QPushButton" name="recognizeButton"> |
|
105 |
<property name="minimumSize"> |
|
106 |
<size> |
|
107 |
<width>150</width> |
|
108 |
<height>0</height> |
|
109 |
</size> |
|
110 |
</property> |
|
87 |
<item row="0" column="2"> |
|
88 |
<widget class="QCheckBox" name="lineCheckBox"> |
|
111 | 89 |
<property name="maximumSize"> |
112 | 90 |
<size> |
113 |
<width>150</width>
|
|
91 |
<width>47</width>
|
|
114 | 92 |
<height>16777215</height> |
115 | 93 |
</size> |
116 | 94 |
</property> |
117 | 95 |
<property name="text"> |
118 |
<string>Recognize</string> |
|
96 |
<string>Line</string> |
|
97 |
</property> |
|
98 |
<property name="checked"> |
|
99 |
<bool>false</bool> |
|
119 | 100 |
</property> |
120 | 101 |
</widget> |
121 | 102 |
</item> |
... | ... | |
135 | 116 |
</property> |
136 | 117 |
</widget> |
137 | 118 |
</item> |
138 |
<item row="0" column="4">
|
|
119 |
<item row="0" column="6">
|
|
139 | 120 |
<widget class="QLabel" name="labelTitle"> |
140 | 121 |
<property name="palette"> |
141 | 122 |
<palette> |
... | ... | |
188 | 169 |
</property> |
189 | 170 |
</widget> |
190 | 171 |
</item> |
191 |
<item row="0" column="3">
|
|
192 |
<spacer name="horizontalSpacer">
|
|
193 |
<property name="orientation">
|
|
194 |
<enum>Qt::Horizontal</enum>
|
|
172 |
<item row="3" column="0" colspan="7">
|
|
173 |
<widget class="QProgressBar" name="progressBarBatch">
|
|
174 |
<property name="value">
|
|
175 |
<number>0</number>
|
|
195 | 176 |
</property> |
196 |
<property name="sizeHint" stdset="0"> |
|
177 |
</widget> |
|
178 |
</item> |
|
179 |
<item row="0" column="7" alignment="Qt::AlignRight"> |
|
180 |
<widget class="QPushButton" name="recognizeButton"> |
|
181 |
<property name="minimumSize"> |
|
197 | 182 |
<size> |
198 |
<width>40</width>
|
|
199 |
<height>20</height>
|
|
183 |
<width>150</width>
|
|
184 |
<height>0</height> |
|
200 | 185 |
</size> |
201 | 186 |
</property> |
202 |
</spacer> |
|
203 |
</item> |
|
204 |
<item row="3" column="0" colspan="5"> |
|
205 |
<widget class="QProgressBar" name="progressBarBatch"> |
|
206 |
<property name="value"> |
|
207 |
<number>0</number> |
|
187 |
<property name="maximumSize"> |
|
188 |
<size> |
|
189 |
<width>150</width> |
|
190 |
<height>16777215</height> |
|
191 |
</size> |
|
192 |
</property> |
|
193 |
<property name="text"> |
|
194 |
<string>Recognize</string> |
|
208 | 195 |
</property> |
209 | 196 |
</widget> |
210 | 197 |
</item> |
211 |
<item row="3" column="5">
|
|
198 |
<item row="3" column="7">
|
|
212 | 199 |
<widget class="QDialogButtonBox" name="buttonBox"> |
213 | 200 |
<property name="enabled"> |
214 | 201 |
<bool>false</bool> |
... | ... | |
239 | 226 |
</property> |
240 | 227 |
</widget> |
241 | 228 |
</item> |
229 |
<item row="0" column="3"> |
|
230 |
<spacer name="horizontalSpacer"> |
|
231 |
<property name="orientation"> |
|
232 |
<enum>Qt::Horizontal</enum> |
|
233 |
</property> |
|
234 |
<property name="sizeHint" stdset="0"> |
|
235 |
<size> |
|
236 |
<width>40</width> |
|
237 |
<height>20</height> |
|
238 |
</size> |
|
239 |
</property> |
|
240 |
</spacer> |
|
241 |
</item> |
|
242 |
<item row="0" column="5"> |
|
243 |
<widget class="QCheckBox" name="checkBoxTraining"> |
|
244 |
<property name="text"> |
|
245 |
<string>Make Data for Training</string> |
|
246 |
</property> |
|
247 |
</widget> |
|
248 |
</item> |
|
242 | 249 |
</layout> |
243 | 250 |
</item> |
244 | 251 |
</layout> |
내보내기 Unified diff