//
//
//                  INTEL CORPORATION PROPRIETARY INFORMATION
//    This  software  is supplied  under  the terms  of the license agreement
//    or nondisclosure agreement with Intel Corporation and may not be copied
//    or  disclosed  except  in accordance  with the terms of that agreement.
//           Copyright (c) 2005 Intel Corporation. All Rights Reserved.
//
//


   This 32-bit sample demonstrates how to use the IntelR Integrated Performance
Primitives (Intel(R) IPP) in face detection  task in an Microsoft(R) Foundation
Classes (MFC) application.  Face detection algorithm follows the description in
[1] and [2].  The  input  data  are: the image  with faces  to detect  and  the
pre-trained Haar classifier cascade.  The output data  are the image with faces
detected and the log file. Equivalent faces having close placement and size are
united by the clustering algorithm.

The example usage is:

face_detection.exe -cascade=<fname> -input=<fname> -output=<fname> -log=<fname>
                   -minwidth=<int> -maxwidth=<int> -scale=<float>
                   -minneighbors=<int> -distance=<int> -ratio=<float>
                   -pruningType=<int> -pruningParam=<int>,

where
-cascade=haar.txt   - file with Haar classifier cascade for frontal faces
-input=test.bmp     - input 1- or 3-channel bmp file
-output=result.bmp  - output 3-channel bmp file
-log=result.txt     - output text file containing face sizes and coordinates of
                      face centers
-minwidth=37        - minimal width of face to be found
-maxwidth=0         - maximal width of face to be found,
                      if 0 - the input image size
-scale=1.12         - multiplier value, faces of sizes minwidth, minwidth*scale,
                      minwidth*scale*scale, : maxwidth  are seached  parameters
                      of the clustering algorithm
-minneighbors=2     - minimal cluster size
                      (clusters with less elements are treated as noise)
-distance=5         - maximal distance in pixels between centers of
                      two equivalent faces
-ratio=1.3          - maximal ratio of sizes of two equivalent faces
-pruningType=3      - pruning type being used to speed up application 
                      performance
-pruningParam=1     - pruning quality

Face  detection  algorithm   is  applied    to  256  color  grey  scale  image.
It uses image scaling  (pyramid) instead of classifier scaling in [1]. External
pruning   can   be   added   by  zeroing  of  unlikely  pixels  of  mask  image
(ippApplyHaarClassifier function argument) to accelerate the detection process.
After  the detection stage faces  are united in clusters.  Two faces with small
difference  between  centers  and  close  sizes  belong  to  the  same cluster.
The average face for the cluster is drawn on the output image.


[1] Paul  Viola  and  Michael J. Jones. Rapid  Object Detection using a Boosted
    Cascade of Simple Features. IEEE CVPR, 2001.
[2] Rainer  Lienhart,  Alexander   Kuranov,  and  Vadim  Pisarevsky.  Empirical
    Analysis  of Detection Cascades  of Boosted  Classifiers  for  Rapid Object
    Detection. MRL Technical Report, Intel Labs, May 2002, revised Dec. 2002
