VS2013 configure OpenCV

Download OpenCV and install

First go to https://opencv.org/releases.html , download the required version of Win pack, it is an executable file in .exe format, double-click directly, and then select the installation path to complete the installation.

Set environment variables

Add the path of the dynamic link library (dll) of OpenCV to the system environment variable Path. The specific steps are shown in the following figure.


First, right-click My Computer, then select Properties -> Advanced System Settings -> Environment Variables -> System Environment Variables Path -> New Environment Variable, that is, the path of OpenCV's dynamic link library (dll), mine is G:\opencv\build\X86\bin .
Where: X86 means 32 bits, X64 means 64 bits.
vc8 = Visual Studio 2005, vc9 = Visual Studio 2008, vc10 = Visual Studio 2010, vc11 = Visual Studio 2012, vc12 = Visual Studio 2013, vc14 = Visual Studio 2015.
Note: After the environment variables are configured, you need to restart the computer to take effect!

Configure VS2013

Create a new project in VS2013

First open VS2013, select File -> New -> Project, and then select Win32 Console Application, as shown in the following figure.


Check Empty Project and click Finish to create a new project.

Add C++ source files

Project -> Source File -> Add -> New Item, add C++ file, as shown in the following figure.

Configuration property page

Right-click the project, select properties, select the platform, the default is Win32, you can add X64 through the configuration manager .
The platform here is very particular and needs to be paid attention to in actual development.

Add include directory

According to the installation path, as shown in the following figure.

Add library directory

The library directory is the path of the dynamic link library, which is the path added by the system environment variable above.

Add additional dependencies

Additional dependencies are dynamic link libraries, which are divided into two types: opencv_calib3d2410.lib and opencv_calib3d2410d.lib. The difference is: opencv_calib3d2410.lib is the Release version, and opencv_calib3d2410d.lib is the Debug version.


verify

You can write the code in the C++ source file to read the image and display it through OpenCV, compile and execute it, and verify whether the configuration is successful.

Summarize

In this method, only the current project can be configured. If you don't need to configure the future projects, you can configure the property page as shown in the figure below, and the steps are the same as above.

In actual development, the number of bits of the system (X86, X64), the version of OpenCV, and even the version of VS must be corresponding or compatible.
Because, for projects developed by others, the system bitness, OpenCV version, and VS version are likely to be different from our own computer configuration, so we must keep it consistent at this time.
According to different needs, we can install multiple versions of VS and OpenCV on the computer, and then configure them accordingly.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843399&siteId=291194637