title: How to verify if rect is inside cv::Mat in OpenCV?
body: <p>Is there anything like <code>cv::Mat::contains(cv::Rect)</code> in Opencv?</p>
  
  <p><strong>Background:</strong>
  After detecting objects as contours and trying to access ROIs by using cv::boundingRect my application crashed. OK, that's because the bounding rects of the object close to image border may be not entirely within the image.</p>
  
  <p>Now I skip the objects not entirely in image by this check:</p>
  
  <pre><code>if(
    cellRect.x&gt;0 &amp;&amp; 
    cellRect.y&gt;0 &amp;&amp; 
    cellRect.x + cellRect.width &lt; m.cols &amp;&amp; 
    cellRect.x + cellRect.width &lt; m.rows) ...
  </code></pre>
  
  <p>where <em>cellRect</em> is the bounding rect of the object and <em>m</em> is the image.
  I hope there is a dedicated opencv function for this.</p>