title: opencv error assertion with roi
body: <p>I'm trying to detect persons and other object using HOG classifier.I started by detecting persons by using this code:</p>
  
  <pre><code>    capt &gt;&gt; frame_capture;
      capt1 &gt;&gt; frame_capture1;
      cv::cvtColor(frame_capture1,gray, CV_RGB2GRAY);
      vector&lt;vector&lt;Point&gt; &gt; contours;
      vector&lt;Vec4i&gt; hierarchy;
      findContours(gray,contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
      vector &lt;Rect&gt; listOfRectangles;
      // detecting objects 
      listOfRectangles = drawBoundingBox(contours);
  
  if(!frame_capture.empty()){
      for (int i =0; i&lt;listOfRectangles.size();++i)
      {
          //rectangle (frame_capture, listOfRectangles[i],Scalar(255,255,0),1,8,0); //! display detections
          cv::Mat roi;
          roi.create(frame_capture.size(),CV_8UC3);
          cv::Mat image=imread("");   
           roi = image(listOfRectangles[i]);
              cv::Mat window;
              cv::resize(roi, window, cv::Size(64, 128));
              hog.detect(window, foundLocations);
              if (!foundLocations.empty())
              {
              cout &lt;&lt; "person .." &lt;&lt; endl;
              }   
      }
  
  //oVideoWriter.write(frame_capture);
      imshow("video",frame_capture);
      waitKey(25);
  }    
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>OpenCV Error: Assertion failed (0 &lt;= roi.x &amp;&amp; 0 &lt;= roi.width &amp;&amp; roi.x + roi.width &lt;= m.cols &amp;&amp; 0 &lt;= roi.y &amp;&amp; 0 &lt;= roi.height &amp;&amp; roi.y + roi.height &lt;= m.rows) in Mat
  </code></pre>
  
  <p>I had used this link:<a href="https://stackoverflow.com/questions/21192984/opencv-how-to-use-hogdescriptordetect-method/36352130#36352130">OpenCV: How to use HOGDescriptor::detect method?</a></p>