[Opencv Notes] use vs2012 and opencv2.4.9 to build and configure the opencv Development Environment

Source: Internet
Author: User

MS Visual C ++ is used to create the opencv project. Because different vs Versions differ in the configuration process, the configuration process is summarized to facilitate use by yourself and other friends.

1. Software preparation

Install visual studio2012 and opencv2.4.9

Here we will not describe the installation of software and the setting of environment variables. The settings in other similar articles are almost similar. This article focuses on the configuration of the vs2012 environment.

2. Configure the vs2012 Environment

(1) create a project

You can create a simple console application or a complex application with a graphical user interface. Here we select the simplest and most commonly used console application.

Understanding the difference between a solution and a project: a solution consists of multiple projects (each project is an independent software module, such as a program or a code library), the advantage of this is that the solution can share files and code libraries. Generally, you create a main folder for the solution that contains all the project folders. After you are familiar with Visual C ++ and create more complex applications, you should use a solution structure that contains multiple projects.


Figure 1 create a console application

(2) Set project properties through a property ticket

To compile and run the opencv application, Visual C ++ needs to know the location of the opencv header file and library, therefore, you need to specify the directory of the header file, the Directory of the code library, and the Linked Library file in the project properties.

Since we will create multiple opencv projects in the future, the best way is to create a property sheet for future projects. We use property manager to complete related operations.


Figure 2 Property Manager

In Visual C ++, the attribute list is an XML file that describes the project settings. Right-click the project debug | Win32 node and select Add new property sheet to create a new property sheet.

(3) set a property ticket

Double-click the added property sheet and edit it as follows:

<1> Configure VC ++ Directories

Double-click the name of the property sheet and select VC ++ directories. Edit the include directories text box and add the path of the opencv header file;

Perform the same operation on library directories to add the path of the library file of opencv.


Figure 3 setting of Single-attribute VC ++ Directories


Figure 4 Add a header file path


Figure 5 add a library file path

<2> specify the opencv library file to be linked

Different applications require different opencv modules. Because we need to reuse this attribute sheet, we will add the required library module.

Choose linker> input> additional dependencies to add the library module.

Opencv_core249d.lib
Opencv_imgproc249d.lib
Opencv_highgui249d.lib
Opencv_ml249d.lib
Opencv_video249d.lib
Opencv_features2d249d.lib
Opencv_calib3d249d.lib
Opencv_objdetect249d.lib
Opencv_contrib249d.lib
Opencv_legacy249d.lib
Opencv_flann249d.lib

The library files to be specified end with the letter "D", which means they are binary files in debug mode. If you need to create another property ticket for the release mode, add it to the Rlease | Win32 node, and the library file name does not contain "D ".


Figure 6 add an opencv Library File


Figure 7 specify library files


Next, you can create a simple application.


Reprinted please indicate the author and Article Source: http://blog.csdn.net/jasonding1354/article/details/38407905


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.