ImageEn, unit ievision



TIEVisionCascadeClassifier = interface(TIEVisionBase)


An interface to handle a cascade classifier to locate faces and other objects within an image or video frame.
Classifiers are supplied to TIEVisionObjectsFinder.
You can use the built-in classifiers or load from file (e.g. that you created using TIEVisionCascadeClassifierTrainer).


Demo  Demos\IEVision\FaceDetection_LowLevel\FaceDetection_LowLevel.dpr
Demo  Demos\IEVision\TrackObjects_LowLevel\TrackObjects_LowLevel.dpr


// Load two face detectors
objectsFinder := IEVisionLib.createObjectsFinder();
objectsFinder.addClassifier('face detector 1', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT_TREE);
objectsFinder.addClassifier('face detector 2', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_DEFAULT));

// Automatically detect a face in the current image
  divisor = 3;
  m_classifier: TIEVisionCascadeClassifier;
  origImage, workImage:TIEVisionImage;
  m_classifier := IEVisionLib.createCascadeClassifier( IEVC_FRONTAL_FACE_DEFAULT );

  // copy current sample to ImageEnView bitmap

  // create scaled gray scale image
  origImage := ImageEnView1.IEBitmap.GetIEVisionImage();
  origImage.flip(ievY_AXIS);  // show image correctly
  workImage := IEVisionLib.createImage(origImage.getWidth(), origImage.getHeight(), ievUINT8, 1);
  origImage.convertColor(workImage, ievBGR2GRAY);
  workImage.resize(workImage.getWidth() div divisor, workImage.getHeight() div divisor);

  // detect face
  objects := m_classifier.detectObjects(workImage, 1.1, 3, ievDO_CANNY_PRUNING, IEVisionSize(0,0), IEVisionSize(0,0));

  // face found?
  if objects.size() > 0 then
    // at least one face detected
    // setup window
    with ImageEnView1, objects.getRect(0) do
      m_lastWindow := IEVisionRect(x*divisor, y*divisor, width*divisor, height*divisor);
    // reset histogram and HUE ranges
    m_histogram := nil;
    m_minHSV := IEVisionScalar(  0,   0,   0);
    m_maxHSV := IEVisionScalar(180, 256, 256);
    // disable face detection
    AutoDetectFace.Down := false;

  // refresh ImageEnView1
  m_classifier := nil;

Methods and Properties

Public Method  detectObjects
Public Method  empty
Public Method  load

See Also

Public Method  createCascadeClassifier
Public Method  addClassifier
Class  IEVision Embedded Classifiers
Public Method  DrawRects