Update the changelog
[opencv] / apps / haartraining / include / cvhaartraining.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
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.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
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.
25 //
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.
28 //
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.
39 //
40 //M*/
41
42 /*
43  * cvhaartraining.h
44  *
45  * haar training functions
46  */
47
48 #ifndef _CVHAARTRAINING_H_
49 #define _CVHAARTRAINING_H_
50
51 /*
52  * cvCreateTrainingSamples
53  *
54  * Create training samples applying random distortions to sample image and
55  * store them in .vec file
56  *
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
69  * maxyangle
70  * maxzangle
71  * showsamples     - if not 0 samples will be shown
72  * winwidth        - desired samples width
73  * winheight       - desired samples height
74  */
75 #define CV_RANDOM_INVERT 0x7FFFFFFF
76
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,
84                               int showsamples = 0,
85                               int winwidth = 24, int winheight = 24 );
86
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,
92                           int showsamples,
93                           int winwidth, int winheight );
94
95 /*
96  * cvCreateTrainingSamplesFromInfo
97  *
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
104  * 
105  * Return number of successfully created samples
106  */
107 int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename,
108                                      int num,
109                                      int showsamples,
110                                      int winwidth, int winheight );
111
112 /*
113  * cvShowVecSamples
114  *
115  * Shows samples stored in .vec file
116  *
117  * filename
118  *   .vec file name
119  * winwidth
120  *   sample width
121  * winheight
122  *   sample height
123  * scale
124  *   the scale each sample is adjusted to
125  */
126 void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale );
127
128
129 /*
130  * cvCreateCascadeClassifier
131  *
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
156  *   1 - Real AdaBoost
157  *   2 - LogitBoost
158  *   3 - Gentle AdaBoost
159  * stumperror       - type of used error if Discrete AdaBoost algorithm is applied
160  *   0 - misclassification error
161  *   1 - gini error
162  *   2 - entropy error
163  */
164 void cvCreateCascadeClassifier( const char* dirname,
165                                 const char* vecfilename,
166                                 const char* bgfilename, 
167                                 int npos, int nneg, int nstages,
168                                 int numprecalculated,
169                                 int numsplits,
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 );
176
177 void cvCreateTreeCascadeClassifier( const char* dirname,
178                                     const char* vecfilename,
179                                     const char* bgfilename, 
180                                     int npos, int nneg, int nstages,
181                                     int numprecalculated,
182                                     int numsplits,
183                                     float minhitrate, float maxfalsealarm,
184                                     float weightfraction,
185                                     int mode, int symmetric,
186                                     int equalweights,
187                                     int winwidth, int winheight,
188                                     int boosttype, int stumperror,
189                                     int maxtreesplits, int minpos );
190
191 #endif /* _CVHAARTRAINING_H_ */