コード例 #1
0
        public async Task <CreateImagesResult> CreateImagesAsync(dynamic objectToProcess = null,
                                                                 Dictionary <string, string> parameters = null)
        {
            var requestDictionary = new Dictionary <string, object>()
            {
                { "Endpoint_Uri", $"{_endpointUri}" },
                { "Endpoint_Version", _version },
                { "Operation_Method", "POST" },
                { "Operation_Path", "training" },
                { "Operation_SubPath", $"projects/{objectToProcess.projectId}/images/urls" },
                { "Headers", _headers.with("ContentType", "application/octet-stream") },
                { "Parameters",
                  new Dictionary <string, string>()
                  {
                      { "name", "testTag" }
                  } },
                { "RequestObject", objectToProcess }
            };


            return
                (await RequestProcessor
                 .ProcessRequest <object, CreateImagesResult>(
                     requestDictionary));
        }
コード例 #2
0
        public static async Task <object> DeleteFaceListAsync(dynamic objectToProcess = null)
        {
            var requestDictionary = new Dictionary <string, object>()
            {
                { "EndpointUri", $"{ApiUri}/face" },
                { "Version", "v1.0" },
                { "Method", "DELETE" },
                { "RequestObject", objectToProcess },
                { "RequestSubPath", $"{((dynamic)objectToProcess).faceListId}" },
                { "RequestPath", "facelists" },
                { "Headers",
                  new Dictionary <string, string>
                  {
                      { "Ocp-Apim-Subscription-Key", SubscriptionKey },
                      { "ContentType", "application/octet-stream" },
                      { "Accept", "application/json" }
                  } }
            };

            return
                (await RequestProcessor
                 .ProcessRequest(
                     requestDictionary,
                     GetPostRequestAction <object>(),
                     GetPreRequestAction <object>()));
        }
コード例 #3
0
        public static async Task <object> AddFaceWithUrlAsync(dynamic objectToProcess)
        {
            var requestDictionary = new Dictionary <string, object>()
            {
                { "EndpointUri", $"{ApiUri}/face" },
                { "Version", "v1.0" },
                { "Method", "POST" },
                { "RequestObject", objectToProcess },
                { "RequestSubPath", $"{objectToProcess.faceListId}/persistedFaces" },
                { "RequestPath", "facelists" },
                { "Headers",
                  new Dictionary <string, string>
                  {
                      { "Ocp-Apim-Subscription-Key", SubscriptionKey },
                      { "ContentType", "application/octet-stream" },
                      { "Accept", "application/json" }
                  } },
                { "Parameters",
                  new Dictionary <string, string>()
                  {
                      { "targetFace", objectToProcess.targetFace }
                  } }
            };

            return
                (await RequestProcessor
                 .ProcessRequest(
                     requestDictionary,
                     GetPostRequestAction <object>(),
                     GetPreRequestAction <object>()));
        }
コード例 #4
0
        public async Task <object> RecognizeTextWithUrl(object objectToProcess = null,
                                                        Dictionary <string, string> parameters = null)
        {
            var requestDictionary = new Dictionary <string, object>()
            {
                { "Endpoint_Uri", $"{_endpointUri}" },
                { "Endpoint_Version", _version },
                { "Operation_Method", "POST" },
                { "Operation_Path", "recognizeText" },
                { "Operation_SubPath", "" },
                { "Headers", _headers
                  .Append(new KeyValuePair <string, string> ("ContentType", "application/json"))
                  .ToDictionary(kv => kv.Key, kv => kv.Value) },
                { "Parameters", parameters },
                { "RequestObject", objectToProcess }
            };

            return(await RequestProcessor.ProcessRequest <object, object>(requestDictionary));
        }
コード例 #5
0
        public static async Task <object> AddFaceAsync(dynamic objectToProcess)
        {
            using (FileStream fileStream = new FileStream(objectToProcess.imageFilePath, FileMode.Open, FileAccess.Read))
            {
                BinaryReader binaryReader = new BinaryReader(fileStream);
                var          bytes        = binaryReader.ReadBytes((int)fileStream.Length);

                var requestDictionary = new Dictionary <string, object>()
                {
                    { "EndpointUri", $"{ApiUri}/face" },
                    { "Version", "v1.0" },
                    { "Method", "POST" },
                    { "RequestObject", bytes },
                    { "RequestSubPath", $"{objectToProcess.faceListId}/persistedFaces" },
                    { "RequestPath", "facelists" },
                    { "Headers",
                      new Dictionary <string, string>
                      {
                          { "Ocp-Apim-Subscription-Key", SubscriptionKey },
                          { "ContentType", "application/octet-stream" },
                          { "Accept", "application/json" }
                      } },
                    { "Parameters",
                      new Dictionary <string, string>()
                      {
                          { "detectionModel", objectToProcess.detectionModel },
                          { "targetFace", objectToProcess.targetFace }
                      } }
                };

                return
                    (await RequestProcessor
                     .ProcessRequest(
                         requestDictionary,
                         GetPostStreamRequestAction <object>(),
                         GetPreRequestAction <object>()));
            }
        }