개정판 1bdb1ec8
issue #000: fix symbol editor remove text
DTI_PID/DTI_PID/Commands/RemoveTextCommand.py | ||
---|---|---|
12 | 12 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
13 | 13 |
import sys |
14 | 14 |
from AppDocData import AppDocData |
15 |
import tesseract_ocr_module as TOCR
|
|
15 |
from TextDetector import TextDetector
|
|
16 | 16 |
import numpy as np |
17 | 17 |
from PIL import Image |
18 | 18 |
import io |
19 |
import cv2 |
|
19 | 20 |
|
20 | 21 |
class RemoveTextCommand(AbstractCommand.AbstractCommand): |
21 | 22 |
''' |
... | ... | |
25 | 26 |
def __init__(self, imageViewer): |
26 | 27 |
super(RemoveTextCommand, self).__init__(imageViewer) |
27 | 28 |
self.name = 'RemoveText' |
28 |
self.imageViewer.setCursor(QCursor(Qt.ArrowCursor)) |
|
29 |
#self.imageViewer.setCursor(QCursor(Qt.ArrowCursor))
|
|
29 | 30 |
image = self.imageViewer.image() |
30 | 31 |
buffer = QBuffer() |
31 | 32 |
buffer.open(QBuffer.ReadWrite) |
32 | 33 |
image.save(buffer, "PNG") |
33 | 34 |
pyImage = Image.open(io.BytesIO(buffer.data())) |
34 |
self.textInfoList = TOCR.getCharactersInfo(np.array(pyImage), (0, 0)) |
|
35 |
dst = cv2.cvtColor(np.array(pyImage), cv2.COLOR_BGR2GRAY) |
|
36 |
textDetector = TextDetector() |
|
37 |
self.textInfoList = textDetector.detectTextAreas(dst, (0, 0)) |
|
35 | 38 |
pixmap = self.imageViewer.pixmap() |
36 | 39 |
ADJUST = 1 |
37 | 40 |
for textInfo in self.textInfoList: |
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
57 | 57 |
self.newSym = None |
58 | 58 |
|
59 | 59 |
self.setWindowTitle('심볼 편집기') |
60 |
#self.ui.removeTextButton.setHidden(True) |
|
60 | 61 |
except Exception as ex: |
61 | 62 |
from App import App |
62 | 63 |
|
DTI_PID/DTI_PID/TextDetector.py | ||
---|---|---|
61 | 61 |
minSize = 5 |
62 | 62 |
|
63 | 63 |
contourImg = np.ones(imgGray.shape, np.uint8) * 255 |
64 |
print(type(imgGray)) |
|
65 |
print(imgGray) |
|
64 | 66 |
binaryImg,mask = cv2.threshold(imgGray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU) |
65 | 67 |
|
66 | 68 |
image, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) |
내보내기 Unified diff