title: General Tips to Improve Haar Vision Training Data Results [openCV]
body: <p>Using trainCascade to train for HAAR-like features. Seeking advice from the community to get better results. In general, what is considered to be a good acceptance ratio?</p>
  
  <p>I started with a smaller Training, following this link as a guide: <a href="http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html" rel="nofollow">http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html</a></p>
  
  <p>Here is my Data:</p>
  
  <pre><code>PARAMETERS:
  cascadeDirName: classifier
  vecFileName: samples.vec
  bgFileName: negatives.txt
  numPos: 68
  numNeg: 436
  numStages: 20
  precalcValBufSize[Mb] : 3072
  precalcIdxBufSize[Mb] : 3072
  stageType: BOOST
  featureType: HAAR
  sampleWidth: 80
  sampleHeight: 80
  boostType: GAB
  minHitRate: 0.999
  maxFalseAlarmRate: 0.5
  weightTrimRate: 0.95
  maxDepth: 1
  maxWeakCount: 100
  mode: ALL
  
  ===== TRAINING 0-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 1
  Precalculation time: 296
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|0.0206422|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 1-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.0810108
  Precalculation time: 228
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.259174|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 2-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.0399304
  Precalculation time: 279
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.155963|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 3-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.0106487
  Precalculation time: 255
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.275229|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 4-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.0031086
  Precalculation time: 295
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.399083|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 5-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.00127805
  Precalculation time: 282
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.389908|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 6-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.000522627
  Precalculation time: 299
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.502294|
  +----+---------+---------+
  |   4|        1| 0.247706|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 7-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 0.000149988
  Precalculation time: 283
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.511468|
  +----+---------+---------+
  |   4|        1|     0.25|
  +----+---------+---------+
  END&gt;
  ===== TRAINING 8-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 4.31894e-05
  Precalculation time: 226
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.440367|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 9-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 2.12363e-05
  Precalculation time: 208
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.541284|
  +----+---------+---------+
  |   4|        1| 0.291284|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 10-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 7.5647e-06
  Precalculation time: 294
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1| 0.451835|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 11-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 3.79627e-06
  Precalculation time: 226
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1| 0.463303|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 12-stage =====
  &lt;BEGIN
  NEG count : acceptanceRatio    436 : 2.03777e-06
  Precalculation time: 184
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1|        1|
  +----+---------+---------+
  |   3|        1| 0.396789|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 13-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 1.06732e-06
  Precalculation time: 262
  +----+---------+---------+
  |  N |    HR   |    FA   |
  +----+---------+---------+
  |   1|        1|        1|
  +----+---------+---------+
  |   2|        1| 0.415138|
  +----+---------+---------+
  END&gt;
  
  ===== TRAINING 14-stage =====
  &lt;BEGIN
  POS count : consumed   68 : 68
  NEG count : acceptanceRatio    436 : 6.80241e-07
  Required leaf false alarm rate achieved. Branch training terminated.
  </code></pre>
  
  <p>I found that the classifiers for stage 7 and 8 worked the best, although not perfectly.</p>
  
  <p>What have you found that makes good positive samples? Smaller images? Larger images? Rotations? (I did rotate my positive samples(90,180,and 270 degrees). And for negative images? </p>
  
  <p>Has anyone experimented with various different grade types of images? Such as those taken from a camera with a good image sensor (like a Canon Rebel) versus those taken with a cell phone camera. Does this make substantial difference in your trainer? </p>
  
  <p>I also believe I made a mistake, in training my trainer to find a chrome object. I think the reflections off of it, although minimal, had a large effect on how well it trained.</p>