Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def offset(paths, amount):
pco = pyclipper.PyclipperOffset()
pco.ArcTolerance = SCALING_FACTOR / 40
paths = pyclipper.scale_to_clipper(paths, SCALING_FACTOR)
pco.AddPaths(paths, pyclipper.JT_SQUARE, pyclipper.ET_CLOSEDPOLYGON)
outpaths = pco.Execute(amount * SCALING_FACTOR)
outpaths = pyclipper.scale_from_clipper(outpaths, SCALING_FACTOR)
return outpaths
def llr_polyscore(cnt, pts, cen, alfa=5, beta=2):
a = cnt[0]; b = cnt[1]
c = cnt[2]; d = cnt[3]
# (1) # za mala powierzchnia
area = cv2.contourArea(cnt)
t2 = area < (4 * alfa * alfa) * 5
if t2: return 0
gamma = alfa/1.5#alfa**(1/2)
#print("ALFA", alfa)
# (2) # za malo punktow
pco = pyclipper.PyclipperOffset()
pco.AddPath(cnt, pyclipper.JT_MITER, pyclipper.ET_CLOSEDPOLYGON)
pcnt = matplotlib.path.Path(pco.Execute(gamma)[0]) # FIXME: alfa/1.5
wtfs = pcnt.contains_points(pts)
pts_in = min(np.count_nonzero(wtfs), 49)
t1 = pts_in < min(len(pts), 49) - 2 * beta - 1
if t1: return 0
A = pts_in
B = area
# (3)
# FIXME: punkty za kwadratowosci? (przypadki z L shape)
nln = lambda l1, x, dx: \
np.linalg.norm(np.cross(na(l1[1])-na(l1[0]),
na(l1[0])-na( x)))/dx
pcnt_in = []; i = 0
for pt in wtfs: