Esempio n. 1
0
def draw_subdiv_facet(img, edge):

    t = edge
    count = 0

    # count number of edges in facet
    while count == 0 or t != edge:
        count += 1
        t = cv.Subdiv2DGetEdge(t, cv.CV_NEXT_AROUND_LEFT)

    buf = []

    # gather points
    t = edge
    for i in range(count):
        assert t > 4
        pt = cv.Subdiv2DEdgeOrg(t)
        if not pt:
            break
        buf.append((cv.Round(pt.pt[0]), cv.Round(pt.pt[1])))
        t = cv.Subdiv2DGetEdge(t, cv.CV_NEXT_AROUND_LEFT)

    if (len(buf) == count):
        pt = cv.Subdiv2DEdgeDst(cv.Subdiv2DRotateEdge(edge, 1))
        cv.FillConvexPoly(
            img, buf,
            cv.RGB(random.randrange(256), random.randrange(256),
                   random.randrange(256)), cv.CV_AA, 0)
        cv.PolyLine(img, [buf], 1, cv.RGB(0, 0, 0), 1, cv.CV_AA, 0)
        draw_subdiv_point(img, pt.pt, cv.RGB(0, 0, 0))
Esempio n. 2
0
def draw_subdiv_edge(img, edge, color):
    org_pt = cv.Subdiv2DEdgeOrg(edge)
    dst_pt = cv.Subdiv2DEdgeDst(edge)

    if org_pt and dst_pt:

        org = org_pt.pt
        dst = dst_pt.pt

        iorg = (cv.Round(org[0]), cv.Round(org[1]))
        idst = (cv.Round(dst[0]), cv.Round(dst[1]))

        cv.Line(img, iorg, idst, color, 1, cv.CV_AA, 0)
Esempio n. 3
0
def draw_subdiv_edge( img, edge, color ):
    org_pt = cv.Subdiv2DEdgeOrg(edge);
    dst_pt = cv.Subdiv2DEdgeDst(edge);
    if org_pt and dst_pt :