ImageEn, unit ievision

TIEVisionCascadeClassifierTrainer


Declaration

TIEVisionCascadeClassifierTrainer = interface(TIEVisionBase)


Description

This interface contains helper functions to create training samples and to train a LBP or HAAR cascade classifier.
You can use classifier files to find content within images.
Cascade classifier training object supports following file formats: jpeg, png, bmp, tiff, pgm.




Demo

Demo  Demos\IEVision\TrainCascadeClassifier\TrainCascadeClassifier.dpr


Example

// 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;


Methods and Properties

Public Method  createSamples
Public Method  createSamplesFromImageSet
Public Method  mergeSamples
Public Method  getSamplesCount
Public Method  trainCascade


See Also

createCascadeClassifierTrainer