Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def orient_path(path, dir):
orient = pyclipper.Orientation(path)
path = pyclipper.scale_to_clipper(path, SCALING_FACTOR)
if orient != dir:
path = pyclipper.ReversePath(path)
path = pyclipper.scale_from_clipper(path, SCALING_FACTOR)
return path
:param tags:
:return:
'''
(h, w) = input_size
if polys.shape[0] == 0:
return [], []
polys[:, :, 0] = np.clip(polys[:, :, 0], 0, w-1)
polys[:, :, 1] = np.clip(polys[:, :, 1], 0, h-1)
validated_polys = []
validated_tags = []
for poly, tag in zip(polys, tags):
if abs(pyclipper.Area(poly)) < 1:
continue
#clockwise
if pyclipper.Orientation(poly):
poly = poly[::-1]
validated_polys.append(poly)
validated_tags.append(tag)
return np.array(validated_polys), np.array(validated_tags)
:param tags:
:return:
'''
(h, w) = xxx_todo_changeme
if polys.shape[0] == 0:
return [], []
polys[:, :, 0] = np.clip(polys[:, :, 0], 0, w-1)
polys[:, :, 1] = np.clip(polys[:, :, 1], 0, h-1)
validated_polys = []
validated_tags = []
for poly, tag in zip(polys, tags):
if abs(pyclipper.Area(poly))<1:
continue
#clockwise
if pyclipper.Orientation(poly):
poly = poly[::-1]
validated_polys.append(poly)
validated_tags.append(tag)
return np.array(validated_polys), np.array(validated_tags)
def __init__(self, pointList):
if pointList[0] == pointList[-1]:
del pointList[-1]
self.clockwise = not pyclipper.Orientation(pointList)
self.segments = [
OutputSegment(
segmentType="flat",
points=[point]
) for point in pointList
]