Wednesday, September 14, 2011

Install opencv 2.31

http://www.arunkumarr.co.in/site/index.php/articles/10-configuring-opencv-23-in-visual-studio-2008



Download OpenCV-2.3.0-win-superpack.exe from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/
Run OpenCV-2.3.0-win-superpack.exe and copy the generated folder OpenCV2.3 to C drive
Open Microsoft Visual Studio 2008 and click Tools->Options
alt
Select Projects and Solutions and then VC++ Directories. Select Include files in Show directories for: drop down menu. Add the following paths. 
C:\OpenCV2.3\opencv\include\opencv
C:\OpenCV2.3\build\include
alt
Select Library files in Show directories for: drop down menu. Add the following path.
C:\OpenCV2.3\build\x86\vc9\lib
Now we have added include and library file paths and this need to be done only for the first time.
Create an new project in Visual Studio 2008
Click Project->Properties. Select Configuration Properties -> Linker -> Input. Make sure you select Debug in 'Configuration:' drop down menu and then add the following to the Additional Dependencies.
opencv_features2d230d.lib opencv_highgui230d.lib opencv_core230d.lib opencv_imgproc230d.lib opencv_ml230d.lib opencv_objdetect230d.lib opencv_video230d.lib opencv_contrib230d.lib opencv_calib3d230d.lib
Now select Release in 'Configuration:' drop down menu and then add the following to the Additional Dependencies  and click OK
opencv_features2d230.lib opencv_highgui230.lib opencv_core230.lib opencv_imgproc230.lib opencv_ml230.lib opencv_objdetect230.lib opencv_video230.lib opencv_contrib230.lib opencv_calib3d230.lib
alt
alt
Add C:\OpenCV2.3\build\x86\vc9\bin to the environment path as shown in screenshot below. You may need to restart the system after setting this.
alt
To test whether the OpenCV is working, add a C++ file under Source files as shown in screen shots below.
alt
 alt
Copy the sample program given below and build it and run. An image will be displayed in a window.
01.#include
02. 
03.#include
04. 
05.using namespace cv;
06. 
07.int main()
08. 
09.{
10. 
11.namedWindow("wnd");
12. 
13.Mat img;
14. 
15.img= imread("C://Users//Public//Pictures//Sample Pictures//Desert.JPG"); //image path
16. 
17.imshow("wnd",img);
18. 
19.cvWaitKey();
20. 
21.return 0;
22. 
23.}

No comments:

Post a Comment