public async Task <IActionResult> Search(FaceSearchModel model) { var matches = new Dictionary <string, float>(); List <Face> detectedFaces; if (!string.IsNullOrEmpty(model.Url)) { detectedFaces = await _faceRecognition.Detect(new Uri(model.Url)); } else if (model.Face != null) { detectedFaces = await _faceRecognition.Detect(model.Face.OpenReadStream()); } else { return(BadRequest()); } foreach (var detectedFace in detectedFaces) { Dictionary <string, float> found = await _faceRecognition.Search(model.ListId, detectedFace.Id.ToString(), new Dictionary <string, object> { { "largeFaceListId", model.ListId } }); foreach (var match in found) { matches.Add(match.Key, match.Value); } } return(Ok(matches)); }
public static List <FaceSearchModel> Search(string faceId) { var result = FaceManager.getJsonReturn("search", new NameValueCollection() { { "face_token", faceId }, { "outer_id", FACESET_OUTER_ID } }); if (result == null) { return(new List <FaceSearchModel>()); } if (result.ContainsKey("error_message")) { return(new List <FaceSearchModel>()); } List <FaceSearchModel> data = new List <FaceSearchModel>(); foreach (var item in result["results"]) { FaceSearchModel element = new FaceSearchModel(); element.Read(item); data.Add(element); } return(data); }