ACF+training+own+detector

__Use the following steps to create your own object model for detection using the ACF framework of Piotr Dollar.__

Start by performing some pre-processing on your data.
 * Go to your framework folder - /home/user/Frameworks/Dollar/
 * Create a folder called 'data' with the following structure

///home/user/Frameworks/Dollar/// //.../data/// //....../your_model/// //........./test/// //............./pos/// //............./neg/// //............./posGt/// //........./training/// //............./pos/// //............./neg/// //............./posGt///


 * Now we need to make sure that all our data follows the following rules
 * /data/your_model/training/pos/ contains your object images I00000.png to Ixxxxx.png
 * /data/your_model/training/neg/ contains your non-object images I00000.png to Ixxxxx.png
 * /data/your_model/training/posGt/ contains your object annotations I00000.txt to Ixxxxx.txt
 * Each annotation file should have the following structure and correspond to an image in the pos folder
 * Start with a comment line **//% bbGT version=3//** (version of the bb software)
 * For each detection add **//class x y w h 0 0 0 0 0 0 0//** (add 7 zeros for options that are standardly not used)
 * Make sure the file doesn't have an empty line at the bottom
 * Now make sure that this is done for both trainings and test set and your data is setup correctly in order to proceed

**ADAPTING THE TRAINING INTERFACE FOR OWN MODEL USE**
Start by downloading the template file which can be found at the bottom of the explanation, used for an EAVISE case (INDUCT strawberry detector). Copy the file inside the toolbox, at the **//toolbox>detector>//** folder.

Now the following parameters need to be set correctly for your problem:
 * 1) **LINE 14:** Set the correct data directory path.
 * 2) **LINE 22-26:**
 * 3) Set the preference model dimensions, keeping in mind that it is [h w] order. If preferred you can add some padding to the model size.
 * 4) Set the location of the training data folders explicitly.
 * 5) Set the number of weak classifiers that need to be used at each stage. Increasing the amount of steps here increases the amount of stages trained.
 * 6) Set the flip option if preferred, which flips your training data around its vertical axis and thus doubles the amount of training samples.
 * 7) **LINE 29-31:**
 * 8) Due to the removal of the standard Sequence - BoundingBoxVideo files used by Piotr Dollar we need to explicitly define elements for training.
 * 9) Add the number of positive and negative samples that need to be used. nPos is the total amount of positive samples, while nNeg is the number of negative windows maximally added at each stage.
 * 10) Define the number of negative windows grabbed from each large negative image (nPerNeg) to diverse the negative windows and define the maximal used negative windows in complete model.
 * 11) There is an option to define which labels should be read and which not if you have a multi label annotation file.
 * 12) **LINE 49:** gives you the ability to apply a threshold on the output score of your detection.
 * 13) **LINE 64-65:** allows for a performance calculation. Give in the desired input image size and the number of test images available.

TRAINING THE ACTUAL MODEL
Once the model training file is configured, all you have to do is run the file. For this be sure to be in the //**toolbox>detector****>**// folder as all paths are defined relative to that folder location. As output you can expect
 * Standard all detections with a score lower than -1 are discarded. This can be adapted in line 45.
 * A test frame with detections result, thresholded or not.
 * An graph output of the miss rate on the test set.
 * An estimation of the FPS that can be achieved if requested for.

SOME STATISTICS
Statistics for the strawberry model
 * +- 900 pos samples / 6000 negative samples used
 * Training takes 64s for ACF and 191s for LDCF
 * Detection takes 0.8s for a single detection with ACF and 2.045 s for an image with LDCF
 * Running over multiple samples we reach 7.8FPS for ACF and 1.81 FPS for LDCF

DOWNLOADS
Template (v.16/01/2015):