Emgu CV smile detection
<p>I am doing a project that takes a photo when you smile, but I am not doing smile detection <em>per se</em>.</p>

<p>(My project is taking a photo when you smile)</p>

<p>How do I do smile detection so that I can take the photo?</p>

<p>This is my project source code:</p>

<pre><code>public partial class Form1 : Form
{
    private Capture capture;        
    private bool captureInProgress;
    private HaarCascade haar;
    private HaarCascade mouth;

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        haar = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
        mouth = new HaarCascade("haarcascade_mcs_mouth.xml");

    }
    private void ProcessFrame(object sender, EventArgs arg)
    {
        Image&lt;Bgr, Byte&gt; ImageFrame = capture.QueryFrame();

        if (ImageFrame !=null)
        {
            Image&lt;Gray, byte&gt; grayFrame = ImageFrame.Convert&lt;Gray, byte&gt;();
            Image&lt;Gray, Byte&gt; gray = ImageFrame.Convert&lt;Gray, Byte&gt;();
            var faces = grayFrame.DetectHaarCascade(haar, 1.4, 4, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(25, 25))[0];
            foreach (var face in faces)
            {
                ImageFrame.Draw(face.rect, new Bgr(Color.Green), 3);

                MCvAvgComp[][] mouthsDetected = gray.DetectHaarCascade(mouth, 1.1, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
                gray.ROI = Rectangle.Empty;

                foreach (MCvAvgComp e in mouthsDetected[0])
                {
                    Rectangle mouthRect = e.rect;
                    mouthRect.Offset(face.rect.X, face.rect.Y);
                    ImageFrame.Draw(mouthRect, new Bgr(Color.Red), 2);
                }
            }

        }

        CamImageBox.Image = ImageFrame;       

    }

    private void btnstart_Click(object sender, EventArgs e)
    {
        #region if capture is not created, create it now
        if (capture == null)
        {
            try
            {
                capture = new Capture();
            }
            catch (NullReferenceException excpt)
            {
                MessageBox.Show(excpt.Message);
            }
        }
        #endregion

        if (capture != null)
        {
            if (captureInProgress)
            {  //if camera is getting frames then stop the capture and set button Text
                // "Start" for resuming capture
                btnStart.Text = "Başlat"; //
                Application.Idle -= ProcessFrame;
            }
            else
            {
                //if camera is NOT getting frames then start the capture and set button
                // Text to "Stop" for pausing capture
                btnStart.Text = "Durdur";
                Application.Idle += ProcessFrame;
            }

            captureInProgress = !captureInProgress;
        }
    }
    private void ReleaseData()
    {
        if (capture != null)
            capture.Dispose();
    }  
  }
}
</code></pre>