Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
13Activity
0 of .
Results for:
No results containing your search query
P. 1
OpenCV Object Detection HowTo

OpenCV Object Detection HowTo

Ratings:

5.0

(1)
|Views: 2,638 |Likes:
Published by api-3799599

More info:

Published by: api-3799599 on Oct 17, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

OpenCV's Rapid Object Detection
Florian Adolf
Page 1 of 6
2003-09-02
How-to build a cascade of boosted classifiers based on
Haar-like features
Introduction

This document describes how to train a classifier for object detection. OpenCV comes already
with a trained classifier for frontal face detection. In order to show that it also works for a variety
of objects, not only for faces, an exemplary training process with bowl is shown. The system used
here is aWi n32 machine with OpenCV beta 3.1 default installation into \u201cC:\Program

Files\OpenCV\u201d as<Ope nCV- dir e ct ory >.

The utilities used here should be in<Ope nCV- di r ec t ory >\ bi n. If this is not the case you have to
compile them first by using<Ope nCV- di r ec t or y >\ apps \ Haar Tr ai ni ng\ mak e\f ull .ds w. In all
compilations select the \u201crelease\u201d version as a current configuration in order to avoid creating the
debug version (library and program has \u201cd\u201d appended).
In case some files cannot be found, check the paths of the \u201cinclude files\u201d and \u201clibrary files\u201d in
your development evironment or compile the needed libraries.

In case the steps mentioned above run properly, you should look for any of the missing file(s) in
the OpenCV Yahoo!-Group.
When you try to compile one of the most common problems is that "_cvcommon.h" cannot be
found because it has simply been forgotten in the distribution package. You can download it from
some message attachments of the OpenCV Yahoo!-Group (i.e.

http://groups.yahoo.com/group/OpenCV/message/11615or
http://groups.yahoo.com/group/OpenCV/message/12353
)

After the orginal code has compiled successfully, you should remove the sample size limitation in
the functionic v Cr e at eI nt Haar Fe at ur es () is to be found in \u201ccvhaartraining.cpp\u201d. Simply replace
s0=36, s1=12, s2=18 and s3=24 with s0=s1=s2=s3=0 and rebuild.

If you are lucky enough to have a multi-processor system or Pentium 4 with \u201cHyper-Threading\u201d for training, you should use the multi-processor feature in cvhaartraining. Thus the haartraining has to be rebuilt with \u201cOpenMP\u201d enabled. Due to the fact that the system used here doesn\u2019t have any of the above mentioned features, we could not experience use of multi-processor features.

OpenCV's Rapid Object Detection
Florian Adolf
Page 2 of 6
2003-09-02
Step 1 - Preparation
Tools:
First of all the utilities "createsamples.exe", "haartraining.exe" and
"performance.exe" should be available. In our case we work in \u201cC:\Temp\\u201d.
Negative Samples:

You should have a lot of images (about 5,000 to 10,000) as negative (background) samples. You
can get them from well known ressources, i.e. photo-cds (CorelDraw or MS Office) or public
databases.
Due to compression artefacts in some compression levels of JPEG images, a BMP image format
should be chosen. The negative (background) resolution used here is equivalent to the one the
video camera uses for later image acquisition (384x256 pixels). But this is not a necessary
condition.
\u201cC:\Temp\negatives\\u201d contains the folders of negative images as well as the info files
\u201ctrain.txt\u201d and \u201ctest.txt\u201d.
To work with these images in our utilities, a list of the files is needed. Using Win32 as host OS,
you can get the list via command promt. Move to the folder where the info file will be stored and
type \u201cdir /b /s > infofile.txt\u201d. Open \u201cinfofile.txt\u201d and make the paths relative to the
info file (i.e. find \u201cC:\Temp\negatives\\u201d and replace with \u201c\u201d).

Positive Samples:

The advantage of object images taken from real world scenes is that you have different
reflections, illuminations and backgrounds. Using IPL the "createsamples" tool can simulate such
conditions but generally they train not that well.

You can get real object images from several sources such as public data sets (as done for face
training) or you can create them by yourself.
The raw images of the bowls were made manually by statues of live video. Several sites with
different floor surfaces and illuminations have been taken to achieve a variety of conditions.
Additionally at each site the camera was positioned in several angles and distances around the
bowls.

You might want to use "objectmarker.exe" to extract the desired objects out of your raw images,
i.e. taken with a camera [Fig.1-1]. You browse through the folder named \u201crawdata\u201d containing all
BMP format images and mark your object(s) with a bounding rectangle. You can add each
bounding box to the info file \u201cinfo.txt\u201d which you can use for your training and/or testing.

Notes: While marking the rectangle should be close to your objects border. Take care of the info
file before you restart this little tool, otherwise it will overwrite it without asking.
OpenCV's Rapid Object Detection
Florian Adolf
Page 3 of 6
2003-09-02
Fig. 1-1: Raw image and a bounding rectangle on the bowl in the middle
If you want to try to train by one example image anyway, you must have \u201ciplPXl.lib\u201d available.
Also you have to uncomment \u201c#define HAVE_IPL\u201d in file \u201c_cvhaartraining.h\u201d so that
iplWarpPerspectiveQ() is running correctly for \u201ccreatesamples.exe\u201d. Otherwise when compiled
the step of pattern generation from your one sample is not included into the program and only the
negatives are put into a vec file.
These positive samples will be stored in a folder \u201cbowls\u201d in \u201cC:\Temp\positives\\u201d where
the info files \u201ctrain.txt\u201d and \u201ctesting.txt\u201dare located [Fig.1-2].
Fig. 1-2: Example content of file train.txt (from left to right): BMP file location, number of rectangles, each rectangles
x/y coordinate of the upper left corner and width/height from this point x/y.

Activity (13)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
peter.raiti2234 liked this
Powel Siwu liked this
Michiel Vlaminck liked this
ujjwal919 liked this
Steven Dang liked this
bombertest1 liked this
DarkNeon141 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->