프로젝트

일반

사용자정보

개정판 02519509

ID02519509ce1477e3881802671af9f502af765a1d
상위 752b0432
하위 d03f6dc2, da1aeb27

백흠경이(가) 약 5년 전에 추가함

issue 366: 텍스트 영역 인식 및 텍스트 인식 속도 개선
issue 479: 심볼 인식 후 hit ratio를 툴팁에 표기
기타 - tesseract version 표기

Change-Id: I7c41eb524de4919bce6aed18c361dcacc09f8aeb

차이점 보기:

DTI_PID/DTI_PID/Commands/RemoveTextCommand.py
1 1
import os.path
2 2
import AbstractCommand
3

  
3 4
try:
4 5
    from PyQt5.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QBuffer, QRect, QRegExp
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QPainter, QColor, QPen, QBrush, QCursor, QTransform, QFont, QRegExpValidator, QValidator
6
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QPainter, QColor, QPen, QBrush, QCursor, QTransform, QFont, \
7
        QRegExpValidator, QValidator
6 8
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QMessageBox
7 9
except ImportError:
8 10
    try:
9 11
        from PyQt4.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QBuffer, QRect, QRegExp
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QPainter, QColor, QPen, QBrush, QCursor, QTransform, QFont, QRegExpValidator, QValidator
12
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QPainter, \
13
            QColor, QPen, QBrush, QCursor, QTransform, QFont, QRegExpValidator, QValidator
11 14
    except ImportError:
12 15
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
13 16
import sys
......
18 21
import io
19 22
import cv2
20 23

  
24

  
21 25
class RemoveTextCommand(AbstractCommand.AbstractCommand):
22 26
    '''
23 27
        @history    2018.05.09  Jeongwoo    Draw Rect on ±1 area
24 28
                    2018.06.11  Jeongwoo    Change method to set image (setImage → setPixmap/updateViewer)
25 29
    '''
30

  
26 31
    def __init__(self, imageViewer):
27 32
        super(RemoveTextCommand, self).__init__(imageViewer)
28
        self.name = 'RemoveText' 
29
        #self.imageViewer.setCursor(QCursor(Qt.ArrowCursor))
33
        self.name = 'RemoveText'
34
        # self.imageViewer.setCursor(QCursor(Qt.ArrowCursor))
30 35
        image = self.imageViewer.image()
31 36
        buffer = QBuffer()
32 37
        buffer.open(QBuffer.ReadWrite)
......
34 39
        pyImage = Image.open(io.BytesIO(buffer.data()))
35 40
        dst = cv2.cvtColor(np.array(pyImage), cv2.COLOR_BGR2GRAY)
36 41
        textDetector = TextDetector()
37
        self.textInfoList = textDetector.detectTextAreas(dst, (0, 0))
42
        self.textInfoList, _ = textDetector.detectTextAreas(dst, (0, 0))
38 43
        pixmap = self.imageViewer.pixmap()
39 44
        ADJUST = 1
40 45
        for textInfo in self.textInfoList:
......
42 47
            painter.begin(pixmap)
43 48
            painter.setPen(QColor(255, 255, 255))
44 49
            painter.setBrush(QColor(255, 255, 255))
45
            painter.drawRect(QRect(textInfo.getX()-ADJUST, textInfo.getY()-ADJUST, textInfo.getW()+ADJUST, textInfo.getH()+ADJUST))
50
            painter.drawRect(QRect(textInfo.getX() - ADJUST, textInfo.getY() - ADJUST, textInfo.getW() + ADJUST,
51
                                   textInfo.getH() + ADJUST))
46 52
            painter.end()
47 53
        pixmapHandle = self.imageViewer.getPixmapHandle()
48 54
        if pixmapHandle is not None:
49 55
            pixmapHandle.setPixmap(pixmap)
50 56
            self.imageViewer.setSceneRect(QRectF(pixmap.rect()))
51 57
            self.imageViewer.updateViewer()
52
    
58

  
53 59
    def execute(self, param):
54 60
        event = param[1]
55 61
        scenePos = param[2]
......
59 65
        pass
60 66

  
61 67
    def redo(self):
62
        pass
68
        pass

내보내기 Unified diff

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