Up and running with OpenCV

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code.

This article will guide you in how to install openCV on your windows machine and writing Simple Image Opening Example.

Let’s start with installing OpenCV. There are actually two ways you can fulfill this task. One by directly downloading and using pre-built libraries and another by making your own libraries by compiling OpenCV Source Code. In this tutorial we will discuss only first one.

Installation by Using the Pre-built Libraries:

  • Download latest OpenCV installer from here.
  • Make sure you have admin rights. Start installer executive file.
  • Install OpenCV in suitable drive and check the installation at the chosen path.
  • Now we need to setup the environment for this builds.

First we set an environment variable to make easier our work. This will hold the build directory of our OpenCV library that we use in our projects. Start up a command window (cmd.exe) and enter:

  • Now you need to add bin directory of above chosen folder to system path. This is cause you will use the OpenCV library in form of “Dynamic-link libraries” (also known as DLL). Inside these are stored all the algorithms and information the OpenCV library contains.
  • For Doing programming we are going to use Visual Studio. Before we create any project we need to setup some parameters inside Visual Studio
  • Go to Tools -> Options -> Projects & Solutions -> VC++ Directories
  • Select Include Files and Put these paths to it.

  • Now select Library Files and Put these paths to it.

Now we are done with the installation. Let’s start our first project in OpenCV using C.

  • Go to File -> New -> Project
  • Select Win32 Console Application and click Finish
  • Project will be created and default .cpp File will be created with main function in it.
  • Right Click on newly created Project. Go to its Properties
  • Go to Project properties menu C/C++ -> General -> Additional Include Directories. Now put following paths to it:

  • Go to Project properties menu Linker -> Input-> Additional Dependencies. Now put following paths to it (make sure that these file presents in library directory of OpenCV builds, If not make necessary changes in following file names):

  • Let’s write simple program for opening and displaying image:

voila it’s done !!!

You can can have various experiments over this library like below. Soon we will come with other stunning tutorials on Video Processing in OpenCV. Stay Tuned…

Note: If you get runtime error like “MSVC.dll not found” then Go to Project Properties -> linker -> general. Enable Incremental Linking = No. this may solve your Problem.


Ganesh Bhosale

From a laptop to a full organization, Ganesh has traveled a tough road. A commando, armed with the latest tech & a huge warehouse of knowledge, he leads by example & is here for the long haul. His strong belief in giving back more has borne rich fruits, both for his employees & clients.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *