Visual studio 2015 + opencv2.4.13 configuration tutorial

Time:2020-10-25

Change the lab, change the computer, and reconfigure the development environment. It’s just that this series lacks a complete configuration tutorial, so we can make it up halfway. May cause this series typesetting change!!! Visual studio 2015 and opencv2.4.13 were selected for this configuration. The reason why opencv3.1 is not configured is that the non free library in opencv3.1 needs to be downloaded by itself, and most of the current projects are developed based on opencv2.4 series, so there is no need to pursue the latest. After understanding some basic uses of OpenCV, it is no longer a question of which version of OpenCV to use.

1. Download

Firstly, the download addresses of visual studio 2015 and opencv2.4.13 are given

Visual studio 2015 Community Edition: https://www.visualstudio.com/downloads/

opencv:https://opencv.org/

2. Installation

Vs2015 installation online tutorial, choose the C + + development environment. Not much.

Double click the downloaded opencvxxx.exe The documents are as follows:

 

Select a folder to unzip. For example, I selected e: \. After selecting the folder, click “extract” to extract the folder with the name of OpenCV.

3. Configure system environment variables

Computer right click Properties advanced system settings environment variables system variables

The following series of figures

(1) Advanced system settings

(2) Environment variable

(3) System variables

Find the path in the system variable, and then click Edit to add the following file

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

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

The x86 and x64 in the file refer to whether your system is 32-bit or 64-bit, while vc10, vc11 and vc12 represent different vs versions, and the versions after vs2012 are vc12. After the environment variables are configured, you need to restart or log off the computer.

4. Vs2015 permanent configuration opencv file

Open vs2015 and create a new project. The steps are as follows

(1)

 

(2)

(3) Add. Cpp file

There are two forms

1) . project – > source file – > right click – > add – > new item, as shown below

 

2) . use the shortcut key Ctrl + Shift + a directly

 

(4) View – > Property Manager

(5)

Find win32.user and double-click to open it

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

 

(7) Add include directory

If my file path is:

E:\20161123\opencv\build\include

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

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

Then confirm, find the library directory under VC + + directory, edit it again, and add lib path

 

 

For example, my path is: e: 20161123, opencv, build, x86, vc12, lib

Click OK after adding.

(8) Linker – > input – > additional dependencies

 

Pay attention to the opencv version at this time

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 the d after the file name.

According to the opencv version, the above library name can be directly copied. Closing vs2015 prompts you to save the configuration. Then re open the project and enter the following code to test whether opencv is configured successfully

#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 title of the window displaying the image to Lena and the attribute to auto size
  Imshow ("Lena", srcimage); // display pictures

  waitKey(0);

  return 0;
}

The operation results are as follows:

 

be careful:

1. The pictures used in the program are stored in the project directory, otherwise the path name should be input

2. The first run may prompt the lack of. DLL library, such as msvcp120d. DLL, msvcr120d. DLL, etc

Download the corresponding dynamic link library on the Internet and put it into the system file

For a 32-bit operating system, put: C: Windows / system32

For the 64 bit operating system, put the

The above is the whole content of this article, I hope to help you in your study, and I hope you can support developeppaer more.