Visual studio 2015 + opencv2.4.13 configuration tutorial, 2015opencv2. 4.13

Source: Internet
Author: User

Visual studio 2015 + opencv2.4.13 configuration tutorial, 2015opencv2. 4.13

Change the lab, change the computer, and reconfigure the development environment. This series lacks a complete configuration tutorial, which is simply completed in the middle. This series may cause typographical accidents !!! Visual studio2015 and opencv2.4.13 are selected for this configuration. Opencv3.1 is not configured because the nonfree library in opencv3.1 needs to be downloaded by itself, and most of the current projects are developed based on the opencv2.4 series, so there is no need to pursue the latest. After learning about some basic usage of opencv, which version of opencv is used is no longer a problem.

1. Download

First,

Visual studio2015 community: https://www.visualstudio.com/downloads/

Opencv: https://opencv.org/

2. Installation

If you have an online installation tutorial on vs2015, select the C ++ development environment. Not much.

The opencvxxx.exe file is as follows:

 

Select a decompressed folder. For example, E: \ 20161123 \ is selected. Select a folder and click "Extract" to decompress the folder to obtain the folder named opencv.

3. configure system environment variables

Computer> right-click> Properties> advanced system Settings> environment variables> System Variables

Series Diagram

(1) advanced system settings


(2) Environment Variables


(3) System Variables


Find the Path in the system variable and click Edit to add the following file:


This path is in the extracted opencv folder. For example, my path is:

E: \ 20161123 \ opencv \ build \ x86 \ vc12 \ bin

For x86 and x64 in files, whether your system is 32-bit or 64-bit, while vc10, vc11, and vc12 represent different vs versions, versions later than vs2012 are vc12. after environment variables are configured, restart or log out of the computer.

4. Configure the opencv file permanently in vs2015

Open vs2015 and create a project, as shown in Series

(1)

 

(2)


(3) Add a. cpp File

There are two forms

1). Project-> source file-> right-click-> Add-> new item, as shown below:

 

2) directly use the shortcut key Ctrl + Shift +

 

(4) view-> Property Manager

(5)


Double-click Win32.user.

(6) Select VC ++ directory> include directory> triangle symbol> Edit

 

(7) Add a directory


For example, my file path is:

E: \ 20161123 \ opencv \ build \ include

E: \ 20161123 \ opencv \ build \ include \ opencv

E: \ 20161123 \ opencv \ build \ include \ opencv2

Then, find the library directory under the VC ++ directory and edit it as well. Add the lib path.

 

 

For example, my path is E: \ 20161123 \ opencv \ build \ x86 \ vc12 \ lib.

Click OK after adding.

(8) linker-> input-> additional dependency

 

Note the opencv version.

For opencv2.4.9, add the Debug library as follows:

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

For opencv2.4.13, add the Debug Library

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_ml2413d.lib
Opencv_nonfree2413d.lib
Opencv_objdetect2413d.lib
Opencv_ocl2413d.lib
Opencv_photo2413d.lib
Opencv_stitching2413d.lib
Opencv_superres2413d.lib
Opencv_ts2413d.lib
Opencv_video2413d.lib
Opencv_videostab2413d.lib

If you want to add a Release library, remove d after the file name.


Based on the opencv version, you can directly copy the above library name. When vs2015 is disabled, the system will prompt you to save the configuration. Then re-open the project and enter the following code to test whether the opencv configuration is successful.

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

using namespace std;
using namespace cv;

int main ()
{
   Mat srcImage = imread ("lena.jpg"); // Load image file
   namedWindow ("lena", WINDOW_AUTOSIZE); // Set the window title of the displayed image to lena, and the property is to automatically adjust the size
   imshow ("lena", srcImage); // Display picture

   waitKey (0);

   return 0;
} 

The running result is as follows:

 

Note:

1. The images used in the program are stored in the project directory. Otherwise, enter the path name.

2. During the first running, the system may prompt that the. dll library is missing, such as MSVCP120D. dll, MSVCR120D. dll, and other dynamic link libraries.

Download the corresponding dynamic link library from the Internet, and then put it into the system file

For 32-bit operating systems, put: C: \ Windows \ System32

For 64-bit operating systems, put: C: \ Windows \ SysWOW64

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.


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.