title: Access Violation Exception Thrown OpenCV
body: <p>Im working on a simple face detector using Visual Studio 2017 with OpenCV 3.2.0 and haarcascades.
  Whenever i run this, i get an error saying there's an exception thrown right after i create the first point. Access violation error. Any help would be greatly appreciated as I do not see any error in the code. <a href="https://i.stack.imgur.com/YEoWh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YEoWh.png" alt="Here is a picture of the exception thrown. "></a></p>
  
  <pre><code>#include &lt;opencv2/opencv.hpp&gt;
  #include &lt;opencv2/objdetect/objdetect.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;vector&gt;
  
  
  
  using namespace std;
  using namespace cv; 
  
  int main()
  {
      CascadeClassifier face_cascade;
      CascadeClassifier eye_cascade;
      face_cascade.load("haarcascade_frontalface_alt.xml");
      eye_cascade.load("haarcascade_eye_tree_eyeglasses.xml");
      VideoCapture cap(0);
      Mat frame;
      while (cap.read(frame))
      {
          Mat frame_gray;
          std::vector &lt;Rect&gt; faces;
          cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
          equalizeHist(frame_gray, frame_gray);
          face_cascade.detectMultiScale(frame_gray,faces, 1.1, 2,0,Size(30,30),Size(300,300));
          for (size_t i = 0; i &lt; faces.size();i++)
          {
  
  
              Point first(faces[i].x, faces[i].y);
              Point second(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
              rectangle(frame,second,first, cvScalar(255, 0, 0), 1, 8, 0);
  
          }
  
          imshow("Test", frame_gray);
          waitKey(30);
      }
      return 0;
  }
  </code></pre>