title: OpenCV Draw draw contours of 2 largest objects
body: <p>I am doing a OpenCV software that detects boxing gloves therefore i want to detect and draw only 2 largest contours (one for each boxing glove). </p>
  
  <p>My software draws contours for everything and some things are noise only which ofcourse i dont want</p>
  
  <p>My code for drawing contours: </p>
  
  <pre><code>    vector&lt;vector&lt;Point&gt; &gt; contours;
      vector&lt;Vec4i&gt; hierarchy;
      findContours(mBlur, contours, hierarchy, CV_RETR_EXTERNAL,  CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
      //-----------------------------------------------------------------------------&gt;
  
      vector&lt;vector&lt;Point&gt; &gt; contours_poly(contours.size());
      vector&lt;Rect&gt; boundRect (contours.size());
      vector&lt;Point2f&gt; boundingBoxArea(boundRect.size());
  
      //-----------------------------------------------------------------------------&gt;
  
      for( int i = 0; i &lt; contours.size(); i++ )
       { 
         approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
         boundRect[i] = boundingRect( Mat(contours_poly[i]) );
  
       }
  
      /// Draw polygonal contour + bonding rects
     Mat drawing = Mat::zeros( range_out.size(), CV_8UC3 );
  
      for( int i = 0; i&lt; contours.size(); i++ )
          {
  
             Scalar color = Scalar(0,0,255);
             drawContours( drawing, contours_poly, i, color, 1, 8, vector&lt;Vec4i&gt;(), 0, Point() );
             fillPoly(drawing, contours, Scalar(255,0,0));
  
         }
  </code></pre>
  
  <p>Here is an Image Example:</p>
  
  <p><img src="https://i.stack.imgur.com/EeJro.png" alt="enter image description here"></p>
  
  <p>My program already segments the gloves by color, The problelem is that at times small contours are drawn in random locations due to noise. Now of course the gloves contours are by far dominant and this is why i want to keep only the contours of these. Hope this makes my question clearer </p>
  
  <p>Could someone suggest a solution please
  I am coding in C++ environment 
  regards </p>