Many of us ofcourse Programmers facing problem in OpenCv with Visual Studio 2010. Problem encounter at the beginning. Means installation of OpenCv in VS_2010 specially in windows 7 64bit computer. I have created a video in which this type of installation problem has solved. Here you can see the video click here.
Also I am describing here all the steps for installation. You may watch video or go step by step process to install.
Step-1:
software requirement :
1. Microsoft Visual Studio 2010 express
download link Visual Studio 2010 express (download c++ addition)
2. OpenCv Latest Version
download link http://sourceforge.net/projects/opencvlibrary/
Step-2:
After downloading vs2010 install it and when you run OpenCv .exe file it will extract all data to a directory in your computer.
It will look like this (for opencv)
Step-3:
Now you have done installing vs2010 and opencv. Now you have to configure property sheet in vs2010 project to properly run your c++ image-processing code. In property sheet configuration we just import opencv and it functions to visual studio to perform image-processing action. So get ready for that. step 4 explain how to configure property sheet.
Step-4:
Open visual Studio 2010 and create new project. Select win32 and console application as shown in figure below and click Ok.
Then click next.
Then check on empty project and click finish.
Next go to property manager which is below right side in window.
Now right click on debug |win32 and select last option property. Then it will look like as image below
In above image there are three points.
4a. VC++ directories
4b. c/c++
4c. Linker
4a. VC++ directories :
There are two field.
include directory and library directory
In "include directory" you have to add include folder of opencv
in my case it is in folder "C:\Users\Krishna\Downloads\Programs\opencv\build\include"
In "Library directory" you have to add library folder of opencv as like "C:\Users\Krishna\Downloads\Programs\opencv\build\x86\vc10\lib"
this tutorial only describe for windows 64 bit users.
4b. C/C++ :
and add the include folder of opencv
4c. Linker :
There will be two tab "general" and "input"
In general tab add in additional library directories
now go to the input tab.
It is serious part of step 4 and you need to mare care about this part.
go to directory "C:\Users\Krishna\Downloads\Programs\opencv\build\x86\vc10\lib" and copy the name of all debug dll file and paste it in input part as in figure below
how to identify debug dll file?
simple way is that if a file contains atleast one 'd' letter then it will be debug dll file. I am using opencv 4.6 so in my case it is
opencv_calib3d246d.lib
opencv_contrib246d.lib
opencv_core246d.lib
opencv_features2d246d.lib
opencv_highgui246d.lib
opencv_imgproc246d.lib
opencv_legacy246d.lib
opencv_nonfree246d.lib
opencv_objdetect246d.lib
opencv_photo246d.lib
opencv_stitching246d.lib
opencv_video246d.lib
opencv_videostab246d.lib
after that click Ok and again Ok to close property sheet.
Now you have done.
Step-5:
Now go to solution explorer and right click on source -> add new source file and add c++ file
build and run your code.
Here is sample code just copy and paste.
#include <opencv\cv.h>
#include <opencv\highgui.h>
using namespace std;
using namespace cv;
int main()
{
IplImage* img = cvLoadImage("c:\\p.jpg");
cvNamedWindow("Input_Image");
cvShowImage("Input_Image",img);
waitKey(300);
system("pause");
return 0;
}
#include <opencv\highgui.h>
using namespace std;
using namespace cv;
int main()
{
IplImage* img = cvLoadImage("c:\\p.jpg");
cvNamedWindow("Input_Image");
cvShowImage("Input_Image",img);
waitKey(300);
system("pause");
return 0;
}
I hope you run your code successfully. For any help regarding to this topic please comment I will help you always.
Thank You.