1. Steps by steps to install OpenCV in MVS2010
1.1 Downloading and Installing OpenCV
Go to homepage: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/
Select OpenCV-2.3.0-win-superpack.exe file and download it.
Go the folder where you downloaded the executable file in Step 2 and select “Run as Administrator”.
The executable file is essentially an archive of files with an extractor built in. It will ask you to select the location where you would like it to extract all its contents. Here I choose: C:\OpenCV2.3.
1.2 Configure VS2010 to use OpenCV library
Way 1: You perform follow page at References Item. This way is OK but it has disadvantages when you move your porojects to another places, then you must reconfigure projects.
Way 2:
1.3 Example capture video from webcame
cvCapture
// cvCapture.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <opencv\highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
int c;
// allocate memory for an image
IplImage *img;
// capture from video device #1
CvCapture* capture = cvCaptureFromCAM(1);
// create a window to display the images
cvNamedWindow("cvCapture", CV_WINDOW_AUTOSIZE);
// position the window
cvMoveWindow("mainWin", 5, 5);
while(1)
{
// retrieve the captured frame
img = cvQueryFrame(capture);
// show the image in the window
cvShowImage("cvCapture", img);
// wait 10 ms for a key to be pressed
c = cvWaitKey(10);
// escape key terminates program
if(c == 27)
break;
}
return 0;
}
Result: