개정판 fb3ad432
issue #000: improve text from server and fixing unrecognize text
Change-Id: Ie5a3cadfaa8d9080b64e17585df1549c77dcf785
DTI_PID/DTI_PID/Shapes/EngineeringUnknownItem.py | ||
---|---|---|
107 | 107 |
def contextMenuEvent(self, event): |
108 | 108 |
if self.isSelected(): |
109 | 109 |
menu = QMenu() |
110 |
registerSymbolAction = QAction("심볼 등록")
|
|
110 |
registerSymbolAction = QAction("Register Symbol")
|
|
111 | 111 |
registerSymbolAction.triggered.connect(lambda: self.onRegisterSymbolEvent()) |
112 | 112 |
menu.addAction(registerSymbolAction) |
113 |
recognizeTextAction = QAction("텍스트 인식")
|
|
113 |
recognizeTextAction = QAction("Recognize Text")
|
|
114 | 114 |
recognizeTextAction.triggered.connect(lambda: self.onRecognizeTextEvent()) |
115 | 115 |
menu.addAction(recognizeTextAction) |
116 | 116 |
|
... | ... | |
188 | 188 |
|
189 | 189 |
App.mainWnd().onRecognizeText(round(rect.left()), round(rect.top()), round(rect.width()), |
190 | 190 |
round(rect.height())) |
191 |
self.transfer.onRemoved.emit(self) |
|
191 | 192 |
except Exception as ex: |
192 | 193 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
193 | 194 |
sys.exc_info()[-1].tb_lineno) |
DTI_PID/DTI_PID/TextDetector.py | ||
---|---|---|
49 | 49 |
listWidget.addItem(worker.tr('Waiting for text information from the server...')) |
50 | 50 |
|
51 | 51 |
# using craft |
52 |
local_info, _ = self.getTextAreaInfo(img, offset[0], offset[1]) |
|
53 |
server_info, img = self.get_text_box_using_craft(img, offset[0], offset[1], web=True) |
|
54 |
|
|
52 |
server_info, _img = self.get_text_box_using_craft(img, offset[0], offset[1], web=True) |
|
53 |
|
|
54 |
img_remain = img.copy() |
|
55 |
for text in server_info: |
|
56 |
x = round(text.getX() - offset[0]) |
|
57 |
y = round(text.getY() - offset[1]) |
|
58 |
width = round(text.getW()) |
|
59 |
height = round(text.getH()) |
|
60 |
cv2.rectangle(img_remain, (x, y), (x + width, y + height), 255, -1) |
|
61 |
|
|
62 |
local_info, _ = self.getTextAreaInfo(img_remain, offset[0], offset[1]) |
|
63 |
|
|
64 |
#configs = app_doc_data.getConfigs('Text Size', 'Min Text Size') |
|
65 |
#minSize = int(configs[0].value) if 1 == len(configs) else 20 |
|
66 |
#min_area = sys.maxsize#minSize * minSize * 2 |
|
67 |
|
|
68 |
''' |
|
55 | 69 |
min_area = sys.maxsize |
56 | 70 |
for info in server_info: |
57 | 71 |
if info.area < min_area: |
... | ... | |
61 | 75 |
for index in reversed(range(len(local_info))): |
62 | 76 |
if local_info[index].area > min_area: |
63 | 77 |
local_info.pop(index) |
78 |
''' |
|
64 | 79 |
|
65 | 80 |
return local_info + server_info, img |
66 | 81 |
|
... | ... | |
272 | 287 |
configs = app_doc_data.getConfigs('Text Size', 'Min Text Size') |
273 | 288 |
minSize = int(configs[0].value) if 1 == len(configs) else 15 |
274 | 289 |
if minSize < 28: |
275 |
minSize += 13
|
|
290 |
minSize = 20
|
|
276 | 291 |
|
277 | 292 |
binary_image = cv2.threshold(ocr_image, 200, 255, cv2.THRESH_BINARY)[1] |
278 | 293 |
|
내보내기 Unified diff