title: Problem with cvCvtColor: unhandled exception at "0x1002e4e4" in "opencvsample.exe": 0xC0000005: Access read violation "0xffffffff"
body: <p>I have a problem with OpenCV function cvCvtColor.
  Here is the code I used:</p>
  
  <pre><code>#include "cv.h"
  #include "highgui.h"
  
  int main(void)
  {
   int  g_thresh = 100;
   CvCapture* capture = cvCreateCameraCapture(0); 
      IplImage* g_image = cvQueryFrame(capture); 
   IplImage* g_image_copy = cvCloneImage(g_image);
   cvNamedWindow( "Contours", 1 );
   cvShowImage( "Contours", g_image );
  
   IplImage* g_gray = cvCreateImage( cvSize(g_image-&gt;width, g_image-&gt;height), g_image-&gt;depth, 1 );
  
  
   cvCvtColor( g_image_copy, g_gray, CV_BGR2GRAY );
   cvThreshold( g_gray, g_gray, g_thresh, 255, CV_THRESH_BINARY );
   CvMemStorage*  g_storage = cvCreateMemStorage(0);
   CvSeq* contours = 0;
  
   cvFindContours( g_gray, g_storage, &amp;contours );
   cvZero( g_gray );
   if( contours ){
    cvDrawContours(
     g_gray,
     contours,
     cvScalarAll(255),
     cvScalarAll(255),
     100 );
   }
  
   cvShowImage( "Contours", g_gray );
   cvWaitKey();
  
   return 0;
  }
  </code></pre>
  
  <p>It's "unhandled exception at "0x1002e4e4" in "opencvsample.exe": 0xC0000005: Access read violation "0xffffffff"." (maybe I make mistakes in translation, I have russian VS2008).
  It occurs at line</p>
  
  <pre><code>cvCvtColor( g_image_copy, g_gray, CV_BGR2GRAY );
  </code></pre>
  
  <p>What I need to do to solve problem?</p>