프로젝트

일반

사용자정보

개정판 c0d132c5

IDc0d132c57f6a7294a331eddb179cf670d3efcb65
상위 9198ffe0
하위 852b0eff

함의성이(가) 약 5년 전에 추가함

issue #506: testing short text

Change-Id: I4f7a9beac6fad7139acb345cb66eb4e6d4b32d62

차이점 보기:

DTI_PID/DTI_PID/OcrResultDialog.py
5 5
from PIL import Image
6 6
import io
7 7
import numpy as np
8
import cv2
8 9
import math
9 10
import enum
10 11

  
......
63 64
        self.boundingBox = boundingBox
64 65
        self._format = format
65 66

  
67
        app_doc_data = AppDocData.instance()
68
        self.img_ocr = app_doc_data.activeDrawing.image.copy()
69
        self.img_ocr = self.img_ocr[int(self.boundingBox.y()):int(self.boundingBox.y() + self.boundingBox.height()), \
70
                int(self.boundingBox.x()):int(self.boundingBox.x() + self.boundingBox.width())]
71

  
66 72
        self.angle = 0  # angle in degree
67 73

  
68 74
        self.ui = OcrResultDialog_UI.Ui_Dialog()
......
71 77
        self.ui.detectResultTextEdit.setFont(QFont('Consolas', 15, QFont.Bold))
72 78
        self.ui.horizontalLayoutTextEdit.addWidget(self.ui.detectResultTextEdit)
73 79

  
74
        app_doc_data = AppDocData.instance()
75 80
        configs = app_doc_data.getAppConfigs('app', 'mode')
76 81
        if configs and 1 == len(configs) and 'advanced' == configs[0].value:
77 82
            pass
......
167 172
            '''CounterClock'''
168 173
            self.angle = (self.angle - 90) % 360
169 174
            transform.rotate(-90)
175

  
176
            self.img_ocr = cv2.rotate(self.img_ocr, cv2.ROTATE_90_COUNTERCLOCKWISE)
170 177
        else:
171 178
            '''Clock'''
172 179
            self.angle = (self.angle - 270) % 360
173 180
            transform.rotate(90)
174 181

  
182
            self.img_ocr = cv2.rotate(self.img_ocr, cv2.ROTATE_90_CLOCKWISE)
183

  
175 184
        self.graphicsView.clearImage()
176 185
        self.image = self.image.transformed(transform)
177 186
        self.graphicsView.setImage(self.image)
......
194 203
                 2018.11.22 euisung     OCR lang apply fixed
195 204
    '''
196 205
    def detect_text(self):
197
        import cv2
198 206
        from TextDetector import TextDetector
199 207
        from TextInfo import TextInfo
200 208

  
201 209
        try:
210
            '''
202 211
            buffer = QBuffer()
203 212
            buffer.open(QBuffer.ReadWrite)
204 213
            self.image.save(buffer, "PNG")
......
208 217
                img_width, img_height = img.shape[::-1]
209 218
            else:
210 219
                _, img_width, img_height = img.shape[::-1]
220
            '''
211 221

  
212 222
            app_doc_data = AppDocData.instance()
213 223

  
214 224
            ocr_data = self.ui.comboBoxOCRData.currentText()
215 225
            white_char_list = app_doc_data.getConfigs('Text Recognition', 'White Character List')
216 226
            if self._format == QOcrResultDialog.Format.Normal:
217
                self.textInfoList = TOCR.getTextInfo(img, (0, 0), 0, language=ocr_data,
227
                self.textInfoList = TOCR.getTextInfo(self.img_ocr, (0, 0), 0, language=ocr_data,
218 228
                                                     conf=white_char_list[0].value if white_char_list else '')
219 229

  
220 230
                if self.textInfoList:
......
351 361
            App.mainWnd().addMessage.emit(MessageType.Error, message)
352 362

  
353 363
    def getMergedTextInfo(self, text):
354
        import cv2
355 364
        from TextInfo import TextInfo
356 365

  
357 366
        buffer = QBuffer()
DTI_PID/DTI_PID/tesseract_ocr_module.py
115 115
        bounding_boxes = boundaryOcrData.split('\n')
116 116

  
117 117
        long_img = None
118
        if False:#not boundaryOcrData and imgHeight / imgWidth > 0.5 and abs(angle) < 1:
119
            img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
118
        if not boundaryOcrData and imgHeight / imgWidth > 0.5 and abs(angle) < 1:
119
            #img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
120 120
            imgNot = np.ones(img.shape, np.uint8)
121 121
            cv2.bitwise_not(img, imgNot)
122 122
            imgNot = cv2.dilate(imgNot, np.ones((3, 3), np.uint8))

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)