當前位置: 首頁>>代碼示例>>Python>>正文


Python pyclipper.CT_UNION屬性代碼示例

本文整理匯總了Python中pyclipper.CT_UNION屬性的典型用法代碼示例。如果您正苦於以下問題:Python pyclipper.CT_UNION屬性的具體用法?Python pyclipper.CT_UNION怎麽用?Python pyclipper.CT_UNION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pyclipper的用法示例。


在下文中一共展示了pyclipper.CT_UNION屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: join_polys

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import CT_UNION [as 別名]
def join_polys(polys, scale=True):
    """ Given a list of polygons, merge them (union) and return a list
        of merged polygons
    """
    pc = pyclipper.Pyclipper()

    if scale:
        polys = scale_to_clipper(polys)

    results=[]
    pc.AddPaths(polys, pyclipper.PT_SUBJECT, True)
    clip_polys = pc.Execute(pyclipper.CT_UNION, pyclipper.PFT_NONZERO,
        pyclipper.PFT_NONZERO)
    if scale:
        clip_polys = scale_from_clipper(clip_polys)
    results.extend([cp for cp in clip_polys])
    pc.Clear()
    return results 
開發者ID:deeplycloudy,項目名稱:glmtools,代碼行數:20,代碼來源:clipping.py

示例2: union

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import CT_UNION [as 別名]
def union(self, poly):
        # type: (Polygon) -> List[Polygon]
        """Union with another polygon.

        :param poly: The clip polygon.
        :returns: A list of Polygons.

        """
        clipper = self._prepare_clipper(poly)
        if not clipper:
            return []
        unions = clipper.Execute(pc.CT_UNION, pc.PFT_NONZERO, pc.PFT_NONZERO)

        return self._process(unions) 
開發者ID:jamiebull1,項目名稱:geomeppy,代碼行數:16,代碼來源:clippers.py

示例3: make_valid_pyclipper

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import CT_UNION [as 別名]
def make_valid_pyclipper(shape):
    """
    Use the pyclipper library to "union" a polygon on its own. This operation
    uses the even-odd rule to determine which points are in the interior of
    the polygon, and can reconstruct the orientation of the polygon from that.
    The pyclipper library is robust, and uses integer coordinates, so should
    not produce any additional degeneracies.

    Before cleaning the polygon, we remove all degenerate inners. This is
    useful to remove inners which have collapsed to points or lines, which can
    interfere with the cleaning process.
    """

    # drop all degenerate inners
    clean_shape = _drop_degenerate_inners(shape)

    pc = pyclipper.Pyclipper()

    try:
        pc.AddPaths(_coords(clean_shape), pyclipper.PT_SUBJECT, True)

        # note: Execute2 returns the polygon tree, not the list of paths
        result = pc.Execute2(pyclipper.CT_UNION, pyclipper.PFT_EVENODD)

    except pyclipper.ClipperException:
        return MultiPolygon([])

    return _polytree_to_shapely(result) 
開發者ID:tilezen,項目名稱:mapbox-vector-tile,代碼行數:30,代碼來源:polygon.py

示例4: iou_score

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import CT_UNION [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 
開發者ID:faustomorales,項目名稱:keras-ocr,代碼行數:32,代碼來源:evaluation.py

示例5: union

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import CT_UNION [as 別名]
def union(self,other, flat=False):
    """Returns a list of Bezier paths representing the union of the two input paths."""
    return self.clip(other, pyclipper.CT_UNION, flat) 
開發者ID:simoncozens,項目名稱:beziers.py,代碼行數:5,代碼來源:booleanoperationsmixin.py

示例6: unionPolygons

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import CT_UNION [as 別名]
def unionPolygons(pathList):
    import pyclipper
    pc = pyclipper.Pyclipper()
    for path in pathList: pc.AddPath(path, pyclipper.PT_SUBJECT, True)
    return pc.Execute(pyclipper.CT_UNION, pyclipper.PFT_NONZERO) 
開發者ID:easyw,項目名稱:RF-tools-KiCAD,代碼行數:7,代碼來源:viafence.py


注:本文中的pyclipper.CT_UNION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。