码迷,mamicode.com
首页 > 其他好文 > 详细

Get start with OpenCV

时间:2014-08-04 17:54:37      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   2014   

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



bubuko.com,布布扣




Get start with OpenCV,布布扣,bubuko.com

Get start with OpenCV

标签:style   blog   http   color   os   io   for   2014   

原文地址:http://blog.csdn.net/cinmyheart/article/details/38369461

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!