cvCvtColor问题:“opencvsample.exe”中“0x1002e4e4”处的未处理异常:0xC0000005:访问读取违规“0xffffffff”

时间:2010-04-09 13:48:02

标签: visual-c++ opencv

我的OpenCV函数cvCvtColor有问题。 这是我使用的代码:

#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->width, g_image->height), g_image->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, &contours );
 cvZero( g_gray );
 if( contours ){
  cvDrawContours(
   g_gray,
   contours,
   cvScalarAll(255),
   cvScalarAll(255),
   100 );
 }

 cvShowImage( "Contours", g_gray );
 cvWaitKey();

 return 0;
}

“opencvsample.exe”中“0x1002e4e4”的“未处理异常”:0xC0000005:访问读取违规“0xffffffff”。“ (也许我在翻译中犯错误,我有俄语VS2008)。 它出现在

cvCvtColor( g_image_copy, g_gray, CV_BGR2GRAY );

我需要做些什么来解决问题?

1 个答案:

答案 0 :(得分:0)