#include "stdafx.h"
#include "iostream.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
int main(int argc, char* argv[])
{
IplImage *img=cvLoadImage("G:\\图像\\TorchSkin.JPG");
if(img!=NULL)
{
cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);
cvShowImage("Example1",img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");
}
else
{
cout<<"读取图片失败"<<endl;
}
return 0;
}
以上是正确的代码
首先,cvLoadImage函数的原型IplImage*cvLoadImage(const char*filename,int flags)
;
可能出错的点只有俩个参数,filename不是单纯的文件名,是指该文件的路径,当然在该工程的文件夹下可以直接用文件名(“TorchSkin.jpg”)