title: OpenCV; sort a vector<Rect> and delete certain entries
body: <p>I have this problem I can't wrap my head around. I am trying to detect and track something in a video. Therefore I use functions like <code>GaussianBlur(), threshold(), findContours(),</code>.</p>
  
  <p><code>findContours()</code> gives me a contour vector which is later converted into bounding rectangles. So far so good. </p>
  
  <p>What I need now from the vector with the bounding rectangles is that they are sorted by size <code>(area)</code> and contains only rectangles which are not enclosed by another rectangle.</p>
  
  <p>I tried to draw a little sketch for better understanding, <a href="http://www7.pic-upload.de/09.01.14/ptnbvocxey8v.png" rel="noreferrer">click here for image</a>.</p>
  
  <p>So what I am looking for is that <code>#8</code> is the first entry, followed by <code>#1, #3,....</code>
  Entries like <code>#2,#4, #9, #10 and #11</code> should be deleted.</p>
  
  <p>I understand that vectors are not ideal for sorting and deleting. So I tried to copy the vector into a list like so:</p>
  
  <pre><code>std::list&lt;Rect&gt; sorted_list(boundRect_temp.begin(), boundRect_temp.end());
  </code></pre>
  
  <p>But now I am not able to access the member variables like area. The thing is that the algorithm shouldn't be too time consuming that's why I am looking for a good solution. Maybe there is a function for that already?</p>