프로젝트

일반

사용자정보

개정판 459af1ad

ID459af1ad3dfe91d499c2d764f240dc0a7fa0fa76
상위 f24a438f
하위 ee2cdc95, fa0b96b3

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

issue #663: improve line detection

Change-Id: I2590e654c71fa2ad121b920e846d70f30db88c6d

차이점 보기:

DTI_PID/DTI_PID/LineDetector.py
436 436
            self.correct_angle(connectedLines)
437 437

  
438 438
            # remove overlap line
439
            #for long_line in sorted(connectedLines, key=lambda param: param.length(), reverse=True):
440
            #    for short_line in sorted(connectedLines, key=lambda param: param.length()):
441
            #        pass
439
            merged = True
440
            while merged:
441
                merged = False
442
                
443
                for long_line in connectedLines:#sorted(connectedLines, key=lambda param: math.sqrt((param[0][0] - param[1][0]) ** 2 + (param[0][1] - param[1][1]) ** 2), reverse=True):
444
                    l_v = LineDetector.is_vertical([long_line[0][0], long_line[0][1], long_line[1][0], long_line[1][1]])
445
                    dx_dy = long_line[0][0] - long_line[1][0] if l_v else long_line[0][1] - long_line[1][1]
446
                    if abs(dx_dy) > 3:
447
                        continue
448
                    l_x_y = [long_line[0][1], long_line[1][1]] if l_v else [long_line[0][0], long_line[1][0]]
449
                    l_x_y = sorted(l_x_y)
450

  
451
                    for short_line in connectedLines:#sorted(connectedLines, key=lambda param: math.sqrt((param[0][0] - param[1][0]) ** 2 + (param[0][1] - param[1][1]) ** 2)):
452
                        if long_line == short_line:
453
                            break
454

  
455
                        s_v = LineDetector.is_vertical([short_line[0][0], short_line[0][1], short_line[1][0], short_line[1][1]])
456
                        dx_dy = short_line[0][0] - short_line[1][0] if s_v else short_line[0][1] - short_line[1][1]
457
                        if abs(dx_dy) > 3 or l_v ^ s_v:
458
                            continue
459

  
460
                        distance_x_y = long_line[0][0] - short_line[0][0] if l_v else long_line[0][1] - short_line[0][1]
461
                        if abs(distance_x_y) > toler:
462
                            continue
463
                        s_x_y = [short_line[0][1], short_line[1][1]] if l_v else [short_line[0][0], short_line[1][0]]
464
                        s_x_y = sorted(s_x_y)
465

  
466
                        if max(l_x_y) < min(s_x_y) or max(s_x_y) < min(l_x_y):
467
                            overlap = False
468
                        else:
469
                            overlap = True
470

  
471
                        if not overlap:
472
                            continue
473
                        else:
474
                            min_x_y, max_x_y = min(l_x_y + s_x_y), max(l_x_y + s_x_y)
475
                            long_line[0] = [long_line[0][0], min_x_y] if l_v else [min_x_y, long_line[0][1]]
476
                            long_line[1] = [long_line[1][0], max_x_y] if l_v else [max_x_y, long_line[1][1]]
477
                            merged = True
478
                            connectedLines.remove(short_line)
479
                            break
480

  
481
                    if merged:# or long_line == short_line:
482
                            break
442 483
            # up to here
443 484
        except Exception as ex:
444 485
            from App import App
DTI_PID/DTI_PID/QtImageViewer.py
270 270
                               self.aspectRatioMode)  # Show entire image (use current aspect ratio mode).
271 271

  
272 272
    def zoomImageInit(self):
273
        #from EngineeringConnectorItem import QEngineeringConnectorItem
274

  
273 275
        if self.hasImage():
274 276
            self.zoomStack = []
275 277
            self.updateViewer()
276 278
            self.setCursor(QCursor(Qt.ArrowCursor))
277 279

  
280
            #for conn in [item for item in self.scene().items() if type(item) is QEngineeringConnectorItem]:
281
            #    conn.setVisible(False)
282

  
278 283
    '''
279 284
        @brief      Zoom in & out image
280 285
        @author     Jeongwoo
DTI_PID/DTI_PID/tesseract_ocr_module.py
238 238

  
239 239
def text_filter(text):
240 240
    """ fix input text """
241
    text = text.replace('—', '-').replace('--', '-')
241
    text = text.replace('—', '-').replace('--', '-').replace('”', '"')
242 242
    return text

내보내기 Unified diff

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