<< Chapter < Page Chapter >> Page >

Implementation

In order to implement these algorithms in time and computationally efficient manner, we used the Computer Vision toolbox in MATLAB. We used several features of this toolbox to calculate the parameters we needed for detecting a smile.

Illustrated example

Using the ubiquitous image of Lena from many face and feature recognition papers and Danny, we complete our first step of detecting the image with the discussed modified Viola-Jones Algorithm. Important pieces of code are included.

faceDetector = vision.CascadeObjectDetector(’FrontalFaceCART’);

box = step(faceDetector,<image>);

Figure 2: Detected Face. This initializes a pre-trained modified Viola-Jones feature detection cascade (Section3.1 [link] ). Then the image is input into the cascade system, giving an output of the coordinates of a box that surronds the face.

mregcrop = imcrop(facecrop, [1 floor(2*box(4)/3) box(3) ceil(box(4))]);

Figure 4: From the Detected Face, the region for performing the mouth search is created. The region of the lower third of the face is isolated for performing the mouth search.

mouthcrop = imcrop(mregcrop, [x y w h]);

mouthDetector = vision.CascadeObjectDetector(’Mouth’);

mbox = step(mouthDetector, mouthcrop);

Figure 6: The mouth is found in the bottom third region. This mouth region is then isolated. A mouth search in the mouth region is performed using a similar Viola-Jones based method.

cornerDetector = vision.CornerDetector(’Method’, ’Minimum eigenvalue (Shi&Tomasi)’);

points = step(cornerDetector, rgb2gray(mouthcrop));

Figure 7: Our last detection step is determining the location of corners within the mouth box. This is done using the Shi-Tomasi Algorithm (Section 3.2 )

P = polyfit(cpoints(:,1),cpoints(:,2),2);

Y = polyval(P,XI);

plot(XI,Y,’b’,’linewidth’,2,’markersize’,10)

Figure 8: From the points detected using the Shi-Tomasi Algorithm, we find the corner density and curvature parameters.

Finally, we return the values of our two parameters for further use in a decision tree. The parameters used in the decision tree are discussed in Section 5.2 .

Decision tree

We use the following decision tree to determine the best image of a set.

Figure 9: Decision Algorithm

We chose a minimum number of detected corners of 11, based on the idea that a low number of points would not be enough to reliably fit a second order curve. This worked out very well with the data set we analyzed 5.2 . We also chose that a positive curvature parameter must be present for a smile to be identified. This also ended up matching with the testing data very well.

Download the code

Files

MATLAB Code Dependencies:

  • MATLAB Computer Vision Toolbox
  • Images of Danny

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Smile identification via feature recognition and corner detection. OpenStax CNX. Dec 17, 2012 Download for free at http://cnx.org/content/col11469/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Smile identification via feature recognition and corner detection' conversation and receive update notifications?

Ask