Beispiel #1
0
        public async Task <bool> IdentifyUser(IdentifyApiModel data)
        {
            var detectFaceResponse = await Post(data.FaceData);

            if (!detectFaceResponse.IsSuccessStatusCode)
            {
                return(false);
            }

            var faceModel = JsonConvert.DeserializeObject <IList <FaceModel> >(detectFaceResponse.ResponseBody).FirstOrDefault();

            string[] faceIds = { faceModel?.FaceId };

            var o = new
            {
                personGroupId = data.PersonGroupId,
                faceIds       = faceIds,
                maxNumOfCandidatesReturned = data.MaxNumOfCandidatesReturned
            };

            var payload = new StringContent(JsonConvert.SerializeObject(o));

            payload.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var identifyResponse = await _faceClientService.Identify(payload);

            return(identifyResponse.IsSuccessStatusCode);
        }
Beispiel #2
0
        public async Task <IActionResult> Identify([FromBody] IdentifyApiModel data)
        {
            if (data == null)
            {
                return(new BadRequestObjectResult("Data is empty"));
            }

            var isIdentify = await _faceRepository.IdentifyUser(data);

            if (isIdentify)
            {
                return(new OkResult());
            }

            return(new BadRequestObjectResult("Identity failed"));
        }