/// <summary> /// Associates a given media file with an exiting subject /// </summary> /// <param name="mediaId">Media ID</param> /// <param name="subjectUid">Subject UID</param> /// <param name="forceFeedback">Fore feedback flag</param> /// <returns>Cogniac.CaptureId object</returns> public CaptureId AssociateMediaToSubject(string mediaId, string subjectUid, bool forceFeedback = false) { if (string.IsNullOrEmpty(mediaId) || string.IsNullOrEmpty(subjectUid)) { throw new ArgumentException(message: "Provided media ID or subject UID are is or empty."); } else { Dictionary <string, object> dict = new Dictionary <string, object> { { "media_id", mediaId }, { "force_feedback", forceFeedback } }; var request = new RestRequest(Method.POST); string data = Helpers.MapToQueryString(dict); IRestResponse response = ExecuteRequest($"{_urlPrefix}/subjects/{subjectUid}/media?{data}", request); if ((response.StatusCode == HttpStatusCode.OK) && (response.IsSuccessful == true)) { return(CaptureId.FromJson(response.Content)); } else { throw new WebException(message: "Network error: " + response.Content); } } }
/// <summary> /// Associates a given media file with an exiting subject /// </summary> /// <param name="mediaId">Media ID</param> /// <param name="subjectUid">Subject UID</param> /// <param name="forceFeedback">Fore feedback flag</param> /// <param name="enableWaitResult">Enable wait flag</param> /// <param name="probability">Association probability, only valid if consensus is null</param> /// <param name="consensus">Consensus value</param> /// <returns>Cogniac.CaptureId object</returns> public CaptureId AssociateMediaToSubject(string mediaId, string subjectUid, bool forceFeedback = false, bool enableWaitResult = false, double?probability = null, bool?consensus = null) { if (string.IsNullOrEmpty(mediaId) || string.IsNullOrEmpty(subjectUid)) { throw new ArgumentException(message: "Provided media ID or subject UID are is or empty."); } else { Dictionary <string, object> dict = new Dictionary <string, object> { { "media_id", mediaId }, { "force_feedback", forceFeedback }, { "enable_wait_result", enableWaitResult } }; // Perform some logic for the probability if (consensus == null) { if (probability == null) { probability = 0.99; } // Insert it into the API call dict.AddIfNotNull("uncal_prob", probability); } else { dict.AddIfNotNull("consensus", consensus); } var request = new RestRequest(Method.POST); string data = Helpers.MapToQueryString(dict); IRestResponse response = ExecuteRequest($"{_urlPrefix}/subjects/{subjectUid}/media?{data}", request); if ((response.StatusCode == HttpStatusCode.OK) && (response.IsSuccessful == true)) { return(CaptureId.FromJson(response.Content)); } else { throw new WebException(message: "Network error: " + response.Content); } } }