개정판 563df4f4
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