Configuration of OpenCV 2.4.7 in VS2012 (X86)

1 篇文章 0 订阅


1. Download OpenCV-2.4.7 from opencv.org,unzip to a directory.

For example, the directory is ”C:\opencv”and there are two sub-folders under it : “build” and “sources”.


2. Configure environment variable

Computer->Properties->Advanced System settings->Environment Variables->System (or user)variables->Path->Variable value:

add“; C:\opencv\build\x86\vc11\bin; C:\opencv\build\x86\vc11\lib” at the end.



3. Create a new Win32 console project for test

Open VS2012,File->New->Project->Win32 Console Application, give a name, select empty project and click finish button.


4. Configure OpenCV dependencies

1) View->Property Manager

Add new Project Property Sheet for both Debug|Win32 and/or Release|Win32. Double click the new Property pages.

2) VC++ Directories->Include Directories,add an item “C:\opencv\build\include;”. 

( You can also try to add “C:\opencv\build\include\opencv”and/or “C:\opencv\build\include\opencv2”.)


VC++Directories->Library Directories, add an item “C:\opencv\build\x86\vc11\lib;”




3) Linker->Input->Additional Dependencies, add following items.

For Debug|Win32,

opencv_calib3d247d.lib
opencv_contrib247d.lib
opencv_core247d.lib
opencv_features2d247d.lib
opencv_flann247d.lib
opencv_gpu247d.lib
opencv_highgui247d.lib
opencv_imgproc247d.lib
opencv_legacy247d.lib
opencv_ml247d.lib
opencv_objdetect247d.lib
opencv_ts247d.lib
opencv_video247d.lib


For Release|Win32,

opencv_calib3d247.lib
opencv_contrib247.lib
opencv_core247.lib
opencv_features2d247.lib
opencv_flann247.lib
opencv_gpu247.lib
opencv_highgui247.lib
opencv_imgproc247.lib
opencv_legacy247.lib
opencv_ml247.lib
opencv_objdetect247.lib
opencv_ts247.lib
opencv_video247.lib

Note that in each line, "247" represents the version and "d" means debug. If other version of opencv is used, just change "247" to other number.



5) In VS2012, Solution Explorer->SourceFiles->right click->Add->New Item->C++ File (.CPP).

Copy the source code from “C:\opencv\sources\samples\cpp\opencv_version.cpp”. Run it.

#include "opencv2/core/core.hpp"
#include <iostream>

const char* keys =
{
    "{ b |build |false | print complete build info }"
    "{ h |help  |false | print this help           }"
};

int main(int argc, const char* argv[])
{
    cv::CommandLineParser parser(argc, argv, keys);

    if (parser.get<bool>("help"))
    {
        parser.printParams();
    }
    else if (parser.get<bool>("build"))
    {
        std::cout << cv::getBuildInformation() << std::endl;
    }
    else
    {
        std::cout << "OpenCV " << CV_VERSION << std::endl;
    }

	getchar();
    return 0;
}



For the future project, try to add #include <opencv2\opencv.hpp> at the beginning to include all headers for OpenCV. The property sheet can be saved as .props file. Then next time the file can be added to the project.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值