Пример #1
0
        private void detectAndRecognizeFace()
        {
            //needs preproessing
            if (SelectedLogFilter != null)
            {
                if (SelectedLogFilter.Picture != null)
                {
                    Image <Bgr, byte> image = new Image <Bgr, byte>(SelectedLogFilter.Picture);
                    DetectedFaces = FaceRecognitionService.DetectFace(EmguCVHelper.ScaleImage(image, 0.25).ToBitmap());
                    QRCodeContent = (string)QRService.Read(SelectedLogFilter.Picture);

                    Guid id = Guid.Empty;
                    int  i  = 0;
                    if (DetectedFaces.Count > 0)
                    {
                        do
                        {
                            string str = FaceRecognitionService.RecognizeFace(DetectedFaces[i].Bitmap);
                            Guid.TryParse(str, out id);
                            i++;
                        } while (id != Guid.Empty && i < DetectedFaces.Count);
                    }

                    if (id != Guid.Empty)
                    {
                        DetectedEmployee = AutomatedAttendanceSystem.RetrieveEmployee(id);
                    }
                    else
                    {
                        DetectedEmployee = null;
                    }
                    //if (DetectedFaces.Count > 0)
                    //{
                    //    EmguCVHelper.DrawObjectsBoundaries(image, DetectedFaces, 0.25);

                    //    SelectedLogFilter.Picture = image.ToBitmap();

                    //}
                }
            }
        }