프로젝트

일반

사용자정보

개정판 feee472b

IDfeee472b7fe0e9bc225d33196777764c1650e11f
상위 ef8dfda1
하위 820da2b5

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

issue #663: unknown item remain

Change-Id: I87d0111fed7dcb1e96d3d5e0122d9edc1256d916

차이점 보기:

DTI_PID/DTI_PID/RecognitionDialog.py
438 438
            thickness = int(windowSize[1] / 2)
439 439

  
440 440
            """
441
            area = app_doc_data.getArea('Drawing')
442

  
443
            # remove line from image
444
            imgDiff = np.zeros(app_doc_data.imgSrc.shape, np.uint8)
445
            imgDiff[round(area.y + 1):round(area.y + area.height),
446
                           round(area.x + 1):round(area.x + area.width)] = \
447
                app_doc_data.imgSrc[round(area.y + 1):round(area.y + area.height),
448
                           round(area.x + 1):round(area.x + area.width)]
449

  
450
            lines = app_doc_data.lines
451
            for line in lines:
452
                line.drawToImage(imgDiff, 255, thickness) if line.thickness is None else \
453
                    line.drawToImage(imgDiff, 255, line.thickness)
454
            # up to here
455

  
456
            imgNot = np.ones(imgDiff.shape, np.uint8)
457
            cv2.bitwise_not(imgDiff, imgNot)
458
            configs = app_doc_data.getConfigs('Filter', 'ErodeSize')
459
            kernel = int(configs[0].value) if 1 == len(configs) else 3
460
            imgNot = cv2.erode(imgNot, np.ones((kernel, kernel), np.uint8))
461
            imgNot = cv2.dilate(imgNot, np.ones((8 + kernel, 8 + kernel), np.uint8))
462

  
463
            contours, hierarchy = cv2.findContours(imgNot, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
464

  
465
            ##
466
            idx = 0
467
            ##
468
            smallContours = []
469
            minimumSize = app_doc_data.getConfigs('Filter', 'MinimumSize')
470
            for contour in contours:
471
                [x, y, w, h] = cv2.boundingRect(contour)
472

  
473
                # remove too small one
474
                if len(minimumSize) is 1:
475
                    if w * h < int(minimumSize[0].value) * int(minimumSize[0].value):
476
                        smallContours.append(contour)
477
                        idx += 1
478
                        continue
479

  
480
                # create unknown item
481
                epsilon = cv2.arcLength(contour, True) * 0.001
482
                approx = cv2.approxPolyDP(contour, epsilon, True)
483
                approx = [pt[0] for pt in approx]
484
                resultStr, resultList = self.determine_remain_object(idx, contours, imgNot)
485
                if resultStr == 'LineIndicator':
486
                    item = QEngineeringUnknownItem(approx, 'True', resultList[0], resultList[1])
487
                    app_doc_data.lineIndicators.append(item)
488
                elif resultStr == 'MissingLine':
489
                    idx += 1
490
                    continue
491
                elif resultStr == 'Unknown':
492
                    item = QEngineeringUnknownItem(approx, 'False')
493
                    app_doc_data.unknowns.append(item)
494
                item.area = 'Drawing'
495
                app_doc_data.allItems.append(item)
496
                idx += 1
497
                # up to here
498
            """
499

  
500
            """
441 501
            if app_doc_data.needReOpening is not None:
442 502
                app_doc_data.needReOpening = True
443 503
            """
......
514 574
            else:
515 575
                message = 'can\'t found {}'.format(diffFilePath)
516 576
                self.displayLog.emit(MessageType.Normal, message)
577

  
578

  
517 579
        except Exception as ex:
518 580
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
519 581
                                                           sys.exc_info()[-1].tb_lineno)

내보내기 Unified diff

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