title: Unhandled exception at 0x778715de in opencv_helloworld.exe: 0xC0000005: Access violation reading location 0x00000004
body: <p>I keep getting the same error, this line of code seems to be the problem i also add those line you told me </p>
  
  <p>CvSeq *hand = cvHaarDetectObjects(img, cascade, hstorage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(100, 100));</p>
  
  <p>Any great ideas?</p>
  
  <pre><code>// OpenCV_Helloworld.cpp : Defines the entry point for the console application.
  // Created for build/install tutorial, Microsoft Visual C++ 2010 Express and OpenCV 2.1.0
  
  #include "stdafx.h"
  
  #include "cv.h"
  #include "cxcore.h"
  #include "highgui.h"
  #include "math.h"
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  IplImage* img = 0;
  
  static CvHaarClassifierCascade* cascade = 0;
  CvMemStorage *cstorage;
  CvMemStorage *hstorage;
  
  void detectObjects( IplImage *img );
  int key;
  
  int main( int argc, char** argv )
  {
      CvCapture *capture;
      IplImage *frame;
  
      // Create a string that contains the cascade name
      const char* cascade_name ="C:/Users/Mario/Documents/Visual Studio 2010/Projects/opencv_helloworld/1256617233-2-haarcascade_hand.xml";
      cascade = ( CvHaarClassifierCascade* )cvLoad( cascade_name, 0, 0, 0 );
  
      if (cascade == 0)
      {
          printf("No se encontro el archivo xml\n");
          system("pause");
          return 0;
      }
  
      hstorage = cvCreateMemStorage( 0 );
      cstorage = cvCreateMemStorage( 0 );
  
      capture = cvCaptureFromCAM( 0 );
  
      cvNamedWindow( "camerawin", 1 );
  
      while(key!='q') {
          frame = cvQueryFrame( capture );
          if( !frame ) break;
  
          detectObjects (frame );
  
          key = cvWaitKey( 10 );
  }
  
      cvReleaseCapture( &amp;capture );
      cvDestroyAllWindows();
      cvReleaseHaarClassifierCascade( &amp;cascade );
      cvReleaseMemStorage( &amp;cstorage );
      cvReleaseMemStorage( &amp;hstorage );
  
      return 0;
  }
  
  void detectObjects( IplImage *img )
  {
      //int px;
      //int py;
      int edge_thresh = 1;
      IplImage *gray = cvCreateImage( cvSize(img-&gt;width,img-&gt;height), 8, 1);
      IplImage *edge = cvCreateImage( cvSize(img-&gt;width,img-&gt;height), 8, 1);
  
      cvCvtColor(img,gray,CV_BGR2GRAY);                       
  
      gray-&gt;origin=1;                         
  
      cvThreshold(gray,gray,100,255,CV_THRESH_BINARY);    
  
      cvSmooth(gray, gray, CV_GAUSSIAN, 11, 11);
  
      cvCanny(gray, edge, (float)edge_thresh, (float)edge_thresh*3, 5); 
  
      CvSeq *hand = cvHaarDetectObjects(img, cascade, hstorage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(100, 100));
  
      if (!hand)
      {
          printf("cvHaarDetectObjects error\n");
          system("pause");
      }
  
      if (hand-&gt;total &lt;= 0)
      {
          printf("hand-&gt;total menor a cero\n");
          system("pause");
      }
  
      CvRect *r = ( CvRect* )cvGetSeqElem( hand, 0 );
      cvRectangle( img,cvPoint( r-&gt;x, r-&gt;y ),
          cvPoint( r-&gt;x + r-&gt;width, 
          r-&gt;y + r-&gt;height ),
          CV_RGB( 255, 0, 0 ), 
          1, 8, 0 );
  
      cvShowImage("camerawin",img);
  }
  </code></pre>