개정판 7c57b0f1
issue #663: fix text detection
Change-Id: I0c4423073720acaa75b8daf48729ba3b3c9dd79f
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
475 | 475 |
if symbol_angle is 180 or symbol_angle is 0: |
476 | 476 |
text_angle = 0 |
477 | 477 |
else: |
478 |
text_angle90 |
|
478 |
text_angle = 90
|
|
479 | 479 |
text_area_symbols.append(TextInfo('', x, y, w, h, text_angle)) |
480 | 480 |
|
481 | 481 |
for textArea_index in reversed(range(len(textAreas))): |
482 |
is_pop = False |
|
482 | 483 |
for text_area_index in reversed(range(len(text_area_symbols))): |
483 | 484 |
if text_area_symbols[text_area_index].contains(textAreas[textArea_index].center) or \ |
484 | 485 |
textAreas[textArea_index].contains(text_area_symbols[text_area_index].center): |
485 | 486 |
if text_area_symbols[text_area_index].area > textAreas[textArea_index].area: |
486 | 487 |
textAreas.pop(textArea_index) |
488 |
is_pop = True |
|
489 |
break |
|
487 | 490 |
else: |
488 | 491 |
text_area_symbols.pop(text_area_index) |
492 |
break |
|
493 |
if is_pop: |
|
494 |
break |
|
489 | 495 |
textAreas.extend(text_area_symbols) |
490 | 496 |
# up to here |
491 | 497 |
|
DTI_PID/DTI_PID/TextDetector.py | ||
---|---|---|
139 | 139 |
|
140 | 140 |
# skip one which size is greater than max size or less then minimum size |
141 | 141 |
if (w > maxTextSize or h > maxTextSize) or (w <= minSize and h <= minSize): |
142 |
cv2.drawContours(ocr_image, [contour], -1, (255, 255, 255), -1) |
|
142 |
#cv2.drawContours(ocr_image, [contour], -1, (255, 255, 255), -1)
|
|
143 | 143 |
continue |
144 | 144 |
|
145 | 145 |
if area >= 0: |
146 | 146 |
cv2.drawContours(ocr_image, [contour], -1, (0, 0, 0), -1) |
147 |
cv2.drawContours(ocr_image, [contour], -1, (255, 255, 255), 1) |
|
148 |
else: |
|
149 |
cv2.drawContours(ocr_image, [contour], -1, (255, 255, 255), -1) |
|
147 |
#cv2.drawContours(ocr_image, [contour], -1, (255, 255, 255), 1)
|
|
148 |
#else:
|
|
149 |
# cv2.drawContours(ocr_image, [contour], -1, (255, 255, 255), -1)
|
|
150 | 150 |
|
151 | 151 |
path = os.path.join(project.getTempPath(), 'OCR_{}.png'.format(app_doc_data.imgName)) |
152 | 152 |
cv2.imwrite(path, ocr_image) |
내보내기 Unified diff