TIEVisionLibrary.createCascadeClassifier
Declaration
function createCascadeClassifier(): TIEVisionCascadeClassifier; overload; safecall;
function createCascadeClassifier(c: TIEVisionCascadeClassifier): TIEVisionCascadeClassifier; overload; safecall;
function createCascadeClassifier(filename: PAnsiChar): TIEVisionCascadeClassifier; overload; safecall;
Description
First overload creates a new empty cascade classifier.
Second overload creates a cascade classifier from a copy of specified object.
Third overload creates a cascade classifier from file or an embedded classifier. Embedded classifiers have ':' prefix and can be:
Const | Classifier |
IEVC_EYE | ":EYE" |
IEVC_EYE_TREE_EYE_GLASSES | ":EYETREEEYEGLASSES" |
IEVC_FRONTAL_FACE_ALT | ":FRONTALFACEALT" |
IEVC_FRONTAL_FACE_ALT_2 | ":FRONTALFACEALT2" |
IEVC_FRONTAL_FACE_ALT_TREE | ":FRONTALFACEALTTREE" |
IEVC_FRONTAL_FACE_DEFAULT | ":FRONTALFACEDEFAULT" |
IEVC_FULL_BODY | ":FULLBODY" |
IEVC_LOWER_BODY | ":LOWERBODY" |
IEVC_PROFILE_FACE | ":PROFILEFACE" |
IEVC_UPPER_BODY | ":UPPERBODY" |
IEVC_LEFT_EYE_2_SPLITS | ":LEFTEYE2SPLITS" |
IEVC_RIGHT_EYE_2_SPLITS | ":RIGHTEYE2SPLITS" |
IEVC_LBP_FRONTAL_FACE | ":LBPFRONTALFACE" |
IEVC_CASCADE_SMILE | ":CASCADESMILE" |
IEVC_FRONTAL_CAT_FACE | ":FRONTALCATFACE" |
IEVC_FRONTAL_CAT_FACE_EXT | ":FRONTALCATFACEEXTENDED" |
IEVC_LICENSE_PLATE_RUS | ":LICENSEPLATERUS" |
IEVC_RUSSIAN_PLATE_NUMBER | ":RUSSIANPLATENUMBER" |
Parameter | Description |
c | Source classifier to copy |
filename | Filename of classifier to load (or one of the embedded classifiers) |
Note: You can create your own classifiers using
TIEVisionCascadeClassifierTrainer | Demos\IEVision\FaceDetection_LowLevel\FaceDetection.dpr |
| Demos\IEVision\FaceDetection_LowLevel\FaceDetection_LowLevel.dpr |
| Demos\IEVision\TrackObjects_LowLevel\TrackObjects.dpr |
| 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
const
divisor = 3;
var
m_classifier: TIEVisionCascadeClassifier;
origImage, workImage:TIEVisionImage;
objects:TIEVisionVectorRect;
begin
m_classifier := IEVisionLib.createCascadeClassifier( IEVC_FRONTAL_FACE_DEFAULT );
// copy current sample to ImageEnView bitmap
ImageEnView1.IO.DShowParams.GetSample(ImageEnView1.IEBitmap);
// 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);
workImage.equalizeHistogram();
// 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
begin
// 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;
end;
// refresh ImageEnView1
ImageEnView1.Update;
m_classifier := nil;
end;
See Also
◼IEVision Embedded Classifiers