Hi Guys. In this post I explain:
Btw, My other programs in OpenCV will be posted here.
I see lot of you facing problems in configuring OpenCV 2.1 for Visual Studio on Windows OS. In this post I seek to explain the way it is to be configured.
Step1: Download
Download OpenCV from http://sourceforge.net/projects/opencvlibrary/
Present version is 2.2, but I show here working with OpenCV 2.1 (configuring OpenCV 2.2 will be the same if you follow this procedure).
Step2: Install OpenCV
Double click to install the downloaded file. I am sure nobody needs help on this. It usually is installed in C:\ as "C:\OpenCV2.1"

Steps 3 to 14: Configure OpenCV with Visual Studio 2008
Step3: Open Visual Studio 2008. I am assuming you have already installed Visual Studio with VIsual C++ editor. Select New->Project
Step4: Give the name of the project, the name i've given is "OpenCam". Make sure that it is a "Win32 Console Application" program.
Step5: Right click on the Project in Solution Explorer and select properties.
Step6: Now we configure the Visual Studio to include the headers that come with OpenCV 2.1. Go to Configuration Properties->C/C++->General->Additional Include Directories and select to add new directories.
Step 7: Open the OpenCV installation directory, browse through the folders "C:\OpenCV2.1\include\opencv" and copy the address to the path. Basically, what we are doing here is to browse into the OpenCV C/C++ headers folder (look for ".h" files). Paste it into the Visual Studio window already opened (into additional include directories). It will look something as show below. Press OK.
Step8: Now we configure the Visual Studio to look for libraries installed (OpenCV libraries).Go to Linker->input->Additional Dependencies and click to add new libraries.
Step 9: Open the OpenCV installation directory, browse through the folders "C:\OpenCV2.1\lib" and copy the address to the path. Basically, what we are doing here is to browse into the OpenCV C/C++ libraries folder (look for ".lib" files). Paste it into the Visual Studio window already opened (into additional dependencies).
Step 10: Add the libraries "cv210.lib", "cvaux210.lib", "cxcore210.lib", "highgui210.lib" into the additional dependencies.Please make sure that you give complete path to the above mentioned ".lib" files. It SHOULD look something as below.
Step 11: Press OK. If you do not have a program of your own to run by copying the following, else proceed to Step 12.
Step 12: Now its time to build the solution. Go to Build->Build Solution.
Step 13: If everything is right (it will be if you are following the exact steps that I'm following here) something like this should show up in the output window.
Step 14: Now its time to run the program. Click on run and BING! Its there. You should be able to see yourselves (if you are running the program and assuming you have a webcam of your own attached to your computer).
Basically what we've done is give "exact path" to the include directories folder and "excat path" to the ".lib" files that are to be included to run the program and it works.
Cheers. Check out the other OpenCV articles over here.
- Configuring OpenCV 2.1 on Visual Studio 2008.
- A sample OpenCV 2.1 program to run on Visual Studio.
Btw, My other programs in OpenCV will be posted here.
I see lot of you facing problems in configuring OpenCV 2.1 for Visual Studio on Windows OS. In this post I seek to explain the way it is to be configured.
Step1: Download
Download OpenCV from http://sourceforge.net/projects/opencvlibrary/
Present version is 2.2, but I show here working with OpenCV 2.1 (configuring OpenCV 2.2 will be the same if you follow this procedure).
Step2: Install OpenCV
Double click to install the downloaded file. I am sure nobody needs help on this. It usually is installed in C:\ as "C:\OpenCV2.1"

Steps 3 to 14: Configure OpenCV with Visual Studio 2008
Step3: Open Visual Studio 2008. I am assuming you have already installed Visual Studio with VIsual C++ editor. Select New->Project
Step4: Give the name of the project, the name i've given is "OpenCam". Make sure that it is a "Win32 Console Application" program.
Step6: Now we configure the Visual Studio to include the headers that come with OpenCV 2.1. Go to Configuration Properties->C/C++->General->Additional Include Directories and select to add new directories.
Step 7: Open the OpenCV installation directory, browse through the folders "C:\OpenCV2.1\include\opencv" and copy the address to the path. Basically, what we are doing here is to browse into the OpenCV C/C++ headers folder (look for ".h" files). Paste it into the Visual Studio window already opened (into additional include directories). It will look something as show below. Press OK.
Step8: Now we configure the Visual Studio to look for libraries installed (OpenCV libraries).Go to Linker->input->Additional Dependencies and click to add new libraries.
Step 9: Open the OpenCV installation directory, browse through the folders "C:\OpenCV2.1\lib" and copy the address to the path. Basically, what we are doing here is to browse into the OpenCV C/C++ libraries folder (look for ".lib" files). Paste it into the Visual Studio window already opened (into additional dependencies).
Step 10: Add the libraries "cv210.lib", "cvaux210.lib", "cxcore210.lib", "highgui210.lib" into the additional dependencies.Please make sure that you give complete path to the above mentioned ".lib" files. It SHOULD look something as below.
Step 11: Press OK. If you do not have a program of your own to run by copying the following, else proceed to Step 12.
Step 12: Now its time to build the solution. Go to Build->Build Solution.
Step 13: If everything is right (it will be if you are following the exact steps that I'm following here) something like this should show up in the output window.
Step 14: Now its time to run the program. Click on run and BING! Its there. You should be able to see yourselves (if you are running the program and assuming you have a webcam of your own attached to your computer).
Basically what we've done is give "exact path" to the include directories folder and "excat path" to the ".lib" files that are to be included to run the program and it works.
Cheers. Check out the other OpenCV articles over here.
i had done the same thing..but its showing errors..wat to doo??
ReplyDeleteWhat is the error?
ReplyDeleteHi
ReplyDeleteis not visible the two include; highgui.h and cv.h
If you are using OpenCV 2.2, headers will be under
ReplyDeleteC:\Program Files\OpenCV2.2\include\opencv
and
C:\Program Files\OpenCV2.2\include\
So yo need to add both folders above in STEP 6.
If you are using OpenCV 2.1, headers will be under:
C:\OpenCV2.1\include\opencv\
So you need to add the above folder in STEP6.
Also add the following libraries in 2.2
ReplyDeleteC:\ProgramFiles\OpenCV2.2\lib\opencv_core220d.lib
C:\ProgramFiles\OpenCV2.2\lib\opencv_highgui220d.lib
C:\ProgramFiles\OpenCV2.2\lib\opencv_video220d.lib
C:\ProgramFiles\OpenCV2.2\lib\opencv_ml220d.lib
C:\ProgramFiles\OpenCV2.2\lib\opencv_legacy220d.lib
C:\ProgramFiles\OpenCV2.2\lib\opencv_imgproc220d.lib
Hi,
ReplyDeleteI'm usin OpenCV2.1 under Win7 and a HP 3100 HD WebCam set to 720p.
I compile your example without any error, but when i run the program, a black screen appear. If I move the mouse into the black screen the pointer change in a white cross.
Do you have any idea because the image do not appear?
Bye
Leo
the above code is the program. It would be a issue with the OS/Drivers rather than the program. Try closing all other programs and then try the above methods
ReplyDeleteThanks for the post, solved my problem of setting OpenCV 2.1 with Visual Studio 2008.
ReplyDeleteHi, Im jyothi,
ReplyDeletei have tried to execute the above code and followed all steps properly....but im getting output but not my img..just blank gray windoe..
even my web cam is on im not getting my webcam seeing me.
It might probably be due to improper image capturing. You can try different parameter values in CvCapture* capture = cvCaptureFromCAM(1); instead of "1". Try -1, 0, 2, etc. I think -1 points to next available camera. Also check if your Webcam works with a different software(logitech, etc).
ReplyDeleteits giving error
ReplyDelete2>------ Skipped Build: Project: pro1PS, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration
please help
hey
ReplyDeletei have tried the entire procedure and I am constantly getting this error:
fatal error C1083: Cannot open include file: 'C:\OpenCv2.1\include\cv.h': No such file or directory.
I have set the environment variable also. Please do reply.Getting really stuck
Hey, I've done exactly what you have done, but I am getting errors.
ReplyDeleteI am using openCV2.1 and vb 2008 c++
the errors are :
error C2006: '#include' : expected a filename, found 'newline'
fatal error C1083: Cannot open include file: '': No such file or directory
Could you please help me
It was a formatting error on the website. Please look at the code now. I'll soon be re-posting this with latest OpenCV version on latest version of Visual Studio.
ReplyDeleteI am using Visual studio 2008 and OpenCV 2.1 it is showing 1>LINK : fatal error LNK1104: cannot open file 'C:\OpenCV2.1\lib.obj' on your demo program
ReplyDeleteI think its an issue with your Path settings that I mentioned in my post above. Please make sure that the files exist that you are pointing to.
ReplyDeletehi, i add all dll file but when i run the file, it saying highgui210.dll file is missing.
ReplyDeleteits crazy cas i add all the lin file according to u r ins-traction whic is step no 10.
thanks it's work
ReplyDelete