Showing posts with label OpenCV. Show all posts
Showing posts with label OpenCV. Show all posts

OpenCV - Haar Training Resources

There were lot of good feed back for my OpenCV articles (Article1, Article 2). There were lot of inquires regarding Haar Training and how to do it. Since I was bit busy with my work at hSenind I couldn't put any replies for that. Finally I managed to find some time to put together few URL and important tools where you can use to create your own classifier XML.

If you are interested in OpenCV vision library you should join to OpenCV yahoo group. It is very active and has lot of resources as well.  Following are some good links I used when I was learning on how to do Haar Training with OpenCV.

Most important thing to consider when doing Haar training is to have good positive and negative image set. We have created a small utility modifying sample program provide with OpenCV to create positive samples. You can download the source here. Using that you can create positive samples to detect some object using a video. You can move frame by frame in the video using 'Space Bar', mark the areas that contain the object you want to detect using mouse and save it just by pressing 'S'. Utility will create the text file required fro training.

Utility can also be used to create sample images to be used for HMM training as well. If you are interested in HMM following http://www.bernardotti.it/portal/showthread.php?t=17777 has a good article on how to use HMM with OpenCV.

 

Getting Started with OpenCV

Finally our final year project is finished. As I've promised in my previous post I'm going to do few posts on OpenCV. In this post I'm going to tell you how to configure MS Visual Studio 2005 to work with OpenCV library. 

Step 1: Installiny OpenCV

First you have to download the OpenCV library from Sourceforge and run the installer. It will install OpenCV library on your computer. By default it will be installed to "C:\Program Files\OpenCV". Installer will add "C:\Program Files\OpenCV\bin" to system's PATH variable. But sometimes this do not happen properly. In such cases you'll have to add OpenCV bin directory manually to the system's PATH.

OpenCV installer

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

Step 2: Configuring VS 2005

In order to use OpenCv from VS you have to add libraries and header files to projects path. Create Win32 Console Application in VS 2005. Then right click the project form the Solution Explorer and select Properties.

project properties

Under "Configuration Properties -> C/C++ -> General" put following folders to "Additional Include Directories".

C:\Program Files\OpenCV\cxcore\include
C:\Program Files\OpenCV\cv\include\
C:\Program Files\OpenCV\cvaux\include
C:\Program Files\OpenCV\otherlibs\highgui

set include directories

Then under "Configuration Properties -> Linker -> Input" put following folders to "Additional Dependencies". Add them line by line with double quotes.

"C:\Program Files\OpenCV\lib\cv.lib"
"C:\Program Files\OpenCV\lib\cvaux.lib"
"C:\Program Files\OpenCV\lib\cxcore.lib"
"C:\Program Files\OpenCV\lib\highgui.lib"

set linker dependancies

Sometimes it is possible that you don't have above lib files in "C:\Program Files\OpenCV\lib" folder. In such situations you just have to compile the OpenCV solution.

It is also possible for you to get complains regarding corex100.dll (it can be corexXXX.dll) when running your OpenCV application. If you get such error build the OpenCV solution and check whether the "C:\Program Files\OpenCV\bin" folder is in your system PATH, if not you either have to add that to the path or copy all the DLLs in bin folder to C:\WINDOWS\SYSTEM32 folder.

opencv solution

So that basically what you have to do to configure VS2005. You can check whether you have configured the VS correctly by compiling and running some sample applications in the "C:\Program Files\OpenCV\samples\c" folder. So have fun with OpenCV.

 

OpenCV - Computer Vision Library

OpenCV is an open source computer vision library developed by Intel. This library is written in C/C++ and it has lot of very powerful image processing features.

I got to know about this library few months back when I was doing researches for our final year project. Our project "Sign2Voice" interprets signs of sign language to voice in real time using a video captured using simple webcam.

OpenCV has rich image processing API that that provides wide range of functionally ranging from simple image processing tasks to machine learning algorithms.  In our project we uses OpenCV library to detect and identify sign language hand gestures. We uses Haar-Cascade classifier provided with OpenCV to detect hand. After training the classifier with set of positive and negative images we can use the classifier to detect objects. OpenCV has a good trained classifier for face detection.

Training of Haar-classifier is not an easy task. This became especially difficult because there is nor proper documentation for this process. Their are few web sites that give instructions on how to train, but they are not that comprehensive.

We had to do lot of experiments and learn through trail and error to find out how to do the training properly. After lot of failures we managed to achieve good results in had detection. 

hand_detect hand_detect1

 

I'm planning to do some posts regarding how to train haar-classifier share the knowledge I gained with you in future. So keep you figures crossed. :)