public async static Task <List <IdentifyResult> > IdentifyFacesAsync(string personGroupId, List <string> faceIds) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Common.CoreConstants.FaceApiSubscriptionKey); IdentifyInfo identifyInfo = new IdentifyInfo() { personGroupId = personGroupId, faceIds = faceIds, }; var payload = new HttpStringContent(JsonConvert.SerializeObject(identifyInfo)); payload.Headers.ContentType = new HttpMediaTypeHeaderValue("application/json"); var response = await client.PostAsync(new Uri($"{CogsExplorer.Common.CoreConstants.CognitiveServicesBaseUrl}/face/v1.0/identify"), payload); List <IdentifyResult> identifyResults = new List <IdentifyResult>(); try { var results = await response.Content.ReadAsStringAsync(); dynamic f = JsonConvert.DeserializeObject(results); identifyResults = JsonConvert.DeserializeObject <List <IdentifyResult> >(results); } catch (Exception ex) { } return(identifyResults); }
private void GoToIdentifyState() { Ensure.NotNull(_connection, "_connection"); _connectingPhase = ConnectingPhase.Identification; _identifyInfo = new IdentifyInfo(Guid.NewGuid(), _stopwatch.Elapsed); var dto = new ClientMessage.IdentifyClient(ClientVersion, _esConnection.ConnectionName); _connection.EnqueueSend(new TcpPackage(TcpCommand.IdentifyClient, _identifyInfo.CorrelationId, dto.Serialize())); }
private void GoToIdentifyState() { Ensure.NotNull(_connection, "_connection"); _connectingPhase = ConnectingPhase.Identification; _identifyInfo = new IdentifyInfo(Guid.NewGuid(), _stopwatch.Elapsed); var dto = new ClientMessage.IdentifyClient(ClientVersion, _esConnection.ConnectionName); if (_settings.VerboseLogging) { _settings.Log.Debug( $"IdentifyClient; Client Version: {ClientVersion}, ConnectionName: {_esConnection.ConnectionName}, "); } _connection.EnqueueSend(new TcpPackage(TcpCommand.IdentifyClient, _identifyInfo.CorrelationId, dto.Serialize())); }