public static AddFaceResponse Unmarshall(UnmarshallerContext _ctx)
        {
            AddFaceResponse addFaceResponse = new AddFaceResponse();

            addFaceResponse.HttpResponse = _ctx.HttpResponse;
            addFaceResponse.RequestId    = _ctx.StringValue("AddFace.RequestId");

            AddFaceResponse.AddFace_Data data = new AddFaceResponse.AddFace_Data();
            data.FaceId          = _ctx.StringValue("AddFace.Data.FaceId");
            addFaceResponse.Data = data;

            return(addFaceResponse);
        }
Exemple #2
0
        public async Task <string> AddFaceToPersonAsync(string personGroupId, string personId, byte[] image)
        {
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add(_ocpApimSubscriptionKey, _subscriptionKey);
                string           uri     = $"{_uriBase}/persongroups/{personGroupId}/persons/{personId}/persistedFaces";
                ByteArrayContent content = new ByteArrayContent(image);
                content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                HttpResponseMessage response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    string responseBody = await response.Content.ReadAsStringAsync();

                    AddFaceResponse result = JsonConvert.DeserializeObject <AddFaceResponse>(responseBody);
                    return(result.PersistedFaceId);
                }
                throw CreateHttpException(await response.Content.ReadAsStringAsync());
            }
        }
Exemple #3
0
        public async Task <AddFaceResponse> AddFaceToCollection(string cardholderName, string cardNumber)
        {
            var response = new AddFaceResponse();

            var ms = new MemoryStream();

            Request.Body.CopyTo(ms);
            try
            {
                var result = await _aWSRekonitionFunction.AddFacesToCollection(cardholderName, ms);

                response.MessageCode          = (int)result.HttpStatusCode;
                response.IsAdded              = result.HttpStatusCode == System.Net.HttpStatusCode.OK;
                response.Message              = $"there are {result.FaceRecords.Count} faces data saved";
                dicUserToCard[cardholderName] = cardNumber;
            }
            catch (Exception ex)
            {
            }
            return(response);
        }