Visual Studio 2012 installation configuration methods graphics and text tutorials with OpenCV configuration Tutorial _ Practical Tips

Source: Internet
Author: User
Tags win32 visual studio 2010

With the help of the classmate, finally successfully configured the VS+OPENCV, the detailed process recorded here, convenient to consult later

I. Installation of VS2012

Download vs2012, official download address

1. Double-click the installation file to set the installation path


2. Select the installation package you want

3. Installation in progress


4. Finally installation completed

5. Click Start

prompt to enter product secret key


Ykcw6-bpfpf-bt8c9-7dcth-qxgwc

Activation succeeded

6. Other configuration pages appear


Here choose C + + as the default development environment

7. Start

8. Note that there may be compatibility issues sometimes, and you need to download the update package


Click Install.

Second, install OpenCV

1. Download OpenCV source
OPENCV official website address: http://opencv.org/, the speed is a little slow


Click Download, select the OpenCV version you want to download in the new pop-up page, select 2.4.9


Then, start downloading


About 349MB.

2. Extract Source

Decompression path arbitrary


Extract password


3. Configure environment Variables for OPENCV
(1) Computer right button "Properties"
(2) Advanced System Setup
(3) Click on environment variables
(4) Add the OpenCV Bin folder path to the environment variable named path, specifically:
① 32-bit system, add: D:\File program\opencv\build\x86\vc11\bin
② 64-bit system, add:
D:\File Program\opencv\build\x86\vc11\bin (corresponds to 32-bit system)
D:\File Program\opencv\build\x64\vc11\bin (corresponds to 64-bit system)
The purpose is to switch back and forth in the compiler Win32 and X64

Note 1: D:\File PROGRAM\OPENCV for OpenCV decompression path
Note 2:VC11 indicates that the compilation environment is Microsoft Visual Studio 2012;

Three, vs2012 configuration OpenCV

1. Open vs2012
2. New Win32 Console Application




3. At Solution Explorer: source file-> add-> New Item


4. Configuring at the property manager
(once configured in the property manager, it is equivalent to a common configuration process, the new project will not have to be reconfigured after the additional)
(1) View-> property Manager


(2) Pop-up property manager


(3) Configure debug Win32
Note: This discussion here is that the debug,release configuration is exactly the same

In Debug | Win32 The Microsoft.Cpp.Win32.user right key "Properties"


Pop-up Microsoft.Cpp.Win32.user Property Page


(4) Start Configuration Microsoft.Cpp.Win32.user Property page
① add the Include directory so that C + + programs caninclude opencv

Specifically: In the Pop-up property page, find the "VC + + Directory", in the corresponding right include directory, enter the OpenCV build->include directory


As you can see, there are two folders under the Opencv->build->include directory and you should add the large directory and two folder directories to the Include directory


The following three directories will be added to the Include directory
D:\File Program\opencv\build\include
D:\File PROGRAM\OPENCV\BUILD\INCLUDE\OPENCV
D:\File Program\opencv\build\include\opencv2


② Add Library Directory
Still on the right side of the VC + + directory, add the Opencv->build->x86->vc11->lib path to the library directory
namely: D:\File Program\opencv\build\x86\vc11\lib


Note: Here are the x64 or x86 depending on the compiler (not the operating system!). )
As the following illustration shows, the compiler is WIN32, then you should select the library under the x86 directory

Other than that:
VC10 = Visual Studio 2010
VC11 = Visual Studio 2012
VC12 = Visual Studio 2013

③ Add a link library (that is, a DLL)
Find additional dependencies on the right side of the linker-> input of the Microsoft.Cpp.Win32.user property page


Add the following DLL name (2.4.9 version-debug the dynamic link library in the corresponding OPENCV)

Opencv_ml249d.lib
Opencv_calib3d249d.lib
Opencv_contrib249d.lib
Opencv_core249d.lib
Opencv_features2d249d.lib
Opencv_flann249d.lib
Opencv_gpu249d.lib
Opencv_highgui249d.lib
Opencv_imgproc249d.lib
Opencv_legacy249d.lib
Opencv_objdetect249d.lib
Opencv_ts249d.lib
Opencv_video249d.lib
Opencv_nonfree249d.lib
Opencv_ocl249d.lib
Opencv_photo249d.lib
Opencv_stitching249d.lib
Opencv_superres249d.lib
Opencv_videostab249d.lib


Note: If the configuration is release | Win32, then, what you need to add is the following 19 release editions with no D
Opencv_objdetect249.lib
Opencv_ts249.lib
Opencv_video249.lib
Opencv_nonfree249.lib
Opencv_ocl249.lib
Opencv_photo249.lib
Opencv_stitching249.lib
Opencv_superres249.lib
Opencv_videostab249.lib
Opencv_calib3d249.lib
Opencv_contrib249.lib
Opencv_core249.lib
Opencv_features2d249.lib
Opencv_flann249.lib
Opencv_gpu249.lib
Opencv_highgui249.lib
Opencv_imgproc249.lib
Opencv_legacy249.lib
Opencv_ml249.lib

In addition, for opencv2.4.8

Debug edition

Opencv_ml248d.lib
Opencv_calib3d248d.lib
Opencv_contrib248d.lib
Opencv_core248d.lib
Opencv_features2d248d.lib
Opencv_flann248d.lib
Opencv_gpu248d.lib
Opencv_highgui248d.lib
Opencv_imgproc248d.lib
Opencv_legacy248d.lib
Opencv_objdetect248d.lib
Opencv_ts248d.lib
Opencv_video248d.lib
Opencv_nonfree248d.lib
Opencv_ocl248d.lib
Opencv_photo248d.lib
Opencv_stitching248d.lib
Opencv_superres248d.lib
Opencv_videostab248d.lib

Release version

Opencv_objdetect248.lib
Opencv_ts248.lib
Opencv_video248.lib
Opencv_nonfree248.lib
Opencv_ocl248.lib
Opencv_photo248.lib
Opencv_stitching248.lib
Opencv_superres248.lib
Opencv_videostab248.lib
Opencv_calib3d248.lib
Opencv_contrib248.lib
Opencv_core248.lib
Opencv_features2d248.lib
Opencv_flann248.lib
Opencv_gpu248.lib
Opencv_highgui248.lib
Opencv_imgproc248.lib
Opencv_legacy248.lib
Opencv_ml248.lib

Test whether the OPENCV is configured successfully

New Blank Win32 Console Application
Add a CPP to your project and enter the following code in the CPP
Note: Be sure to guarantee the project path by PIC image!
Or simply give the absolute path to the image (this will avoid the path error)

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


using namespace CV; 


int main () 
{ 
 //read a picture (game original picture) 
 Mat img=imread ("pic.jpg"); 
 Create a "Game original painting" Window 
 Cvnamedwindow ("Game original painting"); 
 In the window display game original painting 
 Imshow ("Game original Painting", IMG); 
 Wait for 6000 MS Rear window to automatically close 
 waitkey (6000); 
} 

(1) Compiling
Successful, no compilation errors

(2) running the program to successfully display the image

Note 1: If there is no image to manipulate under the path, the following error occurs

The above is the entire content of this article, I hope to help you learn.

Related Article

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.