/// <summary> /// شناسایی چهره /// </summary> /// <returns>شناسنه داخلی</returns> public object Run() { ///[Checking for face] string l_employeeIDString = string.Empty; //if (Check()) //{ if (m_faces.Count > 0) { //Face recognition is run over all detected "faces" and the first valid occurance is retrned foreach (DetectedObject face in m_faces) { l_employeeIDString = FaceRecognition.RecognizeFace(face); if (!string.IsNullOrEmpty(l_employeeIDString)) { break; } } //m_faces.FirstOrDefault(face => !string.IsNullOrEmpty((l_employeeIDString = FaceRecognition.RecognizeFace(face)))); } // } ///[Checking for face] ///[Returning found Employee internal id] Guid l_employeeId = Guid.Empty; Guid.TryParse(l_employeeIDString, out l_employeeId); return(l_employeeId); ///[Running face recognition] }
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(); //} } } }