Note that there are some explanatory texts on larger screens.

plurals
  1. PODelaunay triangulation opencv c++
    primarykey
    data
    text
    <p>I made a delaunay triangulation with openCv thanks to this code : <a href="https://github.com/Itseez/opencv/blob/master/samples/cpp/delaunay2.cpp" rel="noreferrer">example code</a> (in partiluclar draw_subdiv). However, when I want to display the triangulation, I get the mesh and lines who don't belong to triangulation.This lines are due to the fact that the triangulation algorithm starts its job considering triangles posted at "infinity".</p> <p>Can you explain me how to draw only the mesh into the convex hull please (without this lines) ?</p> <p>display function :</p> <pre><code> void draw_subdiv(Mat &amp;img, Subdiv2D&amp; subdiv, Scalar delaunay_color) { vector&lt;Vec6f&gt; triangleList; subdiv.getTriangleList(triangleList); vector&lt;Point&gt; pt(3); for(size_t i = 0; i &lt; 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])); line(img, pt[0], pt[1], delaunay_color, 1); line(img, pt[1], pt[2], delaunay_color, 1); line(img, pt[2], pt[0], delaunay_color, 1); } } </code></pre> <p>main function :</p> <pre><code>Mat image = imread(argv[1], 1); ..... .... //creat delaunay Scalar delaunay_color(255, 255, 255), point_color(0,0,255); Rect rect(0,0,image.cols, image.rows); Subdiv2D subdiv(rect); for(int i = 0; i &lt; point.getDim(); ++i) { Point2f fp(point.getCoord()[i].real(), point.getCoord()[i].imag()); subdiv.insert(fp); } draw_subdiv(image, subdiv, delaunay_color); imwrite("data/delaunay.jpg", image); </code></pre> <p>Result:</p> <p><img src="https://i.stack.imgur.com/oBi2p.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload