首页 > 代码库 > Get start with OpenCV
Get start with OpenCV
Get start with OpenCV
花了三天的时间才把OpenCV装好~这个过程简直艰辛。。。昨天晚上我都差点要绝望了,心里难受啊~最后不知道尝试了多少次之后,libgtk2.0-dev终于装上去了.
apt-get 之前一直找不到libgtk2.0-dev 这个包,无比纠结,时间都砸进去了。仅仅只是搭建开发环境而已,却花了这么多时间,心疼啊~我仅剩不多的暑假时光~如果有viewer和我遇到同样的问题,那我建议——重装一次你的Ubuntu吧~
编译遇到点小麻烦,不过搞定也花什么时间。
Get start with OpenCV, the first demo.
/************************************************************ code writer : EOF code date : 2014.08.04 e-mail : jasonleaster@gmail.com jasonleaster@163.com code purpose: This demo is coded for someone who is the first time to code with OpenCV (A very powerful computer vision library.) Something like your "Hello world" is here. ************************************************************/ #include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui_c.h" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" int main(int argc,char* argv[]) { IplImage* img = cvLoadImage(argv[1],CV_LOAD_IMAGE_COLOR); //IplImage is a structure which could store a image that retured by function 'cvLoadImage' cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE); //cvNamedWindow is a function which would help you to creat a window. cvShowImage("Example1",img); //Obviously, show the picture that you inputed. cvWaitKey(0); //pause and let the user see the picture. cvReleaseImage(&img); //Finally, release the struture, otherwise, memory leak ! return 0; }
没完,编译的参数看的库自带的demo的脚本,不难。这里给出能用的简单的脚本,在当前工作目录下运行即可
#!/bin/sh for i in *.c; do echo "compiling $i" gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`; done
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。