您的位置:首页 > 大数据 > 人工智能

int main(int argc,char…

2017-06-29 10:12 281 查看
 

#include<cv.h>

#include<highgui.h>

int main(int argc,char** argv)

{

IplImage* first=cvLoadImage(argv[1]); //加载图片
cvNamedWindow("first",CV_WINDOW_AUTOSIZE);
//创建一个命名窗口

cvNamedWindow("first_out",CV_WINDOW_AUTOSIZE); 

cvShowImage(argv[1],first); //把加载的图片显示在创建的窗口上

IplImage* first_out=cvCreateImage(

cvGetSize(first_out),

IPL_DEPTH_8U,

1

);

cvCvtColor(

first,

first_out,

CV_RGB2GRAY

);

cvShowImage("first_out",first_out);

while(1) //触发事件,遇到esc键退出



if(cvWaitKey(100)==27)

break;

}

cvDestroyWindow("first"); //销毁显示文件的窗口

cvDestroyWindow("first_out");

cvReleaseImage(&first);
//释放为图像文件所分配的内存

cvReleaseImage(&first_out);

exit(0);

}

 

运行cmd,进入工程所在目录下,假设编译后生成的文件为a.exe, 在命令行中输入a.exe
1.bmp即可(1.bmp是与工程在同一个文件夹中)。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: