OPENCV2.4.13+VS2012 development environment Configuration and example

Source: Internet
Author: User
Tags win32
1. Download and install the OpenCV SDK


Download page for OPENCV official website: http://opencv.org/downloads.html find the corresponding OpenCV for Windows version download. Currently (2016/07/02) the latest version of the official website is released in 2015/12/21, Version 3.1.0, the latest release is the 2016/05/19 day of version 2.4.13.



Version 3.1.0 only has a 64-bit development package and does not (and does not know the future) support the 32-bit compilation environment, which uses version 2.4.13.










After the download is complete, double-click "Opencv-2.4.13.exe" to eject the Install (Unzip) dialog box:







Select the installation path, here is the use of "D:\ProgramFilesD", click "Extract" after the start of decompression;



It is important to note that there is no additional "OpenCV" folder in the installation directory, OpenCV the root directory extracted from the installation package is "OpenCV".




2. Native environment variables and path configuration






Click the Start menu, right-click Computer, properties, advanced system settings, and environment variables, open the Environment Variable Settings dialog box.
















Create a new variable in the user variable OPENCV, variable value: D:\ProgramFilesD\opencv\build;









Create a new variable in the user variable path, variable value: D:\ProgramFilesD\opencv\build\x86\vc11\bin;






There may be a question here: The compiler is VS2012, and the value of the variable should not be xx\vc12\bin. Note that in the OPENCV configuration, vc11 that corresponds to VS2012,VC12 corresponds to VS2013.



Another thing to be concerned about is whether the above variable value should be x86 or x64. Here x86 or x64 choice with your computer is 32-bit or 64-bit unrelated, vs2012 compilation environment by default using Win32 compiler, so select x86.






Edit (or add) the path variable in the system variable, the value of the variable: D:\ProgramFilesD\opencv\build\x86\vc11\bin, note to use the English input semicolon and the previous path is separated, after the addition of the need to restart or log off the computer, The environment variable will not take effect.







3. IDE Project Properties Configuration






Create a new WIN32 console application, name the project name MYFIRSTOPENCV, and select an empty project in the following options:












Right-click Myfirstopencv Project, add New item, select C + + file (. cpp) in the Pop-up dialog box, add source file, name MyFirstOpenCV.cpp:






In the View Directory drop-down menu, open the property manager in the property manager's Debug| On the Win32 directory, click Select Add New Project property sheet, create a new property sheet, and name it Opencv_debug_setting.props.















Double-click to open the property sheet opencv_debug_setting.props. Select the common Properties->vc++ directory and add 3 directories to the containing directory:






D:\ProgramFilesD\opencv\build\include\opencv2



D:\ProgramFilesD\opencv\build\include\opencv



D:\ProgramFilesD\opencv\build\include










Also in the VC + + directory, add 1 directories in the Library directory:






D:\ProgramFilesD\opencv\build\x86\vc11\lib









Add a library file to an additional dependency by selecting the additional dependency, input----linker, general properties, and so on:






Opencv_ml2413d.lib



Opencv_calib3d2413d.lib



Opencv_contrib2413d.lib



Opencv_core2413d.lib



Opencv_features2d2413d.lib



Opencv_flann2413d.lib



Opencv_gpu2413d.lib



Opencv_highgui2413d.lib



Opencv_imgproc2413d.lib



Opencv_legacy2413d.lib



Opencv_objdetect2413d.lib



Opencv_ts2413d.lib



Opencv_video2413d.lib



Opencv_nonfree2413d.lib



Opencv_ocl2413d.lib



Opencv_photo2413d.lib



Opencv_stitching2413d.lib



Opencv_superres2413d.lib



Opencv_videostab2413d.lib












OK, at this point, the VS2012 environment configuration OpenCV2.4.13 work has been completed, for the creation of the OPENCV project, only need to add the project's property configuration, no longer need to step-by-step configuration.



Method: First save the project's property profile Opencv_debug_setting.props to the alternate folder, the path to this property profile in this project is:



D:\VS2012Test\MyFirstOpenCV\MyFirstOpenCV



Then in the newly created project, add the Opencv_debug_setting.props property sheet in the property manager:







4.OpenCV Project Testing



Finally, let's test whether the configuration is OK.



Add the following code to the program's source file, MyFirstOpenCV.cpp file, to display a picture in the window:




<pre name= "code"  class= "CPP" > #include  <iostream>   #include <core /core.hpp>   #include

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.