Ejemplo n.º 1
0
def paint_voronoi( subdiv, img ):
    cv.CalcSubdivVoronoi2D( subdiv );
    for edge in subdiv.edges:
        # left
        draw_subdiv_facet( img, cv.Subdiv2DRotateEdge( edge, 1 ));
       # right
        draw_subdiv_facet( img, cv.Subdiv2DRotateEdge( edge, 3 ));
Ejemplo n.º 2
0
    print "Delaunay triangulation will be build now interactively."
    print "To stop the process, press any key\n"

    for i in range(200):
        fp = (random.random() * (rect[2] - 10) + 5,
              random.random() * (rect[3] - 10) + 5)

        locate_point(subdiv, fp, img, active_facet_color)
        cv.ShowImage(win, img)

        if (cv.WaitKey(100) >= 0):
            break

        cv.SubdivDelaunay2DInsert(subdiv, fp)
        cv.CalcSubdivVoronoi2D(subdiv)
        cv.Set(img, bkgnd_color)
        draw_subdiv(img, subdiv, delaunay_color, voronoi_color)
        cv.ShowImage(win, img)

        if (cv.WaitKey(100) >= 0):
            break

    cv.Set(img, bkgnd_color)
    paint_voronoi(subdiv, img)
    cv.ShowImage(win, img)

    cv.WaitKey(0)

    cv.DestroyWindow(win)