title: How to scale an image using eye tracking in WPF?
body: <p>I'm trying to zoom in and out each frame from a live video stream from a webcam, by opening or squinting my eyes.  I already have the eye tracking part working, but I can't figure out where to fit in the ScaleTransform.  Below is the existing code I have:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Windows.Forms;
  using Emgu.CV.Structure;
  using Emgu.CV.UI;
  using Emgu.CV;
  using System.Drawing;
  using System.Diagnostics;
  using System.Windows.Media;
  
  namespace eyeDetection
  {
     static class Program
     {
        /// &lt;summary&gt;
        /// The main entry point for the application.
        /// &lt;/summary&gt;
        [STAThread]
        static void Main()
        {
           Application.EnableVisualStyles();
           Application.SetCompatibleTextRenderingDefault(false);
           Run();
        }
  
        static void Run()
        {
            ImageViewer viewer = new ImageViewer(); //create an image viewer
            Capture capture = new Capture(); //create a camera capture
            Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
                {   // run this until application closed (close button click on image viewer)
                    Image&lt;Bgr, Byte&gt; image = capture.QueryFrame();
                    Image&lt;Gray, Byte&gt; gray = image.Convert&lt;Gray, Byte&gt;(); //Convert it to Grayscale
  
                    Stopwatch watch = Stopwatch.StartNew();
                    //normalizes brightness and increases contrast of the image
                    gray._EqualizeHist();
  
                    //Read the HaarCascade objects
                   HaarCascade eye = new HaarCascade("haarcascade_eye.xml");
  
                   MCvAvgComp[][] eyeDetected = gray.DetectHaarCascade(
                       eye,
                       1.1,
                       10,
                       Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                       new Size(20, 20));
  
                    foreach (MCvAvgComp e in eyeDetected[0])
                    {
                        //draw the eyes detected in the 0th (gray) channel with blue color
                        image.Draw(e.rect, new Bgr(Color.Blue), 2);
                    }
  
  
                      watch.Stop();
                    //display the image 
                    viewer.Image = image; //draw the image obtained from camera
                });
            viewer.ShowDialog(); //show the image viewer
        }
     }
  }
  </code></pre>