개정판 7dd4c31a
set text angle to 0 if text is contained in instrument
DTI_PID/DTI_PID/DTI_PID.py | ||
---|---|---|
674 | 674 |
Jeongwoo 2018.06.08 Add angle Parameter on TOCR.getTextInfo |
675 | 675 |
humkyung 2018.06.16 update proessbar while recognizing text |
676 | 676 |
humkyung 2018.07.03 remove white space and replace given oldStr with newStr |
677 |
humkyung 2018.07.04 set |
|
677 | 678 |
''' |
678 |
def initMainSrc(mainRes, tInfoList, updateProgressSignal, listWidget): |
|
679 |
def initMainSrc(mainRes, tInfoList, searchedSymbolList, updateProgressSignal, listWidget):
|
|
679 | 680 |
global srcGray |
680 | 681 |
global ocrCompletedSrc |
681 | 682 |
global textInfoList |
... | ... | |
708 | 709 |
x = tInfo.getX() - round(area.x) |
709 | 710 |
y = tInfo.getY() - round(area.y) |
710 | 711 |
img = imgOCR[y:y+tInfo.getH(), x:x+tInfo.getW()] |
712 |
|
|
713 |
# set angle 0 if symbol contains the text area is instrumentation |
|
714 |
contains = [symbol for symbol in searchedSymbolList if symbol.contains(tInfo)] |
|
715 |
if contains: |
|
716 |
_type = contains[0].getType() |
|
717 |
category = docData.getSymbolCategoryByType(_type) |
|
718 |
if 'Instrumentation' == category: tInfo.setAngle(0) |
|
719 |
# up to here |
|
720 |
|
|
711 | 721 |
resultTextInfo = TOCR.getTextInfo(img, (x, y), tInfo.getAngle()) |
712 | 722 |
if resultTextInfo is not None and len(resultTextInfo) > 0: |
713 | 723 |
for result in resultTextInfo: |
... | ... | |
991 | 1001 |
### up to here |
992 | 1002 |
threadLock.release() |
993 | 1003 |
|
994 |
initMainSrc(mainRes, textAreas, updateProgressSignal, listWidget) |
|
995 |
|
|
996 | 1004 |
pool = futures.ThreadPoolExecutor(max_workers = THREAD_MAX_WORKER) |
997 | 1005 |
for targetItem in targetSymbolList: |
998 | 1006 |
if type(targetItem) is list: |
... | ... | |
1009 | 1017 |
cv2.imwrite(os.path.join(project.getTempPath(), 'Tile', item.getName()+'.png'), _img) |
1010 | 1018 |
## up to here |
1011 | 1019 |
|
1020 |
initMainSrc(mainRes, textAreas, searchedSymbolList, updateProgressSignal, listWidget) |
|
1021 |
|
|
1012 | 1022 |
chan, docData.imgWidth, docData.imgHeight = src.shape[::-1] |
1013 | 1023 |
drawFoundSymbolsOnCanvas(mainRes, textInfoList, listWidget) |
1014 | 1024 |
|
DTI_PID/DTI_PID/symbol.py | ||
---|---|---|
58 | 58 |
self.text = text |
59 | 59 |
|
60 | 60 |
def getText(self): |
61 |
return self.text |
|
61 |
return self.text |
|
62 |
|
|
63 |
''' |
|
64 |
@brief check if contains given text area |
|
65 |
@author humkyung |
|
66 |
@date 2018.07.04 |
|
67 |
''' |
|
68 |
def contains(self, textArea): |
|
69 |
from TextInfo import TextInfo |
|
70 |
|
|
71 |
minX = self.sp[0] |
|
72 |
minY = self.sp[1] |
|
73 |
maxX = minX + self.width |
|
74 |
maxY = minY + self.height |
|
75 |
|
|
76 |
_minX = textArea.getX() |
|
77 |
_minY = textArea.getY() |
|
78 |
_maxX = _minX + textArea.getW() |
|
79 |
_maxY = _minY + textArea.getH() |
|
80 |
|
|
81 |
return False if (minX > _maxX or minY > _maxY or maxX < _minX or maxY < _minY) else True |
내보내기 Unified diff