TIEVisionLibrary.createCascadeClassifierTrainer
Declaration
function createCascadeClassifierTrainer(): TIEVisionCascadeClassifierTrainer; safecall;
Description
Create a cascade classifier trainer object.
| Demos\IEVision\TrainCascadeClassifier\TrainCascadeClassifier.dpr |
// Start training session
var
cct: TIEVisionCascadeClassifierTrainer;
imagesCount: integer;
begin
cct := IEVisionLib().createCascadeClassifierTrainer();
// create training sample files. The output will be "samples.vec"
DeleteFile(sExePath + SAMPLES_FILENAME);
imagesCount := cct.createSamplesFromImageSet(PAnsiChar(AnsiString(sExePath + POSITIVE_SAMPLES_DIR)),
PAnsiChar(AnsiString(sExePath + SAMPLES_FILENAME)),
StrToInt(EditSampleWidth.Text), // samples width
StrToInt(EditSampleHeight.Text)); // samples height
// trainCascade images count must be less than 85% of the images in "vec" file
imagesCount := trunc(imagesCount * 0.85);
// train cascade (produces train_data\cascade.xml file)
cct.trainCascade(PAnsiChar(AnsiString(sExePath + TRAINDATA_DIR)),
PAnsiChar(AnsiString(sExePath + SAMPLES_FILENAME)),
PAnsiChar(AnsiString(sExePath + NEGATIVE_SAMPLES_DIR)),
imagesCount, // number of positives (up to 85% of content of "samples.vec")
StrToInt(EditSampleWidth.Text), // samples width
StrToInt(EditSampleHeight.Text), // samples height
StrToInt(EditStages.Text), // number of stages
TIEVisionFeatureType(ComboBoxFeatureType.ItemIndex), // featureType (ievLBP or ievHAAR)
CheckBoxContinue.Checked, // continueTraining
TrainingMsgCallBack);
end;