private AddFaceResult AddFace(string faceSetName, string externalImageId, string image, ImageType imageType, AddExternalFields addExternalFields) { string uri = String.Format(FrsConstantV2.FACE_ADD_URI, projectId, faceSetName); Dictionary <string, object> jsonObj = new Dictionary <string, object>(); switch (imageType) { case ImageType.BASE64: jsonObj.Add("image_base64", image); break; case ImageType.URL: jsonObj.Add("image_url", image); break; } if (null != externalImageId) { jsonObj.Add("external_image_id", externalImageId); } if (null != addExternalFields) { jsonObj.Add("external_fields", addExternalFields.GetString()); } HttpWebResponse response = accessService.Post(uri, null, HttpUtils.ObjToData(jsonObj), FrsConstantV2.TYPE_JSON); return(HttpUtils.ResponseToObj <AddFaceResult>(response)); }
//FILE public AddFaceResult AddFaceByFile(string faceSetName, string externalImageId, string imagePath, AddExternalFields addExternalFields) { string uri = string.Format(FrsConstantV2.FACE_ADD_URI, this.projectId, faceSetName); MultipartWriter multipart = new MultipartWriter(); multipart.WriteStart(); multipart.WriteFile("image_file", imagePath, imagePath); if (null != externalImageId) { multipart.WriteProperty("external_image_id", externalImageId); } if (null != addExternalFields) { multipart.WriteProperty("external_fields", addExternalFields.GetString()); } byte[] data = multipart.WriteClose(); HttpWebResponse response = this.accessService.Post(uri, null, data, multipart.GetContentType()); return(HttpUtils.ResponseToObj <AddFaceResult>(response)); }