title: opencv Contour Removal
body: <p>I am having an issue with contours in opencv, mainly with how they are handled. for reference look at this tutorial:</p>
  
  <p><a href="http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/moments/moments.html#moments" rel="nofollow">http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/moments/moments.html#moments</a></p>
  
  <p>The Part that is giving me pause is when I try to interact with the contour opbject they declare in that I cannot figure out how to remove items from the collection without breaking everything. the object declarations from the tutorial are included for those who did not click it below.</p>
  
  <pre><code>vector&lt;vector&lt;Point&gt; &gt; contours;
  vector&lt;Vec4i&gt; hierarchy;
  </code></pre>
  
  <p>Now, I may have missed this somewhere in the opencv documentation, but how do I remove a contour from the list of returned contours safely?</p>
  
  <p>By safely I mean that I tried a simple</p>
  
  <pre><code>contours.erase(contours.begin()+15);
  </code></pre>
  
  <p>which cause run time issues with the hierarch item that gets returned with it, but when I included </p>
  
  <pre><code>hierarchy.erase(hierarchy.begin()+15);
  </code></pre>
  
  <p>I lost more than a single contour, so I am kind of at a loss as to how I remove a single contour from the collection that gets returned to me.</p>
  
  <p>Edit:</p>
  
  <p>Based on the response I got how can I get OpenCV to return me a series of contours that I can easily remove unnecessary contours from?
  Cheers</p>