개정판 c19b5a16
issue #631: 한글이 포함된 파일 지원(원인: cv2의 imread 함수가 unicode를 지원하지 않음)
Change-Id: I672b587d3ed9cd0bba639808ff40bb0be20a4cd6
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
270 | 270 |
self._imgFilePath = path |
271 | 271 |
self.imgName = os.path.splitext(os.path.basename(self._imgFilePath))[0] |
272 | 272 |
|
273 |
@staticmethod |
|
274 |
def my_imread(filePath): |
|
275 |
""" read a file which's name contains unicode string : ref http://devdoftech.co.kr:82/redmine/issues/631 """ |
|
276 |
import numpy as np |
|
277 |
import cv2 |
|
278 |
|
|
279 |
stream = open(filePath.encode('utf-8') , 'rb') |
|
280 |
_bytes = bytearray(stream.read()) |
|
281 |
numpyArray = np.asarray(_bytes, dtype=np.uint8) |
|
282 |
return cv2.imdecode(numpyArray, cv2.IMREAD_UNCHANGED) |
|
283 |
|
|
273 | 284 |
''' |
274 | 285 |
@brief getter of imgSrc |
275 | 286 |
@author humkyung |
... | ... | |
281 | 292 |
import numpy as np |
282 | 293 |
|
283 | 294 |
if self._imgSrc is None and self._imgFilePath is not None and os.path.isfile(self._imgFilePath): |
284 |
self._imgSrc = cv2.cvtColor(cv2.imread(self._imgFilePath), cv2.COLOR_BGR2GRAY)
|
|
295 |
self._imgSrc = cv2.cvtColor(AppDocData.my_imread(self._imgFilePath), cv2.COLOR_BGR2GRAY)
|
|
285 | 296 |
kernel = np.array([[-1,-1,-1], |
286 | 297 |
[-1, 9,-1], |
287 | 298 |
[-1,-1,-1]]) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1980 | 1980 |
|
1981 | 1981 |
# parse notes |
1982 | 1982 |
for textInfoMap in otherTextInfoList: |
1983 |
if textInfoMap[0]=='Note': |
|
1983 |
if textInfoMap[0]=='Note' or textInfoMap[1] is None:
|
|
1984 | 1984 |
pass |
1985 | 1985 |
|
1986 | 1986 |
for textInfo in textInfoMap[1]: |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
19 | 19 |
from EngineeringLineItem import QEngineeringLineItem |
20 | 20 |
from EngineeringTextItem import QEngineeringTextItem |
21 | 21 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
22 |
from TrainingEditorDialog import QTrainingEditorDialog |
|
23 | 22 |
from SymbolSvgItem import SymbolSvgItem |
24 | 23 |
|
25 | 24 |
__author__ = "Marcel Goldschen-Ohm <marcel.goldschen@gmail.com>" |
... | ... | |
184 | 183 |
except Exception as ex: |
185 | 184 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
186 | 185 |
|
187 |
def my_imread(self, filePath): |
|
188 |
""" read a file which's name contains unicode string : ref http://devdoftech.co.kr:82/redmine/issues/631 """ |
|
189 |
import numpy as np |
|
190 |
import cv2 |
|
191 |
|
|
192 |
stream = open(filePath.encode('utf-8') , 'rb') |
|
193 |
_bytes = bytearray(stream.read()) |
|
194 |
numpyArray = np.asarray(_bytes, dtype=np.uint8) |
|
195 |
return cv2.imdecode(numpyArray, cv2.IMREAD_UNCHANGED) |
|
196 |
|
|
197 | 186 |
''' |
198 | 187 |
@brief open a image file selected by user |
199 | 188 |
@author |
... | ... | |
216 | 205 |
elif QT_VERSION_STR[0] == '5': |
217 | 206 |
fileName, dummy = QFileDialog.getOpenFileName(self, "Open image file", os.getcwd() if folder == '' else folder, "Image files(*.png *.jpg)", options=options) |
218 | 207 |
if len(fileName) and os.path.isfile(fileName): |
219 |
cvImg = cv2.cvtColor(self.my_imread(fileName), cv2.COLOR_BGR2GRAY)
|
|
208 |
cvImg = cv2.cvtColor(AppDocData.my_imread(fileName), cv2.COLOR_BGR2GRAY)
|
|
220 | 209 |
#blur = cv2.GaussianBlur(cvImg, (5,5),0) |
221 | 210 |
cvImg = cv2.threshold(cvImg, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
222 | 211 |
|
... | ... | |
391 | 380 |
@history send escape key event to command |
392 | 381 |
''' |
393 | 382 |
def keyPressEvent(self, event): |
383 |
from TrainingEditorDialog import QTrainingEditorDialog |
|
384 |
|
|
394 | 385 |
try: |
395 | 386 |
if event.key() == Qt.Key_Delete: |
396 | 387 |
for item in [item for item in self.scene.selectedItems() if hasattr(item, 'transfer')]: |
DTI_PID/DTI_PID/TrainingEditorDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
1 | 2 |
import sys |
2 | 3 |
import os, time, datetime |
3 | 4 |
from PyQt5.QtCore import * |
내보내기 Unified diff