Getting started with OpenCV

首先,你得设置编译环境(针对Visual C++),包括:

1.添加含“头文件”的文件夹位置,
<OPENCV_INSTALL>/cv/inlcude
<OPENCV_INSTALL>/cxcore/include
<OPENCV_INSTALL>/cvaux/include
<OPENCV_INSTALL>/otherlibs/cvcam/include
<OPENCV_INSTALL>/otherlibs/highgui

2.添加库文件所在的文件夹位置,
<OPENCV_INSTALL>/lib

3.和含有源文件的文件夹位置。
<OPENCV_INSTALL>/cv/src
<OPENCV_INSTALL>/cxcore/src
<OPENCV_INSTALL>/cvaux/src
<OPENCV_INSTALL>/otherlibs/highgui
<OPENCV_INSTALL>/otherlibs/cvcam/src/windows

*<OPENCV_INSTALL>即是OpenCV的安装位置。

然后建立一个工程,添加如下代码:

#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

int main(int argc, char **argv)
{
    IplImage *img = cvLoadImage("Image.bmp");
    cvNamedWindow("Image:", 1);
    cvShowImage("Image:", img);

    cvWaitKey();
    cvDestroyWindow("Image:");
    cvReleaseImage(&img);

    return 0;
}

当然别忘了添加编译所需的.lib文件(cxcore.lib cv.lib highgui.lib cvaux.lib),不然链接器会显示无法链接函数。然后编译,运行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值