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 : [email protected] [email protected] 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
Get start with OpenCV
时间: 2024-10-03 21:54:13