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))
def locate_point( subdiv, fp, img, active_color ): (res, e0) = cv.Subdiv2DLocate( subdiv, fp ); if res in [ cv.CV_PTLOC_INSIDE, cv.CV_PTLOC_ON_EDGE ]: e = e0 while True: draw_subdiv_edge( img, e, active_color ); e = cv.Subdiv2DGetEdge(e, cv.CV_NEXT_AROUND_LEFT); if e == e0: break draw_subdiv_point( img, fp, active_color );