17 |
17 |
from SymbolSvgItem import SymbolSvgItem
|
18 |
18 |
from EngineeringTextItem import QEngineeringTextItem
|
19 |
19 |
from EngineeringUnknownItem import QEngineeringUnknownItem
|
|
20 |
from EngineeringErrorItem import QEngineeringErrorItem
|
|
21 |
from EngineeringEndBreakItem import QEngineeringEndBreakItem
|
|
22 |
from symbol import Symbol
|
20 |
23 |
|
21 |
24 |
from MainWindow import MainWindow
|
22 |
25 |
|
... | ... | |
211 |
214 |
|
212 |
215 |
#remove already existing symbol and text
|
213 |
216 |
if not batch:
|
214 |
|
items = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem) or \
|
215 |
|
issubclass(type(item), QEngineeringTextItem) or \
|
216 |
|
type(item) is QEngineeringUnknownItem]
|
|
217 |
items = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringUnknownItem or type(item) is QEngineeringEndBreakItem or type(item) is QEngineeringErrorItem]
|
|
218 |
if worker.isSymbolChecked:
|
|
219 |
items.extend([item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)])
|
|
220 |
if worker.isTextChecked:
|
|
221 |
items.extend([item for item in worker.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)])
|
217 |
222 |
for item in items:
|
218 |
223 |
worker.graphicsView.scene.removeItem(item)
|
219 |
|
|
220 |
224 |
#up to here
|
221 |
225 |
|
222 |
226 |
srcList = path
|
... | ... | |
310 |
314 |
for sym in searchedSymbolList:
|
311 |
315 |
pool.submit(Worker.removeDetectedSymbol, sym, appDocData.imgSrc)
|
312 |
316 |
pool.shutdown(wait = True)
|
|
317 |
print(searchedSymbolList[0].getOcrOption())
|
|
318 |
else:
|
|
319 |
# if symbol is excluded from recognition, keep it
|
|
320 |
import math
|
|
321 |
|
|
322 |
symbolItems = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)]
|
|
323 |
|
|
324 |
for symbolItem in symbolItems:
|
|
325 |
symbolName = symbolItem.name
|
|
326 |
symbolType = symbolItem.type
|
|
327 |
searchedItemSp = [int(symbolItem.loc[0]), int(symbolItem.loc[1])]
|
|
328 |
sw = symbolItem.size[0] # check later
|
|
329 |
sh = symbolItem.size[1] # check later
|
|
330 |
|
|
331 |
symbolThreshold = 50 # not necessary
|
|
332 |
symbolMinMatchCount = 0 # not necessary
|
|
333 |
hitRate = 80 # not necessary
|
|
334 |
|
|
335 |
allowed_error = 0.0001
|
|
336 |
#degree 0
|
|
337 |
if abs(symbolItem.angle - 0) <= allowed_error:
|
|
338 |
symbolRotatedAngle = 0
|
|
339 |
#degree 90
|
|
340 |
elif abs(symbolItem.angle - 1.57) <= allowed_error:
|
|
341 |
symbolRotatedAngle = 90
|
|
342 |
#degree 180
|
|
343 |
elif abs(symbolItem.angle - 3.14) <= allowed_error:
|
|
344 |
symbolRotatedAngle = 180
|
|
345 |
#degree 270
|
|
346 |
elif abs(symbolItem.angle - 4.71) <= allowed_error:
|
|
347 |
symbolRotatedAngle = 270
|
|
348 |
else:
|
|
349 |
symbolRotatedAngle = math.pi / 180 * symbolItem.angle
|
|
350 |
|
|
351 |
isDetectOnOrigin = 80 # not necessary
|
|
352 |
symbolRotateCount = 0 # not necessary
|
|
353 |
symbolOcrOption = 0 # not necessary
|
|
354 |
isContainChild = 0 # not necessary
|
|
355 |
originalPoint = [symbolItem.origin[0] - symbolItem.loc[0], symbolItem.origin[1] - symbolItem.loc[1]]
|
|
356 |
symbolConnectionPoint = []
|
|
357 |
baseSymbol = str(symbolItem.parentSymbol)
|
|
358 |
additionalSymbol = str(symbolItem.childSymbol)
|
|
359 |
isExceptDetect = 0 # not necessary
|
|
360 |
detectFlip = symbolItem.flip
|
|
361 |
|
|
362 |
searchedSymbolList.append(Symbol(symbolName, symbolType ,
|
|
363 |
searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, hitRate, symbolRotatedAngle ,
|
|
364 |
isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild ,
|
|
365 |
','.join(str(x) for x in originalPoint),
|
|
366 |
[],
|
|
367 |
baseSymbol, additionalSymbol, isExceptDetect, detectFlip))
|
|
368 |
|
|
369 |
worker.graphicsView.scene.removeItem(symbolItem)
|
|
370 |
|
|
371 |
pool = futures.ThreadPoolExecutor(max_workers = THREAD_MAX_WORKER)
|
|
372 |
|
|
373 |
for sym in searchedSymbolList:
|
|
374 |
pool.submit(Worker.removeDetectedSymbol, sym, appDocData.imgSrc)
|
|
375 |
pool.shutdown(wait = True)
|
313 |
376 |
|
314 |
377 |
worker.updateBatchProgress.emit(len(srcList), 1)
|
315 |
378 |
|
... | ... | |
368 |
431 |
|
369 |
432 |
if isLineChecked:
|
370 |
433 |
Worker.recognizeLine(mainRes, listWidget, worker.graphicsView, worker, batch)
|
|
434 |
else:
|
|
435 |
pass
|
371 |
436 |
|
372 |
437 |
createUnknownItems(mainRes)
|
373 |
438 |
|
... | ... | |
741 |
806 |
Worker.addSearchedSymbol(symbolName, symbolType ,
|
742 |
807 |
searchedItemSp, sw, sh, symbolThreshold, symbolMinMatchCount, hitRate, symbolRotatedAngle ,
|
743 |
808 |
isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild ,
|
744 |
|
originalPoint, connectionPoint, baseSymbol, additionalSymbol,isExceptDetect, detectFlip=1 if index is 1 else 0)
|
|
809 |
originalPoint, connectionPoint, baseSymbol, additionalSymbol, isExceptDetect, detectFlip=1 if index is 1 else 0)
|
745 |
810 |
threadLock.release()
|
746 |
811 |
else: ## 겹치는 영역이 기준값보다 클 경우
|
747 |
812 |
if symbolIndex != -1 and symbolIndex < len(searchedSymbolList):
|
... | ... | |
757 |
822 |
isDetectOnOrigin, symbolRotateCount, symbolOcrOption, isContainChild ,
|
758 |
823 |
','.join(str(x) for x in originalPoint),
|
759 |
824 |
'/'.join('{},{},{},{}'.format(param[0], param[1], param[2], param[3]) for param in connectionPoint),
|
760 |
|
baseSymbol, additionalSymbol,isExceptDetect, detectFlip=1 if index is 1 else 0)
|
|
825 |
baseSymbol, additionalSymbol, isExceptDetect, detectFlip=1 if index is 1 else 0)
|
761 |
826 |
threadLock.release()
|
762 |
827 |
## 현재 심볼과 검출된 심볼이 같지 않을 경우 (포함)
|
763 |
828 |
elif appDocData.isEquipmentType(searchedSymbol.getType()):
|
... | ... | |
1416 |
1481 |
self.ui = Recognition_UI.Ui_Recognition()
|
1417 |
1482 |
self.ui.setupUi(self)
|
1418 |
1483 |
|
|
1484 |
self.ui.buttonBox.setEnabled(True)
|
|
1485 |
self.ui.listWidget.model().rowsInserted.connect(self.rowInserted)
|
|
1486 |
self.ui.recognizeButton.clicked.connect(self.recognizeButtonClicked)
|
|
1487 |
self.ui.lineCheckBox.stateChanged.connect(self.checkBoxChanged)
|
|
1488 |
self.ui.checkBoxSymbol.stateChanged.connect(self.checkBoxChanged)
|
|
1489 |
self.isAccepted = False
|
|
1490 |
self.batch = batch
|
|
1491 |
|
1419 |
1492 |
appDocData = AppDocData.instance()
|
1420 |
1493 |
configs = appDocData.getAppConfigs('app', 'mode')
|
1421 |
1494 |
if configs and 1 == len(configs) and 'advanced' == configs[0].value:
|
... | ... | |
1423 |
1496 |
else:
|
1424 |
1497 |
self.ui.lineCheckBox.setVisible(False)
|
1425 |
1498 |
|
1426 |
|
self.ui.buttonBox.setEnabled(True)
|
1427 |
|
self.ui.listWidget.model().rowsInserted.connect(self.rowInserted)
|
1428 |
|
self.ui.recognizeButton.clicked.connect(self.recognizeButtonClicked)
|
1429 |
|
self.isAccepted = False
|
1430 |
|
self.batch = batch
|
|
1499 |
if self.batch:
|
|
1500 |
self.ui.lineCheckBox.setCheckState(Qt.Checked)
|
|
1501 |
self.ui.lineCheckBox.setEnabled(False)
|
|
1502 |
self.ui.checkBoxSymbol.setEnabled(False)
|
|
1503 |
self.ui.checkBoxText.setEnabled(False)
|
|
1504 |
|
|
1505 |
def checkBoxChanged(self, checkState):
|
|
1506 |
'''
|
|
1507 |
@brief line cannot be eocognized alone
|
|
1508 |
@author euisung
|
|
1509 |
@date 2019.05.14
|
|
1510 |
'''
|
|
1511 |
if checkState is int(Qt.Checked):
|
|
1512 |
if self.ui.lineCheckBox.isChecked() and not self.ui.checkBoxSymbol.isChecked():
|
|
1513 |
self.ui.checkBoxSymbol.setCheckState(Qt.Checked)
|
|
1514 |
elif checkState is int(Qt.Unchecked):
|
|
1515 |
if self.ui.lineCheckBox.isChecked() and not self.ui.checkBoxSymbol.isChecked():
|
|
1516 |
self.ui.lineCheckBox.setCheckState(Qt.Unchecked)
|
|
1517 |
|
1431 |
1518 |
|
1432 |
1519 |
'''
|
1433 |
1520 |
@brief QListWidget Row Inserted Listener
|
... | ... | |
1448 |
1535 |
@author humkyung
|
1449 |
1536 |
@history humkyung 2018.10.05 clear imgSrc before recognizing
|
1450 |
1537 |
"""
|
1451 |
|
if self.ui.checkBoxSymbol.isChecked() or self.ui.checkBoxText.isChecked() or self.ui.lineCheckBox.isChecked():
|
|
1538 |
if self.ui.checkBoxSymbol.isChecked() or self.ui.checkBoxText.isChecked():# or self.ui.lineCheckBox.isChecked():
|
1452 |
1539 |
appDocData = AppDocData.instance()
|
1453 |
1540 |
appDocData.imgSrc = None
|
1454 |
1541 |
area = appDocData.getArea('Drawing')
|