Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem with IplImage pointer

Hi everybody! I start learning OpenCV. Now using Windows 8.1 + VS2013 + opencv246 I have a problem with pointer "frame":

  CvCapture *capture = cvCreateCameraCapture(0);    
  if (capture == NULL)          
    return 0;
  IplImage *frame = NULL; 
  IplImage *sframe = NULL;

  CvSize size = cvSize(         
     cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH) / 2,  
  cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT) / 2       
  );

  frame = cvQueryFrame(capture); //after this line "frame" remains NULL!    
  sframe = cvCreateImage(size, frame->depth, frame->nChannels); //here we've got exception

Visual Studio throws exception:

Unhandled exception at 0x0029564C in opencv_threewindows.exe: 0xC0000005: 
Access violation reading address 0x00000008.

Why "frame" doesn't initialize? If we will delete these lines, and continue program execution:

cvNamedWindow("camera", CV_WINDOW_AUTOSIZE);
while (1)
    {
        frame = cvQueryFrame(capture);
                cvShowImage("camera", frame);
        }

All works fine... I can't understand why this occurs. Appreciate any help.

Problem with IplImage pointer

Hi everybody! I start learning OpenCV. Now using Windows 8.1 + VS2013 + opencv246 opencv246. I have a problem with pointer "frame":

  CvCapture *capture = cvCreateCameraCapture(0);    
  if (capture == NULL)          
    return 0;
  IplImage *frame = NULL; 
  IplImage *sframe = NULL;

  CvSize size = cvSize(         
     cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH) / 2,  
  cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT) / 2       
  );

  frame = cvQueryFrame(capture); //after this line "frame" remains NULL!    
  sframe = cvCreateImage(size, frame->depth, frame->nChannels); //here we've got exception

Visual Studio throws exception:

Unhandled exception at 0x0029564C in opencv_threewindows.exe: 0xC0000005: 
Access violation reading address 0x00000008.

Why "frame" doesn't initialize? If we will delete these lines, and continue program execution:

cvNamedWindow("camera", CV_WINDOW_AUTOSIZE);
while (1)
    {
        frame = cvQueryFrame(capture);
                cvShowImage("camera", frame);
        }

All works fine... I can't understand why this occurs. Appreciate any help.

click to hide/show revision 3
retagged

updated 2013-12-23 03:08:10 -0600

berak gravatar image

Problem with IplImage pointer

Hi everybody! I start learning OpenCV. Now using Windows 8.1 + VS2013 + opencv246. I have a problem with pointer "frame":

  CvCapture *capture = cvCreateCameraCapture(0);    
  if (capture == NULL)          
    return 0;
  IplImage *frame = NULL; 
  IplImage *sframe = NULL;

  CvSize size = cvSize(         
     cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH) / 2,  
  cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT) / 2       
  );

  frame = cvQueryFrame(capture); //after this line "frame" remains NULL!    
  sframe = cvCreateImage(size, frame->depth, frame->nChannels); //here we've got exception

Visual Studio throws exception:

Unhandled exception at 0x0029564C in opencv_threewindows.exe: 0xC0000005: 
Access violation reading address 0x00000008.

Why "frame" doesn't initialize? If we will delete these lines, and continue program execution:

cvNamedWindow("camera", CV_WINDOW_AUTOSIZE);
while (1)
    {
        frame = cvQueryFrame(capture);
                cvShowImage("camera", frame);
        }

All works fine... I can't understand why this occurs. Appreciate any help.