我在Windows 8中使用OpenCV 2.3.1。当我调用函数cvShowImage
时,程序崩溃了。我正在使用代码块,我不知道为什么会这样。
如果我对该行发表评论,该程序运行良好。
代码如下:
IplImage *img1=NULL;
img1=cvLoadImage("LenaComFormas.pgm",CV_LOAD_IMAGE_GRAYSCALE);
cvShowImage("Original", img1);
cvWaitKey(0);
答案 0 :(得分:1)
因为图片未加载(cvLoadImage
返回NULL
)。您可以使用debugger进行检查。再次检查文件的路径。
答案 1 :(得分:1)
你的代码在Windows7上使用Qt和opencv 2.4.3正常工作......你可以做的可能检查......
IplImage *img1 = cvLoadImage("",0);
if(img1==NULL)
return -1;
3。检查* .pgm图像的支持...或者获取最新的opencv并尝试...
修改.. 强> 4。只是为了检查尝试以下..
#include <opencv/opencv2/core.hpp>
#include <opencv/opencv2/highgui.hpp>
using namespace cv;
int main()
{
Mat image;
image = imread("",0);
imshow("TEST",image);
waitKey(0);
return 0;
}