Note that there are some explanatory texts on larger screens.

plurals
  1. PO"no matching function for call to min_element" when using a vector of CvPoints (opencv)
    text
    copied!<p>Here's my function to retrieve the corners of a rectangle, the input is a thresholded image (with a numberplate on it) and I want the output to be a vector (within a vector) with the cornerpoints of the plate. Ordered: left_up, right_up, right_bottom, left_bottom.</p> <p>I use openCV to find the contours (which works fine); after some filters, I use approxPoly to find rectangles. I find four points, which is great, but I want to order them. I thought the following would work: put all the point in a vector</p> <p>find min_element specified by compare function Left and erase from vector</p> <p>find another left element and erase, then determine which is up and which is down.</p> <p>the remaining two points are the right points.</p> <pre><code>bool left(CvPoint &amp;pt1, CvPoint &amp;pt2) { return pt1.x &lt; pt2.x; } bool up(CvPoint &amp;pt1, CvPoint &amp;pt2) { return pt1.y &lt; pt2.y; } std::vector&lt;std::vector&lt;CvPoint&gt; &gt; findNumberPlate(IplImage* img) { vector&lt;CvPoint&gt; numberplate; vector&lt;vector&lt;CvPoint&gt; &gt; numberplates_output; CvMemStorage* storage = cvCreateMemStorage(0); CvMemStorage* storage2 = cvCreateMemStorage(0); CvSeq* contour = 0; cvFindContours(img, storage, &amp;contour, sizeof (CvContour), CV_RETR_EXTERNAL); CvSeq* result = 0; for (CvSeq* c = contour; c != NULL; c = c-&gt;h_next) { double area_contour = cvContourArea(c, CV_WHOLE_SEQ); CvBox2D c_box = cvMinAreaRect2(c); double area_box = c_box.size.height * c_box.size.width; if (area_contour / area_box &gt; 0.83 &amp;&amp; area_contour &gt; 2000) { if (!storage2 == 0) cvClearMemStorage(storage2); else storage2 = cvCreateMemStorage(0); result = cvApproxPoly(c, sizeof (CvContour), storage2, CV_POLY_APPROX_DP, cvContourPerimeter(c)*0.03, 0); if (result-&gt;total == 4) { //find up/bottom &amp; left/right vector&lt;CvPoint&gt; points; for (int i = 0; i &lt; 4; i++) { CvPoint* tempPoint = (CvPoint*) cvGetSeqElem(result, i); points.push_back(cvPoint(tempPoint-&gt;x,tempPoint-&gt;y)); } vector&lt;CvPoint&gt;::iterator itLeft1 = std::min_element(points.begin(), points.end(), left); points.erase(itLeft1); vector&lt;CvPoint&gt;::iterator itLeft2 = std::min_element(points.begin(), points.end(), left); points.erase(itLeft2); vector&lt;CvPoint&gt;::iterator itLeftUp = std::min(itLeft1, itLeft2, left); vector&lt;CvPoint&gt;::iterator itLeftBottom = std::max(itLeft1, itLeft2, left); CvPoint left_up = *itLeftUp; CvPoint left_bottom = *itLeftBottom; vector&lt;CvPoint&gt;::iterator itRightUp = std::min(points.begin(), points.end(), up); vector&lt;CvPoint&gt;::iterator itRightBottom = std::max(points.begin(), points.end(), up); CvPoint right_up = *itRightUp; CvPoint right_bottom = *itRightBottom; //etc } </code></pre> <p>However, when using the function min_element &amp; max_element I get several errors I don't understand. </p> <pre><code>findNumberPlate.cpp:57: error: no matching function for call to ‘min_element(__gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;, __gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;, &lt;unresolved overloaded function type&gt;)’ findNumberPlate.cpp:59: error: no matching function for call to ‘min_element(__gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;, __gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;, &lt;unresolved overloaded function type&gt;)’ findNumberPlate.cpp:62: error: no matching function for call to ‘min(__gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;&amp;, __gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;&amp;, &lt;unresolved overloaded function type&gt;)’ findNumberPlate.cpp:63: error: no matching function for call to ‘max(__gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;&amp;, __gnu_cxx::__normal_iterator&lt;CvPoint*, std::vector&lt;CvPoint, std::allocator&lt;CvPoint&gt; &gt; &gt;&amp;, &lt;unresolved overloaded function type&gt;)’ </code></pre> <p>Can't I use CvPoints with min_element? Or... Can anyone help me? </p> <p>Thanks!</p>
 

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