コード例 #1
0
        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);
        }
コード例 #2
0
        public static DetectionViewModel Build(Bitmap image)
        {
            var detectionViewModel = new DetectionViewModel
            {
                ImageBase64 = ImageUtilities.ImageToBase64(image)
            };

            return detectionViewModel;
        }
コード例 #3
0
        public static DetectionViewModel Build(Bitmap image)
        {
            var detectionViewModel = new DetectionViewModel
            {
                ImageBase64 = ImageUtilities.ImageToBase64(image)
            };

            return(detectionViewModel);
        }
コード例 #4
0
        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;
        }