コード例 #1
0
 public static void StartTrainCam()
 {
     if (ImageBoxOutput != null)
     {
         try
         {
             FaceDetection.Init(faceClasifier);
             Capture = new Capture();
             Capture.FlipHorizontal = true;
             //Event for processing frame
             timer          = new DispatcherTimer();
             timer.Tick    += ProcessTrainFrame;
             timer.Interval = new TimeSpan(0, 0, 0, 0, 50);
             timer.Start();
             Capture.Start();
         }
         catch (NullReferenceException ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
コード例 #2
0
        private static void ProcessTrainFrame(object sender, EventArgs e)
        {
            detectedFaces.Clear();
            //Get Current Frame
            currentFrame = Capture.QueryFrame();
            Image <Gray, byte> grayFrame = currentFrame.Convert <Gray, byte>();

            //Detect Faces in current frame
            FaceDetection.Detect(grayFrame, detectedFaces);

            //Can only Train if there is only one face detected
            if (detectedFaces.Count == 1)
            {
                currentFrame.Draw(detectedFaces[0], new Bgr(Color.Green), 2);
            }

            else
            {
                detectedFaces.Clear();
            }

            //Display current frame
            ImageBoxOutput.Image = currentFrame;
        }