OpenCV Installation Guide
This guide describes how to install and link the OpenCV library 2.1 together with Visual Studio 2008 in order to compile the lab projects developed for this course. Once this process has been completed, full control over the OpenCV library files will be available.
Notes:
- OpenCV is an evolving project, therefore new iterations of the software will be released in the future. However as the software changes many of the installation steps demonstrated in this document will be the same or will get simpler
- Building the OpenCV libraries with the Intel IPP will not be covered in this guide, however information on this topic can be found at http://software.intel.com/en-us/articles/intel-ipp-support-model-changed-in-opencv-2x/
- The compiler that is used in this installation guide is Visual C++ 2008 Express Edition.
1) Installing VS2008 Express
- Download Visual C++ 2008 Express Edition from http://www.microsoft.com/express/Downloads/#2008-Visual-CPP
- Install Visual C++ 2008 Express Edition
2) Installing OpenCV 2.1
- Download OpenCV 2.1 as shown in the image below from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
- When installing OpenCV 2.1, make sure that the files are added to the system path for all users
- After Installation is complete restart computer.
3) Linking OpenCV 2.1 with Visual C++
- Open Visual C++
- Open Tools --> Options. Under Projects and Solutions --> VC++ Directories
- Select Show directories for: Library files and create a new line with the location of the OpenCV lib folder that was specified during installation
- Select Show directories for: Include files and create a new line with the location of the OpenCV include\opencv folder that was specified during installation
4) Test Project
To make sure that everything is functional, a test project will be created to use OpenCV to display an image included in OpenCV sample programs.
- Open Visual C++
- Go File->New->Project
- When the New Project dialog appears select Win32 Console Application and enter a project name
- Make sure that your project is empty
- Add a .cpp file to you project called main.cpp
- Press Alt+F7 or select from the tool menu Project->"your projects name" Properties
- Open Configuration Properties->Linker->Input
- Beside Additional Dependencies add cv210.lib highgui210.lib cxcore210.lib
- Copy the following code into main.cpp
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
using namespace cv;
int main()
{
char img_file[] = "C:\\OpenCV2.1\\samples\\c\\lena.jpg";
IplImage* img = cvLoadImage(img_file);
cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);
cvShowImage("Example1",img);
cvWaitKey(0);
}
- Compile and execute. Congratulations you have just written your first OpenCV program!
No comments:
Post a Comment