프로젝트

일반

사용자정보

개정판 563df4f4

ID563df4f49ec187f320219a6e42f3470d4a50d939
상위 13a0b568
하위 617a14d2

humkyung 이(가) 6년 이상 전에 추가함

Implementing issue #480: Line 인식
- 불필요한 선들이 많이 인식되는 부분을 수정

차이점 보기:

DTI_PID/DTI_PID/DTI_PID.py
860 860
                humkyung 2018.06.11 add drawing path to parameter and write recognized lines to image
861 861
'''
862 862
def recognizeLine(path, listWidget, graphicsView):
863
    import shapely
863 864
    from SymbolSvgItem import SymbolSvgItem
864 865
    from QEngineeringFlowArrowItem import QEngineeringFlowArrowItem
865 866
    from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem
......
906 907
            # connect line to line
907 908
            try:
908 909
                for line in connectedLines[:]:
909
                    matches = [it for it in connectedLines if (line != it) and (not detector.isParallel(line, it))]
910
                    for match in matches:
911
                        detector.connectLineToLine(match, line)
910
                    matches = [it for it in connectedLines if (it is not line) and (not detector.isParallel(line, it))]
911

  
912
                    # get closest line
913
                    minDist = None
914
                    selected = None
915
                    shapelyLine = shapely.geometry.LineString(line)
916
                    for it in matches:
917
                        ptStart = it.startPoint()
918
                        dist = line.distance(shapely.geometry.Point(ptStart[0], ptStart[1]))
919
                        if minDist is None or dist < minDist:
920
                            minDist = dist
921
                            selected = it
922
                        ptEnd = it.endPoint()
923
                        dist = line.distance(shapely.geometry.Point(ptEnd[0], ptEnd[1]))
924
                        if minDist is None or dist < minDist:
925
                            minDist = dist
926
                            selected = it
927
                    # up to here
928

  
929
                    if selected is not None:
930
                        detector.connectLineToLine(selected, line)
912 931
            except Exception as ex:
913 932
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
914 933
            # up to here

내보내기 Unified diff

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