title: Calculating the area of Bounding Box
body: <p>Hello StackOverflowers </p>
  
  <p>I have created an application that Segments an image on the basis of a predefined color using inRange function. I then draw bounding box around the detected object.</p>
  
  <p>My question here is how do I determine region properties such as: area, size, height and with, center point.</p>
  
  <p>Here i placed a screen dump example..... </p>
  
  <p><img src="https://i.stack.imgur.com/N0cTO.png" alt="enter image description here"></p>
  
  <p>How should i approach to retrieve region properties of these bounding boxes or any other bounding boxes that get drown.......?</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) );
  
  
  
       /// Approximate contours to polygons + get bounding rects and circles
    vector&lt;vector&lt;Point&gt; &gt; contours_poly( contours.size() );
    vector&lt;Rect&gt; boundRect( contours.size() );
    vector&lt;Point2f&gt;center( contours.size() );
    vector&lt;float&gt;radius( contours.size() );
  
    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(255,0,255);
         drawContours( drawing, contours_poly, i, color, 1, 8, vector&lt;Vec4i&gt;(), 0, Point() );
         rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );
       }
  </code></pre>
  
  <p>Regards </p>