OpenCV: Open Source Computer Vision

OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision.

OpenCV is released under a BSD license and hence it’s free for both academic and commercial use. It has C++, C, Python and Java interfaces and supports Windows, Linux, Mac OS, iOS and Android. OpenCV was designed for computational efficiency and with a strong focus on real-time applications. Written in optimized C/C++, the library can take advantage of multi-core processing.

This post will describe setting up openCV on your system and its integration with visual studio. If you want opencv’s integration with other tools like android studio, then this post is not for you.

  1. Download openCV
  2. Run the exe and extract the file in directory say C:\
  3. Download visual studio. For me vs 2015 professional worked well. Download it from here.
  4. Now you need to change some global system parameters. This post describes it very well. Just take care of the fact that in linker’s additional dependency don’t blindly copy what was written in the post, but go to the folder “C:\opencv\build\x86\vc11\lib”(may vary depending upon your opencv version) and actually copy the name of the libs.
  5. After setting up your openCV and visual studio, download some sample opencv files and play with it. Just to begin with copy the following code in your consoleApplication.cpp file.
    Remember to add Deepika_Padukone.jpg image in your project
#include "stdafx.h"
#include "opencv2/core/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/photo/photo.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/contrib/contrib.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/core.hpp"

using namespace cv;
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, const char** argv )
Mat img = imread("Deepika_Padukone.jpg", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'

if (img.empty()) //check whether the image is loaded or not
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

waitKey(0); //wait infinite time for a keypress

destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

return 0;

Leave a Reply

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