文档搜索 > BASIC/ADVANCED MULTIMEDIA IMAGING Updated: 4 August 2009 Visual Studio 2008 Version A Basic Introduction to OpenCV By Tobi Vaud

BASIC/ADVANCED MULTIMEDIA IMAGING Updated: 4 August 2009 Visual Studio 2008 Version A Basic Introduction to OpenCV By Tobi Vaud

Page 1
Page 1
BASIC/ADVANCED MULTIMEDIA IMAGING Updated: 4
th
August 2009 Visual Studio 2008 Version A Basic Introduction to OpenCV By Tobi Vaudrey
Layout
Useful Links ................................................................................................................... 2 MOST IMORTANT – Learning OpenCV Book! ...................................................... 2 Visual Studio and other Microsoft Products Free Download .................................... 2 OpenCV (Open Computer Vision Library) ............................................................... 2 Other Possibly Useful Links ...................................................................................... 2 Getting OpenCV Working on your PC .......................................................................... 3 Create New Project .................................................................................................... 3 OPTION 1: Customize Project Options ..................................................................... 6 OPTION 2: Customize Global Options ..................................................................... 7 Final notes .................................................................................................................. 9 Common Problems....................................................................................................... 10 Missing DLL’s ......................................................................................................... 10

Page 2
Page 2
Useful Links
MOST IMORTANT – Learning OpenCV Book!
Get your hands on a “Learning OpenCV” book. This book has a lot of info and hints/tips on programming with OpenCV. It explains some theory as well.
http://oreilly.com/catalog/9780596516130/
Visual Studio and other Microsoft Products Free Download
Link: http://msdn.cs.auckland.ac.nz/ Recommended downloads: ? Visual Studio 2008 ? MSDN (if you have a lot of space as it is available online) IMPORTANT NOTE: Use the same version of Visual Studio when editing your programs! If you switch between Visual Studio 2005 and 2008, then you may get bugs and your code will not work. It can take a while to figure it out. You have been warned.
OpenCV (Open Computer Vision Library)
Link to download for Windows:
http://sourceforge.net/projects/opencvlibrary/
Link to Official Website:
http://www.intel.com/technology/computing/opencv/index.htm
Link for “cheat sheet” and introduction to OpenCV:
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html
Wiki for documentation on OpenCV:
http://opencvlibrary.sourceforge.net/
OpenCV Reference Manual:
http://www.cs.unc.edu/Research/stc/FAQs/OpenCV/OpenCVReferenceManual.pdf
OpenCV User Group:
http://groups.yahoo.com/group/OpenCV/
Other Possibly Useful Links
IPP (Intel Performance Primatives):
http://www.intel.com/cd/software/products/asmo-na/eng/302910.htm
Only recommended for the people who are very keen. This is a library that will be used by OpenCV if it is installed. It is a library that optimises your processor for running Computer Vision mathematics. I.e. it will speed up your programs when you run them.

Page 3
Page 3
Getting OpenCV Working on your PC
First you need to get a copy of Visual Studio 2008. Secondly, you need to install OpenCV. (See page 1 for links.) Now you are ready, but there are some minor things that need to be set up. IMPORTANT NOTE: where “C:\Program Files\OpenCV” is used in this setup, make sure that this is the location where OpenCV is installed. For Computer Science Students: On all Science Lab machines, OpenCV is installed under the default path, i.e. “C:\Program Files\OpenCV” For Mechanical Engineering Students: OpenCV is installed under the MECHENG409 folder, i.e. “S:\Mech\Courses\MechEng409\OpenCV”
Create New Project
? Within Developer Studio create new application: ? Select from menu "File"->"New..."->"Projects" tab. ? Choose "Visual C++” > “Win32” > “Console Application".

Page 4
Page 4
? Type the project name and choose location ? Click OK.. ? In the Application Wizard, click Next. ? I recommend unchecking “Precompiled headers” ? Then click Finish.

