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


Python pyclipper.PT_CLIP屬性代碼示例

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


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

示例1: _prepare_clipper

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import PT_CLIP [as 別名]
def _prepare_clipper(self, poly):
        """Prepare 3D polygons for clipping operations.

        :param poly: The clip polygon.
        :returns: A Pyclipper object.

        """
        if not self.is_coplanar(poly):
            return False
        poly1 = self.project_to_2D()
        poly2 = poly.project_to_2D()

        s1 = pc.scale_to_clipper(poly1.vertices_list)
        s2 = pc.scale_to_clipper(poly2.vertices_list)
        clipper = pc.Pyclipper()
        clipper.AddPath(s1, poly_type=pc.PT_SUBJECT, closed=True)
        clipper.AddPath(s2, poly_type=pc.PT_CLIP, closed=True)

        return clipper 
開發者ID:jamiebull1,項目名稱:geomeppy,代碼行數:21,代碼來源:clippers.py

示例2: iou_score

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import PT_CLIP [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

示例3: poly_intersect

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import PT_CLIP [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) 
開發者ID:lquirosd,項目名稱:P2PaLA,代碼行數:12,代碼來源:metrics.py

示例4: clipPolygonWithPolygons

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

示例5: clip_poly_pair

# 需要導入模塊: import pyclipper [as 別名]
# 或者: from pyclipper import PT_CLIP [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 
開發者ID:deeplycloudy,項目名稱:glmtools,代碼行數:15,代碼來源:clipping.py


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