OpenCV and Visual Studio 2015, the hard way

Many computer vision projects rely on OpenCV. If you want to get going with OpenCV with Visual Studio on Windows without taking the easy route of just getting a NuGet package (maybe you want a specific version or a fork…), this article is meant to remind you (and me) what you need to do.

Download and install

Download the Windows version of OpenCV available on the official website.

This is what the download button looks like

Extract it to a trusted place on your disk. I prefer to keep it on the root of one of my drives.

This is what the extract dialog looks like

Setting the environment variables

To make the set up of any future project as easy as possible, you need to set the path to set an environment variable for the OpenCV install directory:

Setting the directory

You also have to add the OpenCV binaries to the path:

Setting the path

Configuration of your Visual Studio project

Create a new Visual C++ Project, an Empty Project is a fine fine to starting point.

Access the solution properties from the Solution Explorer pane:

Accessing the property pages

Before modifying anything in the Property Pages, make you are making the modifications to the proper configuration:

Add the additional includes directories from the C/C++ -> General page:

From the Linker -> General page, add the library directories:

In the Linker -> Input page, set the additional dependencies:

Depending of the version of OpenCV and your compiler, you might need to set the _CRT_SECURE_NO_WARNINGS flag from the C/C++ -> Preprocessor page.

That is all.

Success



Enter your desired user name/password and after your comment has been reviewed by an admin it will be posted and your account will be enabled. If you are already registered please login before posting.