public IHttpActionResult Recognition(DetectionViewModel detectionViewModel) { var faceBitmap = detectionViewModel.GetImage(); var personsOnImage = _faceDetectionLibrary.FaceRecognition(faceBitmap); if (personsOnImage == null) { return BadRequest("No faces found."); } else if (personsOnImage.Count == 0) { return BadRequest("Face recognition could not found any persons on image."); } else if (personsOnImage.Count == 1) { var personOnImage = personsOnImage.First(); if (personOnImage.RecognitionStatus == FaceRecognitionStatus.FaceRecognitionFailure || personOnImage.RecognitionStatus == FaceRecognitionStatus.FaceRecognitionError) { if (personOnImage.PersonOnFace == null) { return BadRequest("Face recognition failed with eigen distance " + personOnImage.EigenDistance + "."); } else { return BadRequest("Face recognition failed with eigen distance " + personOnImage.EigenDistance + ". Presumed person on image is: "+personOnImage.PersonOnFace.FirstName+ " "+ personOnImage.PersonOnFace.LastName); } } } return Ok(personsOnImage); }
public DetectionViewModel Detect(DetectionViewModel detectionViewModel) { var faceBitmap = detectionViewModel.GetImage(); var faces = _faceDetectionLibrary.FindFaces(faceBitmap); faceBitmap = _faceDetectionLibrary.DrawFacesBoundsOnBitmap(faceBitmap, faces); detectionViewModel = DetectionViewModel.Build(faceBitmap); return detectionViewModel; }