프로젝트

일반

사용자정보

개정판 85ed5cf5

ID85ed5cf572e7145187b9ee67925f3fd02b0e1b7d
상위 8187418d
하위 080b40ae

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

fix temp symbol manager

Change-Id: I76d51e46566cb00f04aa44adc07e3a4a55fbe3fa

차이점 보기:

DTI_PID/DTI_PID/DetectSymbolDialog.py
47 47
        if os.path.exists(self.drawingDir):
48 48
            files = os.listdir(self.drawingDir)
49 49
            for file in files:
50
                listItem = QListWidgetItem()
51
                listItem.setData(32, file)
52
                listItem.setText(os.path.splitext(file)[0])
53
                self.ui.listWidgetDrawings.addItem(listItem)
50
                if os.path.splitext(file)[1] in ['.png', '.PNG']:
51
                    listItem = QListWidgetItem()
52
                    listItem.setData(32, file)
53
                    listItem.setText(os.path.splitext(file)[0])
54
                    self.ui.listWidgetDrawings.addItem(listItem)
54 55

  
55 56
        self.ui.listWidgetDrawings.currentTextChanged.connect(self.currentTextChangedEvent)
56 57
        self.ui.pushButtonDetectSymbol.clicked.connect(self.detectSymbol)
......
105 106
    def currentTextChangedEvent(self, text):
106 107
        self.imageName = text
107 108
        self.imgPath = self.drawingDir + "\\" + self.ui.listWidgetDrawings.currentItem().data(32)
109

  
110
        appDocData = AppDocData.instance()
111
        drawings = appDocData.getDrawings()
112
        matches = [drawing for drawing in drawings if drawing.file_path == self.imgPath]
113
        if not matches:
114
            self.progress.setValue(self.progress.maximum())
115
            return
116
        self.imgCopy = drawings[0].image.copy()
108 117
        self.tableSetting()
109 118

  
110 119
    '''
......
304 313
        if not self.ui.listWidgetDrawings.count():
305 314
            return
306 315

  
307
        self.progress = QProgressDialog("잠시만 기다려주세요", "Cancel", 0, 100, self)
316
        self.progress = QProgressDialog("Please wait for a while", "Cancel", 0, 100, self)
308 317
        self.progress.setWindowModality(Qt.WindowModal)
309 318
        self.progress.setAutoReset(True)
310 319
        self.progress.setAutoClose(True)
311 320
        self.progress.setMinimum(0)
312 321
        self.progress.resize(600, 100)
313
        self.progress.setWindowTitle("인식 중...")
322
        self.progress.setWindowTitle("Reading file...")
314 323
        self.progress.show()
315 324
        self.progress.setMaximum(100)
316 325
        self.progress.setValue(0)
317 326
        QApplication.processEvents()
318 327

  
319
        from TextDetector import TextDetector
328
        #from TextDetector import TextDetector
320 329

  
321 330
        appDocData = AppDocData.instance()
322 331
        # textDetector에서 사용하기 때문에 설정
323
        appDocData.imgName = self.imageName
332
        #appDocData.imgName = self.imageName
324 333

  
325 334
        # 흑색 이미지로 변환
326
        img = cv2.imread(self.imgPath, 1)
327
        imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
335
        imgGray = self.imgCopy
328 336

  
329 337
        # 프로젝트의 Drawing Area data
330 338
        area = appDocData.getArea('Drawing')
......
333 341
        offset = (area.x, area.y) if area is not None else (0, 0)
334 342

  
335 343
        # 이미지 이진화
336
        thresholdImg = cv2.threshold(imgGray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
344
        #thresholdImg = cv2.threshold(imgGray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
345
        
337 346
        # 프로젝트의 Area 영역만큼만 자른 이미지
338
        areaImg = thresholdImg[round(area.y):round(area.y + area.height), round(area.x):round(area.x + area.width)]
347
        areaImg = imgGray[round(area.y):round(area.y + area.height), round(area.x):round(area.x + area.width)]
339 348

  
340 349
        # 선제거 전에 먼저 작은 영역 제거
341 350
        # contours 추출을 위한 색반전
......
568 577

  
569 578
        xmlPath = self.boxDir + self.imageName + '.box'
570 579
        if os.path.exists(xmlPath):
571
            _pixmap = QPixmap(self.imgPath)
580
            cvImg = self.imgCopy
581
            bytesPerLine = self.imgCopy.shape[1]
582
            _pixmap = QImage(cvImg.data, cvImg.shape[1], cvImg.shape[0], bytesPerLine, QImage.Format_Indexed8)
583
            _pixmap = QPixmap.fromImage(_pixmap)
572 584

  
573 585
            xml = parse(xmlPath)
574 586
            root = xml.getroot()
DTI_PID/DTI_PID/MainWindow.py
574 574

  
575 575
        dlg = QDetectSymbolDialog(self)
576 576
        dlg.exec_()
577
        
578
        self.symbolTreeWidget.initSymbolTreeView()
577 579

  
578 580
    '''
579 581
        @brief      OCR Editor

내보내기 Unified diff

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