public async Task <MatchResult> MatchImageAsync(Stream content, bool cacheImage, string listid)
        {
            var imageType = ModeratorHelper.GetImageFormat(content);

            if (imageType.Equals(ModeratorHelper.ImageFormat.unknown))
            {
                throw new Exception($"Image type: {imageType} not supported");
            }
            content.Position = 0;
            List <KeyValue> metaData = new List <KeyValue>();

            metaData.Add(new KeyValue()
            {
                Key   = "CacheImage",
                Value = cacheImage.ToString()
            });
            metaData.Add(new KeyValue()
            {
                Key   = "subscription-key",
                Value = _subscriptionKey
            });
            metaData.Add(new KeyValue()
            {
                Key   = "listid",
                Value = listid
            });

            return(await InvokeImageModeratorAsync <Stream, MatchResult>(content, Constants.Operations.Match.ToString(), metaData).ConfigureAwait(false));
        }
示例#2
0
        public async Task <OcrImageResult> OCRImageAsync(Stream content, bool cacheImage, bool enhanced = true, string language = "eng")
        {
            var imageType = ModeratorHelper.GetImageFormat(content);

            if (imageType.Equals(ModeratorHelper.ImageFormat.unknown))
            {
                throw new Exception($"Image type: {imageType} not supported");
            }
            content.Position = 0;
            List <KeyValue> metaData = new List <KeyValue>();

            metaData.Add(new KeyValue()
            {
                Key   = "CacheImage",
                Value = cacheImage.ToString()
            });
            metaData.Add(new KeyValue()
            {
                Key   = "enhanced",
                Value = enhanced.ToString()
            });
            metaData.Add(new KeyValue()
            {
                Key   = "language",
                Value = language
            });

            return(await this.InvokeImageModeratorAsync <Stream, OcrImageResult>(content, Constants.Operations.OCR.ToString(), metaData).ConfigureAwait(false));
        }
示例#3
0
        public async Task <CreateJobResult> CreateJob(string teamName, Stream content, ContentType contentType,
                                                      string contentId, string workFlowName,
                                                      string callBackEndpoint)
        {
            var imageType = ModeratorHelper.GetImageFormat(content);

            if (imageType.Equals(ModeratorHelper.ImageFormat.unknown))
            {
                throw new Exception($"Image type: {imageType} not supported");
            }
            content.Position = 0;
            List <KeyValue> metaData = new List <KeyValue>();

            metaData.Add(new KeyValue()
            {
                Key   = "ContentType",
                Value = contentType.ToString()
            });

            metaData.Add(new KeyValue()
            {
                Key   = "ContentId",
                Value = contentId
            });

            metaData.Add(new KeyValue()
            {
                Key   = "WorkflowName",
                Value = workFlowName
            });

            metaData.Add(new KeyValue()
            {
                Key   = "CallBackEndpoint",
                Value = callBackEndpoint
            });

            return
                (await
                 InvokeAsync <Stream, CreateJobResult>(content,
                                                       string.Format(Constants.CREATE_JOB, teamName), Constants.HttpMethod.POST, metaData)
                 .ConfigureAwait(false));
        }
示例#4
0
        public async Task <DetectFacesResult> DetectFacesImageAsync(Stream content, bool cacheImage)
        {
            var imageType = ModeratorHelper.GetImageFormat(content);

            if (imageType.Equals(ModeratorHelper.ImageFormat.unknown))
            {
                throw new Exception($"Image type: {imageType} not supported");
            }
            content.Position = 0;
            List <KeyValue> metaData = new List <KeyValue>();

            metaData.Add(new KeyValue()
            {
                Key   = "CacheImage",
                Value = cacheImage.ToString()
            });

            return(await this.InvokeImageModeratorAsync <Stream, DetectFacesResult>(content, Constants.Operations.FindFaces.ToString(), metaData).ConfigureAwait(false));
        }