hsnaves / face_detector

Haar cascade face detector
MIT License
1 stars 1 forks source link

Readme File #1

Open tanzidhasan opened 2 years ago

tanzidhasan commented 2 years ago

Sir, I am working on a project where part of your code will be very useful. But there are no particular instruction of training, detection or evaluating instruction in README.md. I have generated "haarcascade" object file. Now, I am not certain what instructions should be used to train, detect or evaluate any object. If you provide necessary instructions to run the software, I will be very grateful.

hsnaves commented 2 years ago

I have been a long time since I last used this program, I am not sure if I even remember how to use it... Well, the first thing is typing

./haarcascade train --help

and you should get the help with the options you can provide for training

Usage: ./haarcascade train [options] file...
Options:
  --datadir <dir>                       Specify directory with training images[default: data]
  --width <uint>                        Specify width of image for the classifier[default: 24]
  --height <uint>                       Specify height of image for the classifier[default: 24]
  --match_thresh <dbl>                  Coefficient used to determine if two boxes match[default: 0.75]
  --overlap_thresh <dbl>                Coefficient used to determine if two boxes overlap[default: 0.33]
  --learn_overlap                       To lean the match_thresh and overlap_thresh from the data
  --min_similarity <dbl>                Minimum similarity when finding positive windows[default: 0.9]
  --Cp <dbl>                            Penalty constant for false positives[default: 1]
  --Cn <dbl>                            Penalty constant for false negatives[default: 1]
  --max_stages <uint>                   Maximum number of stages for the cascade[default: 25]
  --max_classifiers <uint>              Maximum number of classifiers per stage[default: 200]
  --num_parallels <uint>                Number of parallel classifiers[default: 1]
  --cycle_parallels                     Force traininig to cycle through the parallels
  --buckets <uint>                      Number of buckets for boosting[default: 1001]
  --bucket_max <dbl>                    Maximum value of buckets[default: 300.0]
  --bucket_min <dbl>                    Minimum value of buckets[default: -300.0]
  --max_false_positive <dbl>            Maximum false positive rate per stage[default: 0.25]
  --max_false_negative <dbl>            Maximum false negative rate per stage[default: 0.005]
  --feature_prob <dbl>                  Choose a random subset of features with this probability[default: 1]
  --min_jumbled <uint>                  Use all jumbled images if it is less than this parameter[default: 100]
  --min_negative_samples <uint>         Minimum number of negative samples[default: 10]
  --positive_samples <uint>             Number of positive samples[default: 0]
  --negative_samples <uint>             Number of negative samples[default: 0]
  --scale <dbl>                         How much to scale images in detection[default: 1.1]
  --min_stddev <dbl>                    Minimum standard deviation for a detected object[default: 10.0]
  --step <uint>                         How many pixels should the detection window move per step[default: 1]
  --multi_exit                          Set the cascade to multi-exit
  --cascade <file>                      Name of the output cascade file[default: cascade.txt]
  --num_threads <uint>                  Number of threads used to train[default: 1]
  --max_planes <uint>                   Maximum number of planes for the cutting plane algorithm (CPA)[default: 1000]
  --eps <dbl>                           To determine convergence of CPA based on risk difference[default: 1e-6]
  --eps_qp <dbl>                        To determine convergence of the dual quadratic programming[default: 1e-6]
  --mu <dbl>                            Coefficient for the position of the next plane[default: 0.1]
  --max_unused <uint>                   Remove plane after not being used for many iterations[default: 200]
  --help                                Print this help

As far as I remember, you need to specify the --datadir, which is the directory containing the training images, and the training file, which is a CSV file with the information about the training samples. For example:

./haarcascade train --datadir /path/to/images/ training.csv

The training.csv file should contain the columns positive, filename, left, top, width, height, where positive identifies if the sample is a face or not (yes or no), filename is the name of the image file containing the sample, and left, top, width, height specify a sub-rectangle within the image which delimits the face. The filename is relative to the directory specified with --datadir.

For example:

positive,filename,left,top,width,height
yes,face1.jpg,0,0,24,24
no,not_face.png,0,0,30,30