How to use the pyclipper.ET_CLOSEDPOLYGON function in pyclipper

To help you get started, we’ve selected a few pyclipper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github revarbat / mandoline-py / mandoline / geometry2d.py View on Github external
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
github maciejczyzewski / neural-chessboard / llr.py View on Github external
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: