Вы находитесь на странице: 1из 8

An OpenCV Installation and Getting started guide for

Windows
Dear Madhav Sir,
This guide will help you install OpenCV library version 4.0b (I used this version for the
code submitted to you). I used it with Visual C++ 6.0 Professional edition on windows
XP. I am not sure In case you are using any other configuration please let me know.

Download link for OpenCV: please download v4.0 b release.


http://sourceforge.net/projects/opencvlibrary/

Important Note: Install the software in the default directory i.e. “C:\Program Files\OpenCV”.

Setting up Visual C++ for OpenCV:


Setting up system environment variable:
Go to taskbar, click ”start” and then click “Control Panel”. Turn to “Classic View” (upper left
corner) if the current view is “Category View”. Now double click on the “System” icon to open the
“System Properties” dialog box. Click on the “Advance” tab, and then on the “Environmental
Variables” button towards the bottom of the dialog box. Under the second list, (please see the
image below) i.e., “System Variables”, find the variable called “Path”. Select it, and then click
“Edit”.
Add the path of the OpenCV “bin” folder in the “Variable value” text box. To do this, we
may append the path to the end of the list (please see the image below) make sure that
semicolons separate the entries. If the default destination was chosen during installation, your
path should be “C:\Program Files\OpenCV\bin”. If not, find the path to OpenCV’s “bin” folder, and
add it in the “Variable value” text box. Click “OK” on all open dialogs, and close the Control Panel.
You must now restart your computer for the PATH variable to be updated. Now, OpenCV will be
able to find the required DLLs it needs. This completes setting up the PATH variable.

Preparing Visual C++ for use:


Start Visual C++ 6.0. From the menu, click “Tools”, and then “Options…”
In the “Options” dialog box, find the “Directories” tab and click it. Currently, we’re looking at the
directories specified for the include files. You can switch to other file types such as library
files by clicking the arrow under “Show directories for”. Right now, let’s leave it on “Include
files”.

Assuming the default destination folder during installation, add the following directories. (Your
directories may be different if you chose to install OpenCV in a different location. If so, change the
paths accordingly.)
 C:\Program Files\OpenCV\cv\include
 C:\Program Files\OpenCV\cxcore\include
 C:\Program Files\OpenCV\otherlibs\highgui
The directories for the needed include files are finished. Next, switch to “Library files”.

Add the directory “C:\Program Files\OpenCV\lib” to the list of directories. Switch to “Executable
files”. Add “C:\PROGRAM FILES\OPENCV\BIN”.

Be sure to click “OK” on the “Options” dialog box, or you’ll be doing all of this over again.

Creating a new project:


These settings specified here are specific to a project. If you want to create another project, these
settings will have to be made to that one as well. However the settings we made previously i.e.
adding the new directories etc. are inherited by all Visual C++ projects.
Start Visual C++. Go to “File” click on “New” A dialog box for creating a new file/project/etc. will
appear. We’re interested in creating a new project, so click on the “Projects” tab if it’s not already
selected. Several fields are on the right hand side (See the image below).
For “Project name”, enter appropriate project name. You may choose any location you wish.
Check “Create new workspace” if it’s not checked. Check “Win32” as the platform if it’s not
checked. Now, select “Win32 Console Application” from the project list on the left. Finally, click
“OK
A second dialog box will appear (See the image below) asking about what type of console
application we want to create. Leave “An empty project” selected and click “Finish”. Once “Finish”
is clicked, a skeleton project will be created with no files. Another window will appear informing
you about the successful creation of a skeleton console application project. Click “OK”.

Before creating the actual application, we need to modify the project settings to our
liking. From the menu, click “Projects” and then click “Settings…”.
Once “Settings…” is clicked, the “Project Settings” dialog box will appear. Under
“Settings For” at the top left, switch to “All Configurations”. (see the image below).
Click the “Link” tab, and then select “General” for the “Category”.
Under “Object/library Modules” add the following libraries.
 cv.lib
 cxcore.lib
 highgui.lib
 strmbase.lib

Once the libraries have been entered, click “OK”. Now, we’ll add a file to our project.
From the menu, click “File” and then click “New…”, as before. Instead of the “Projects”
tab, we need the “Files” tab, so click it. From the choices, choose “C++ Source File”. On
the right hand side, enter a file name. (We use “image1” as a file name). The location
should already be specified. “Add to project” should already be checked, and set to
“image1”. If not, change it. Once done, click “OK”.
After clicking “OK”, the file should be open and ready for coding. You can also directly
copy paste and build my code to run it. I hope this will help you. It seems little tedious
job in the beginning but two three codes will make it seem easy.
Should there be any more explanation required or any problem, please let me know.

Yours truly,
Shadab Khan
5th Sem, BE
MIT Manipal

+91 99004 04678

Вам также может понравиться