Posted on

Eye-Shape Classification

Veronika Štrbáková

The project shows detection and recognition of face and eyes from input image (webcam). I use for detection and classification haarcascade files from OpenCV. If eyes are recognized, I classify them as opened or narrowed. The algorithm uses the OpenCV and SVMLight library.

Functions used: CascadeClassifier::detectMultiScale, HOGDescriptor::compute HOGDescriptor::setSVMDetector, SVMTrainer::writeFeatureVectorToFile

The process:

  1. As first I make positive and negative dataset. Positive dataset are photos of narrowed eyes and negative dataset are photos of opened eyes.
    Strbakova_eye
  2. Then I make HOGDescriptor and I use it to compute feature vector for every picture. These pictures are used to train SVM vector and their feature vectors are saved to one file: features.dat
    HOGDescriptor hog;
    vector<float> featureVector;
    SVMLight::SVMTrainer svm("features.dat");
    hog.compute(img, featureVector, Size(8, 8), Size(0, 0));
    svm.writeFeatureVectorToFile(featureVector, true);
    
  3. From feature vectors I compute single descriptor vector and I set him to my HOGDescriptor.
    SVMLight::SVMClassifier c("classifier.dat");
    vector descriptorVector = c.getDescriptorVector();
    hog.setSVMDetector(descriptorVector);
    
  4. I detect every face and every eye from picture. For every found picture of eye I cut it and I use HOGDescriptor to detect narrowed shape of eye.
    strbakova_face_det
    Face, Eye and Mouth detection
    strbakova_cutting_eyes
    Cutting eyes and conversion to grayscale format

    strbakova_narrowed_eyes.jpg
    Finding narrowed eyes