#include "ViolaJones.h" ViolaJones::ViolaJones(void) { } ViolaJones::~ViolaJones(void) { } ViolaJones::ViolaJones(vector ptr, vectorntr, vectorpte, vector nte) { positiveTrain=ptr; negativeTrain=ntr; positiveTest=pte; negativeTest=nte; } /* * f - the maximum acceptable false positive rate per layer * d - the minimum acceptable detection rate per layer * targetF - target overall false positive rate * kaskada - kaskada koja se gradi */ void ViolaJones::buildCascade(double f,double d, double targetF, Cascade &kaskada) { //P - set of positive examples; N - set of negative examples: list P(positiveTrain.begin(),positiveTrain.end()); list N(negativeTrain.begin(),negativeTrain.end()); double tmpF=1.0; // trenutni false positive rate double lastF=1.0; // false positive rate prethodnog nivoa double tmpD=1.0; // trenutni detaction rate double lastD=1.0; // detection rate prethodnog nivoa int i=0; // i - level kaskade int n; // broj featureova u trenutnom levelu kaskade pair tmpRet; // pomocna varijabla while(tmpF>targetF) { i++; n=0; tmpF=lastF; while(tmpF>f*lastF) { n++; //adaBoostTrain(P,N,n,kaskada); // trenira level kaskade s n featureova AdaBoost::startTraining(P,N,kaskada[i],n) // Evaluate current cascaded classifier on validation set to determine tmpF and tmpD: tmpRet=evaluateOnTest(kaskada); tmpF=tmpRet.first; tmpD=tmpRet.second; /* * Decrease threshold for the i-th classifier until the current cascaded classifier * has a detection rate of at least d × lastD (this also affects tmpF ): */ decraseThreshold(i,d*lastD,kaskada); } N.clear(); /* * If tempF > targetF then evaluate the current cascaded detector on the set of non-face images * and put any false detections into the set N: */ if(tmpF>targetF) evaluateOnTrainNegative(N,kaskada); } } // Evaluate current cascaded classifier on validation set to determine tmpF and tmpD pair &N, Cascade kaskada) { for(int i=0;i