1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
45 * haar training functions
48 #ifndef _CVHAARTRAINING_H_
49 #define _CVHAARTRAINING_H_
52 * cvCreateTrainingSamples
54 * Create training samples applying random distortions to sample image and
55 * store them in .vec file
57 * filename - .vec file name
58 * imgfilename - sample image file name
59 * bgcolor - background color for sample image
60 * bgthreshold - background color threshold. Pixels those colors are in range
61 * [bgcolor-bgthreshold, bgcolor+bgthreshold] are considered as transparent
62 * bgfilename - background description file name. If not NULL samples
63 * will be put on arbitrary background
64 * count - desired number of samples
65 * invert - if not 0 sample foreground pixels will be inverted
66 * if invert == CV_RANDOM_INVERT then samples will be inverted randomly
67 * maxintensitydev - desired max intensity deviation of foreground samples pixels
68 * maxxangle - max rotation angles
71 * showsamples - if not 0 samples will be shown
72 * winwidth - desired samples width
73 * winheight - desired samples height
75 #define CV_RANDOM_INVERT 0x7FFFFFFF
77 void cvCreateTrainingSamples( const char* filename,
78 const char* imgfilename, int bgcolor, int bgthreshold,
79 const char* bgfilename, int count,
80 int invert = 0, int maxintensitydev = 40,
81 double maxxangle = 1.1,
82 double maxyangle = 1.1,
83 double maxzangle = 0.5,
85 int winwidth = 24, int winheight = 24 );
87 void cvCreateTestSamples( const char* infoname,
88 const char* imgfilename, int bgcolor, int bgthreshold,
89 const char* bgfilename, int count,
90 int invert, int maxintensitydev,
91 double maxxangle, double maxyangle, double maxzangle,
93 int winwidth, int winheight );
96 * cvCreateTrainingSamplesFromInfo
98 * Create training samples from a set of marked up images and store them into .vec file
99 * infoname - file in which marked up image descriptions are stored
100 * num - desired number of samples
101 * showsamples - if not 0 samples will be shown
102 * winwidth - sample width
103 * winheight - sample height
105 * Return number of successfully created samples
107 int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename,
110 int winwidth, int winheight );
115 * Shows samples stored in .vec file
124 * the scale each sample is adjusted to
126 void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale );
130 * cvCreateCascadeClassifier
132 * Create cascade classifier
133 * dirname - directory name in which cascade classifier will be created.
134 * It must exist and contain subdirectories 0, 1, 2, ... (nstages-1).
135 * vecfilename - name of .vec file with object's images
136 * bgfilename - name of background description file
137 * npos - number of positive samples used in training of each stage
138 * nneg - number of negative samples used in training of each stage
139 * nstages - number of stages
140 * numprecalculated - number of features being precalculated. Each precalculated feature
141 * requires (number_of_samples*(sizeof( float ) + sizeof( short ))) bytes of memory
142 * numsplits - number of binary splits in each weak classifier
143 * 1 - stumps, 2 and more - trees.
144 * minhitrate - desired min hit rate of each stage
145 * maxfalsealarm - desired max false alarm of each stage
146 * weightfraction - weight trimming parameter
147 * mode - 0 - BASIC = Viola
148 * 1 - CORE = All upright
149 * 2 - ALL = All features
150 * symmetric - if not 0 vertical symmetry is assumed
151 * equalweights - if not 0 initial weights of all samples will be equal
152 * winwidth - sample width
153 * winheight - sample height
154 * boosttype - type of applied boosting algorithm
155 * 0 - Discrete AdaBoost
158 * 3 - Gentle AdaBoost
159 * stumperror - type of used error if Discrete AdaBoost algorithm is applied
160 * 0 - misclassification error
164 void cvCreateCascadeClassifier( const char* dirname,
165 const char* vecfilename,
166 const char* bgfilename,
167 int npos, int nneg, int nstages,
168 int numprecalculated,
170 float minhitrate = 0.995F, float maxfalsealarm = 0.5F,
171 float weightfraction = 0.95F,
172 int mode = 0, int symmetric = 1,
173 int equalweights = 1,
174 int winwidth = 24, int winheight = 24,
175 int boosttype = 3, int stumperror = 0 );
177 void cvCreateTreeCascadeClassifier( const char* dirname,
178 const char* vecfilename,
179 const char* bgfilename,
180 int npos, int nneg, int nstages,
181 int numprecalculated,
183 float minhitrate, float maxfalsealarm,
184 float weightfraction,
185 int mode, int symmetric,
187 int winwidth, int winheight,
188 int boosttype, int stumperror,
189 int maxtreesplits, int minpos );
191 #endif /* _CVHAARTRAINING_H_ */