Ask Your Question

vaxon's profile - activity

2016-09-28 06:13:25 -0600 received badge  Enthusiast
2016-09-26 11:22:25 -0600 asked a question Subdiv2d - points index

Hi kind people, I used this function for Delaunay triangulation:

// Draw delaunay triangles static void draw_delaunay( Mat& img, Subdiv2D& subdiv, Scalar delaunay_color ) {

vector<Vec6f> triangleList;
subdiv.getTriangleList(triangleList);
vector<Point> pt(3);
Size size = img.size();
Rect rect(0,0, size.width, size.height);

for( size_t i = 0; i < triangleList.size(); i++ )
{
    Vec6f t = triangleList[i];
    pt[0] = Point(cvRound(t[0]), cvRound(t[1]));
    pt[1] = Point(cvRound(t[2]), cvRound(t[3]));
    pt[2] = Point(cvRound(t[4]), cvRound(t[5]));

    // Draw rectangles completely inside the image.
    if ( rect.contains(pt[0]) && rect.contains(pt[1]) && rect.contains(pt[2]))
    {
        line(img, pt[0], pt[1], delaunay_color, 1, CV_AA, 0);
        line(img, pt[1], pt[2], delaunay_color, 1, CV_AA, 0);
        line(img, pt[2], pt[0], delaunay_color, 1, CV_AA, 0);
    }
}

}

I noticed that subdiv2d doesn't return index of points, only coordinates, can anyone please give me an idea on how to make a structure that can do that. Thank you in advance.

2016-09-10 06:42:40 -0600 asked a question Delaunay triangulation - edge flip?

I used this code: http://www.learnopencv.com/delaunay-t... for Delaunay triangulation, now I'm trying to figure out how to flip edges like this: http://i.imgur.com/RqAQKN5.png.

I found that there is a member function of subdiv2d called "swapedges" which potentionally does exactly what I need but I don't know how it's supposed to be used, I'm pretty new at C++ and OpenCV and if there's anyone who could help me by showing an example of how it should work, I would be very thankful.

Thanks in advance.