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是与工程在同一个文件夹中)。
相关文章推荐
- 主函数main中变量(int&nbsp;argc…
- 主函数main中变量(int&nbsp;argc…
- int char* string …
- C语言--main(int argc char**argv)具体用法
- vs2005&nbsp;int&nbsp;_tmain(int&nbsp;argc,&nbsp;_TCH…
- char,int,long,long long类型…
- char ,int,long,float,double…
- 关于主函数:int main(int&nb…
- (转)关于主函数:int&nbsp;main(int&amp;nb…
- int pointer & char pointer
- int main(int argc,char* argv[])
- Java_int 和integer的区别
- Oracle&nbsp;to_char格式化函数
- int argc char *argv[]
- return type of 'main' is not `int'
- 关于main函数的(int_argc,char_argv[])
- int main(int argc,char *argv[])中参数的意义
- java&nbsp;中&nbsp;int和byte数组互转
- 32位机器中int/char/long 的字长 && 字节对齐
- main(int argc, char **argv)中argc和argv的具体含义,以及操作系统如何处理