개정판 820da2b5
issue #633: recognition test
Change-Id: I3a066a86c787a8b8dd3a1b111506f8a17ad08820
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
437 | 437 |
|
438 | 438 |
thickness = int(windowSize[1] / 2) |
439 | 439 |
|
440 |
""" |
|
441 | 440 |
area = app_doc_data.getArea('Drawing') |
441 |
diffFilePath = os.path.join(project.getTempPath(), "DIFF_" + os.path.basename(path)) |
|
442 | 442 |
|
443 | 443 |
# remove line from image |
444 |
imgDiff = np.zeros(app_doc_data.imgSrc.shape, np.uint8)
|
|
444 |
imgDiff = np.ones(app_doc_data.imgSrc.shape, np.uint8) * 255
|
|
445 | 445 |
imgDiff[round(area.y + 1):round(area.y + area.height), |
446 | 446 |
round(area.x + 1):round(area.x + area.width)] = \ |
447 | 447 |
app_doc_data.imgSrc[round(area.y + 1):round(area.y + area.height), |
... | ... | |
452 | 452 |
line.drawToImage(imgDiff, 255, thickness) if line.thickness is None else \ |
453 | 453 |
line.drawToImage(imgDiff, 255, line.thickness) |
454 | 454 |
# up to here |
455 |
cv2.imwrite(diffFilePath, imgDiff) |
|
455 | 456 |
|
456 | 457 |
imgNot = np.ones(imgDiff.shape, np.uint8) |
457 | 458 |
cv2.bitwise_not(imgDiff, imgNot) |
... | ... | |
495 | 496 |
app_doc_data.allItems.append(item) |
496 | 497 |
idx += 1 |
497 | 498 |
# up to here |
498 |
""" |
|
499 | 499 |
|
500 | 500 |
""" |
501 | 501 |
if app_doc_data.needReOpening is not None: |
502 | 502 |
app_doc_data.needReOpening = True |
503 | 503 |
""" |
504 | 504 |
|
505 |
""" |
|
505 | 506 |
diffFilePath = os.path.join(project.getTempPath(), "DIFF_" + os.path.basename(path)) |
506 | 507 |
if os.path.isfile(diffFilePath): |
507 | 508 |
imgDiff = cv2.threshold(cv2.cvtColor(cv2.imread(diffFilePath, 1), cv2.COLOR_BGR2GRAY), 0, 255, |
... | ... | |
574 | 575 |
else: |
575 | 576 |
message = 'can\'t found {}'.format(diffFilePath) |
576 | 577 |
self.displayLog.emit(MessageType.Normal, message) |
577 |
|
|
578 |
""" |
|
578 | 579 |
|
579 | 580 |
except Exception as ex: |
580 | 581 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
2218 | 2219 |
|
2219 | 2220 |
try: |
2220 | 2221 |
app_doc_data = AppDocData.instance() |
2222 |
imgOriginal = app_doc_data.imgSrc |
|
2223 |
|
|
2224 |
# remove not drawing area |
|
2225 |
configs = app_doc_data.getConfigs('{} Equipment Desc Area'.format(app_doc_data.imgName)) |
|
2226 |
for config in configs: |
|
2227 |
found = re.findall('\\d+', config.value) |
|
2228 |
if len(found) == 4: |
|
2229 |
cv2.rectangle(imgOriginal, (int(found[0]), int(found[1])), |
|
2230 |
(int(found[0]) + int(found[2]), int(found[1]) + int(found[3])), 255, -1) |
|
2231 |
|
|
2232 |
configs = app_doc_data.getConfigs('{} Typical Area'.format(app_doc_data.imgName)) |
|
2233 |
for config in configs: |
|
2234 |
found = re.findall('\\d+', config.value) |
|
2235 |
if len(found) == 4: |
|
2236 |
cv2.rectangle(imgOriginal, (int(found[0]), int(found[1])), |
|
2237 |
(int(found[0]) + int(found[2]), int(found[1]) + int(found[3])), 255, -1) |
|
2238 |
|
|
2239 |
noteArea = app_doc_data.getArea('Note') |
|
2240 |
if noteArea is not None: |
|
2241 |
noteArea.img = app_doc_data.imgSrc[round(noteArea.y):round(noteArea.y + noteArea.height), |
|
2242 |
round(noteArea.x):round(noteArea.x + noteArea.width)].copy() |
|
2243 |
cv2.rectangle(imgOriginal, (round(noteArea.x), round(noteArea.y)), |
|
2244 |
(round(noteArea.x + noteArea.width), round(noteArea.y + noteArea.height)), 255, -1) |
|
2245 |
# up to here |
|
2246 |
|
|
2247 |
""" |
|
2221 | 2248 |
if os.path.isfile(orgImagePath) and os.path.isfile(recImagePath): |
2222 | 2249 |
imgOriginal = \ |
2223 | 2250 |
cv2.threshold(Worker.cvtGrayImage(cv2.imread(orgImagePath, 1)), 127, 255, cv2.THRESH_BINARY)[1] |
... | ... | |
2271 | 2298 |
|
2272 | 2299 |
project = app_doc_data.getCurrentProject() |
2273 | 2300 |
cv2.imwrite(os.path.join(project.getTempPath(), "DIFF_" + os.path.basename(orgImagePath)), imgDiff) |
2301 |
""" |
|
2274 | 2302 |
except Exception as ex: |
2275 | 2303 |
from App import App |
2276 | 2304 |
|
내보내기 Unified diff