Ask Your Question
0

How to find Delaunay Neighborhood of all the vertices in OpenCV.

asked 2016-06-03 01:20:45 -0600

Delaunay Neighborhood of a vertex is its immediate spatial neighbors in the Delaunay Triangulation i.e. the vertices which share an edge with that vertex. I wish to find Delaunay Neighborhood for all the points and store it in a vector<vector<point2f>>.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-03-31 10:29:10 -0600

void getNeigs(const int vtx_idx, std::vector<cv::Point2f>& neigs) const{
    neigs.clear();
    if((vtx_idx < 4) || (vtx_idx >= vtx.size())){
        return;
    }
    const Vertex& vertex = vtx.at(vtx_idx);
    if(vertex.isfree() || vertex.isvirtual()){
        return;
    }
    const int first_edge = vertex.firstEdge;
    const int right_edge = getEdge(first_edge, NEXT_AROUND_RIGHT);
    int edge = right_edge;
    const size_t MAX_ITERATION = vtx.size();
    for(size_t iteration=0; iteration!=MAX_ITERATION; ++iteration){
        const int neig = edgeOrg(edge);
        neigs.emplace_back(vtx.at(neig).pt);
        edge = getEdge(edge, NEXT_AROUND_DST);
        if(edge == right_edge){
            return;
        }
    }
}
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-06-03 01:20:45 -0600

Seen: 248 times

Last updated: Jun 03 '16