MCPcopy
hub / github.com/Charmve/Surface-Defect-Detection / polygon_from_points

Function polygon_from_points

DeepPCB/evaluation/script.py:67–88  ·  view source on GitHub ↗

Returns a Polygon object to use with the Polygon2 class from a list of 8 points: x1,y1,x2,y2,x3,y3,x4,y4

(points,correctOffset=False)

Source from the content-addressed store, hash-verified

65 globals()[alias] = importlib.import_module(module)
66
67 def polygon_from_points(points,correctOffset=False):
68 """
69 Returns a Polygon object to use with the Polygon2 class from a list of 8 points: x1,y1,x2,y2,x3,y3,x4,y4
70 """
71
72 if correctOffset: #this will substract 1 from the coordinates that correspond to the xmax and ymax
73 points[2] -= 1
74 points[4] -= 1
75 points[5] -= 1
76 points[7] -= 1
77
78 resBoxes=np.empty([1,8],dtype='int32')
79 resBoxes[0,0]=int(points[0])
80 resBoxes[0,4]=int(points[1])
81 resBoxes[0,1]=int(points[2])
82 resBoxes[0,5]=int(points[3])
83 resBoxes[0,2]=int(points[4])
84 resBoxes[0,6]=int(points[5])
85 resBoxes[0,3]=int(points[6])
86 resBoxes[0,7]=int(points[7])
87 pointMat = resBoxes[0].reshape([2,4]).T
88 return plg.Polygon( pointMat)
89
90 def rectangle_to_polygon(rect):
91 resBoxes=np.empty([1,8],dtype='int32')

Callers 1

evaluate_methodFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected