尝试使用 opencv 从网络摄像头捕获视频时出现此错误。这是我正在使用的代码:
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main( int argc, const char** argv ) {
CvCapture *capture = cvCaptureFromCAM(0);
IplImage *frame;
cvNamedWindow("test");
while ( 1)
{
frame = cvQueryFrame(capture) ;
cvShowImage("test", frame);
int key = cvWaitKey(1);
if ( key == 27 ) break; // ESC key was pressed
}
// Memory deallocation
cvReleaseCapture(&capture);
cvDestroyWindow("test");
return 0;
}
错误发生在 cvShowImage("text", frame):
OpenCV 错误:cvGetMat 中的空指针(传递了空数组指针),文件 /opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/opencv/work/opencv-2.4.6.1/modules/core/src/array.cpp,行2382 libc++abi.dylib:终止调用抛出异常(lldb)
它是什么错误,我该如何解决?