本文整理汇总了Python中pyclipper.CT_INTERSECTION属性的典型用法代码示例。如果您正苦于以下问题:Python pyclipper.CT_INTERSECTION属性的具体用法?Python pyclipper.CT_INTERSECTION怎么用?Python pyclipper.CT_INTERSECTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyclipper
的用法示例。
在下文中一共展示了pyclipper.CT_INTERSECTION属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: intersect
# 需要导入模块: import pyclipper [as 别名]
# 或者: from pyclipper import CT_INTERSECTION [as 别名]
def intersect(self, poly):
# type: (Polygon) -> List[Polygon]
"""Intersect with another polygon.
:param poly: The clip polygon.
:returns: False if no intersection, otherwise a list of Polygons representing each intersection.
"""
clipper = self._prepare_clipper(poly)
if not clipper:
return []
intersections = clipper.Execute(
pc.CT_INTERSECTION, pc.PFT_NONZERO, pc.PFT_NONZERO
)
return self._process(intersections)
示例2: iou_score
# 需要导入模块: import pyclipper [as 别名]
# 或者: from pyclipper import CT_INTERSECTION [as 别名]
def iou_score(box1, box2):
"""Returns the Intersection-over-Union score, defined as the area of
the intersection divided by the intersection over the union of
the two bounding boxes. This measure is symmetric.
Args:
box1: The coordinates for box 1 as a list of (x, y) coordinates
box2: The coordinates for box 2 in same format as box1.
"""
if len(box1) == 2:
x1, y1 = box1[0]
x2, y2 = box1[1]
box1 = np.array([[x1, y1], [x2, y1], [x2, y2], [x1, y2]])
if len(box2) == 2:
x1, y1 = box2[0]
x2, y2 = box2[1]
box2 = np.array([[x1, y1], [x2, y1], [x2, y2], [x1, y2]])
if any(cv2.contourArea(np.int32(box)[:, np.newaxis, :]) == 0 for box in [box1, box2]):
warnings.warn('A box with zero area was detected.')
return 0
pc = pyclipper.Pyclipper()
pc.AddPath(np.int32(box1), pyclipper.PT_SUBJECT, closed=True)
pc.AddPath(np.int32(box2), pyclipper.PT_CLIP, closed=True)
intersection_solutions = pc.Execute(pyclipper.CT_INTERSECTION, pyclipper.PFT_EVENODD,
pyclipper.PFT_EVENODD)
union_solutions = pc.Execute(pyclipper.CT_UNION, pyclipper.PFT_EVENODD, pyclipper.PFT_EVENODD)
union = sum(cv2.contourArea(np.int32(points)[:, np.newaxis, :]) for points in union_solutions)
intersection = sum(
cv2.contourArea(np.int32(points)[:, np.newaxis, :]) for points in intersection_solutions)
return intersection / union
示例3: intersection
# 需要导入模块: import pyclipper [as 别名]
# 或者: from pyclipper import CT_INTERSECTION [as 别名]
def intersection(self,other, flat=False):
"""Returns a list of Bezier paths representing the intersection of the two input paths."""
return self.clip(other, pyclipper.CT_INTERSECTION, flat)
示例4: poly_intersect
# 需要导入模块: import pyclipper [as 别名]
# 或者: from pyclipper import CT_INTERSECTION [as 别名]
def poly_intersect(subj, clip):
"""
"""
pc = pyclipper.Pyclipper()
pc.AddPath(clip, pyclipper.PT_CLIP, True)
pc.AddPath(subj, pyclipper.PT_SUBJECT, True)
solution = pc.Execute(
pyclipper.CT_INTERSECTION, pyclipper.PFT_EVENODD, pyclipper.PFT_EVENODD
)
return np.array(solution)
示例5: clip_poly_pair
# 需要导入模块: import pyclipper [as 别名]
# 或者: from pyclipper import CT_INTERSECTION [as 别名]
def clip_poly_pair(pc, p, q):
""""
pc: an instance of pyclipper.Pyclipper.
p: the polygon by which to clip other polygon q.
pc and p may be held fixed through use of functools.partial so that
multiple q may be clipped by p.
"""
pc.Clear()
pc.AddPath(q, pyclipper.PT_SUBJECT, True)
pc.AddPath(p, pyclipper.PT_CLIP, True)
clip_polys = pc.Execute(clip_type=pyclipper.CT_INTERSECTION)
return clip_polys