Ejemplo n.º 1
0
        public TrainingForm(String _name)
        {
            InitializeComponent();

            name = _name;

            photoCounter = 3;

            capture = new Capture();
            CameraCapture.Init(capture);
            BlinkDetector.Init(new CascadeClassifier(eyePairClassifier), new CascadeClassifier(eyeClassifier));
            FaceDetection.Init(new CascadeClassifier(faceClassifier));
            TrainingStateManager.Clear();
            BlinkStateManager.Clear();

            labelInstruction.Text = "We will now capture a few images \nof your face";
            labelRemaining.Text   = photoCounter + " more capture to finish";
            buttonFinish.Enabled  = false;
            CameraCapture.Start();

            timer          = new DispatcherTimer();
            timer.Tick    += ProcessTrainFrame;
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            timer.Start();
        }
Ejemplo n.º 2
0
        private void ProcessTrainFrame(object sender, EventArgs e)
        {
            //Get Current Frame
            Image <Bgr, byte>  currentFrame = capture.QueryFrame();
            Image <Gray, byte> grayFrame    = currentFrame.Convert <Gray, byte>();

            Rectangle facePos = FaceDetection.Detect(grayFrame);

            TrainingStateManager.AddToHistory(grayFrame.Copy(), facePos);

            PrintInstruction();


            if (!facePos.Equals(Rectangle.Empty))
            {
                BlinkStateManager.faceDetected = true;
                Image <Gray, byte> faceImage = grayFrame.Copy(facePos);

                CheckBlink(faceImage);
            }

            imageBox.Image = currentFrame;
        }