想要把工业ccd截屏处理,用opencv,但是截图的时候就弹出如题的错误,希望可以早点得到解决方法,在线等
代码如下:
IplImage* pImg=NULL;
pImg = cvCreateImageHeader(cvSize(m_nMaxWid,m_nMaxHei),IPL_DEPTH_8U,3);
cvSetData(pImg,m_pImageBuffer,m_nMaxWid*3);
//memcpy(pImg->imageData,m_pImageBuffer,m_nMaxWid*m_nMaxHei*3);
CvCapture* cap=cvCreateCameraCapture(-1);
char filename[100];
static int count=0;
cvNamedWindow("Camera",CV_WINDOW_AUTOSIZE);
pImg=cvQueryFrame(cap);
sprintf(filename,"%s%d%s","image",count++,".jpg");
cvShowImage("Camera",pImg);
//cvWaitKey(30000);
cvSaveImage(filename,pImg);
cvDestroyAllWindows();
cvReleaseImage(&pImg);
cvReleaseCapture(&cap);
if (NULL != pImg) {
delete []pImg;///English:
}
pImg = cvCreateImageHeader(cvSize(m_nMaxWid,m_nMaxHei),IPL_DEPTH_8U,3);
cvSetData(pImg,m_pImageBuffer,m_nMaxWid*3);
再加上句cvcopy(pimage0,plmg);就可以了