Page 5
Page 5
? After the above steps done Developer Studio will create the project folder (by
default it has the same name as the project), <project name>.vcproj file, Solution <project name>.sln and, Three Source files: <project name>.cpp, stdafx.cpp and stdafx.h. StdAfx files are precompiled header files, which I find cause more pain than they’re worth.
? For example, consider that we have created a new "Hello" Project. Open the
Hello.cpp file, and include the OpenCV-related #include directives:
#include <cv.h> #include <cxcore.h> #include <highgui.h>
? Note that these should be included after stdafx.h (if using pre-compiled
headers) or you may get build errors.
? Now type some OpenCV code, and Build the Solution by pressing the F7 Key.
There should be linker errors. E.g.
IplImage * src = cvLoadImage("picture.bmp",1);
? To resolve these, add dependency projects into workspace (following steps) ? Choose from menu: "Project" -> "Properties". (Or right click on your project
in the left hand tree)
? Choose “Configuration Properties” -> "Linker" tab -> "Input" category ->
"Additional Dependencies:"
? Add the paths for all necessary import libraries (cxcore.lib cv.lib highgui.lib
cvaux.lib)

Page 6
Page 6
OPTION 1: Customize Project Options
NOTE: If you do NOT do this, you will NEED to do OPTION 2. PROS: - Can copy the project and run from anywhere as long as the paths are the same. - Perfect for the Lab PC’s CONS: - Needs to be set up on every new project you create.
? Choose from menu: "Project" -> "Properties". (Or right click on your project
in the left hand tree)
? Choose "Linker" tab -> "General" category -> "Additional Library
Directories”, Add the paths:
"C:\Program Files\OpenCV\lib"
? Now, choose "C\C++" -> "General" -> "Additional Include Directories”
"C:\Program Files\OpenCV\cv\include" "C:\Program Files\OpenCV\cxcore\include" "C:\Program Files\OpenCV\otherlibs\highgui" "C:\Program Files\OpenCV\cvaux\include"

Page 7
Page 7
? Click OK to save your settings. ? That’s it, you should be able to compile and run your code ?
OPTION 2: Customize Global Options
NOTE: If you do NOT do this, you will NEED to do OPTION 1. PROS: - Every project that is set up will work straight away. - Perfect for home PC’s CONS: - Will not work very well on Lab PC’s.
? Open the Visual C++ Application. In the menu bar, select Tools->Options ? In the listing, choose Projects and Solutions -> VC++ Directories. ? First, select Library files from the "Show Directories for" List Box. ? Click the Insert New icon, and locate the folder where you have installed
opencv.
? Consider that it is installed in "C:/Program Files/OpenCV". ? In the Library files list, locate and add:
"C:\Program Files\OpenCV\lib"

Page 8
Page 8
? Now choose Include files in the list box, and locate and add the following
directories:
"C:\Program Files\OpenCV\cv\include" "C:\Program Files\OpenCV\cxcore\include" "C:\Program Files\OpenCV\otherlibs\highgui" "C:\Program Files\OpenCV\cvaux\include"

Page 9
Page 9
? Next, choose source files in the list box, and locate and add the following
directories:
"C:\Program Files\OpenCV\cv\src" "C:\Program Files\OpenCV\cxcore\src" "C:\Program Files\OpenCV\cvaux\src" "C:\Program Files\OpenCV\otherlibs\highgui"
? Now click OK in the Options dialog. ? You have successfully configured the global settings. ? That’s it, you should be able to compile and run your code ?
Final notes
If you have any issues, double check the steps above. Also look at the other resources available on the net.

Page 10
Page 10
Common Problems
Missing DLL’s
You may get the following error message if the PATH has not been set for OpenCV. To fix this there are some different options: 1. If you do not have admin rights to the computer, or you are using a “hotseat” computer, i.e. you can use multiple computers but log into your profile. Then the best solution is to copy and paste the required *.DLL files from ..\OpenCV\bin to your ..\<MSVisProj>\ folder (i.e., where your project files are). 2. If you have admin rights on the computer, then you can also update your PATH directory: to change your PATH settings, right-click 'My Computer', click 'Properties' and look at the 'Advanced' tab. There you will see a button marked 'Environment Variables' - click it. In the window that then appears, look for the PATH option in the lower list of the two presented. Add “..\OpenCV\bin\” as the last entry in PATH, usually separated using a semicolon (;). 3. If 2 does not work, then simply copy all the *.DLL files from ..\OpenCV\bin to C:\WINDOWS\system32. Or follow the option 1 above.

设为首页 | 加入收藏 | 昂纲搜索

All Rights Reserved Powered by 文档下载网

Copyright © 2011
文档下载网内容来自网络,如有侵犯请和我们联系。tousu#anggang.com
返回顶部