Exemple #1
0
        public ActionResult Upload()
        {
            var imageData = ProcessRequestImage(Request.InputStream);

            var detectResult = _faceService.DetectFace(imageData);

            if (detectResult == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }

            var identityModel = new IdentifyFaceModel {
                PersonGroupId = personGroupId, FaceIds = new string[] { detectResult.FaceId }
            };
            var identityResult = _faceService.IdentifyFace(identityModel);

            if (identityResult == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }

            var personId = identityResult.Candidates.FirstOrDefault()?.PersonId;

            if (string.IsNullOrEmpty(personId))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var face = _faceRepository.Get(Guid.Parse(personId));

            ViewBag.Name = face?.Name;
            return(View("Index"));
        }
Exemple #2
0
        public async Task <ApiResult> Post(string data)
        {
            var base64Array  = Convert.FromBase64String(data);
            var arrayContent = new ByteArrayContent(base64Array);

            arrayContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

            return(await _faceClientService.DetectFace(arrayContent));
        }