public static async Task <ImageInsights> ProcessImageAsync(Func <Task <Stream> > imageStreamCallback, string imageId)
        {
            VisualFeature[] DefaultVisualFeaturesList = new VisualFeature[] { VisualFeature.Tags, VisualFeature.Description };

            var imageAnalysisResult = await VisionServiceHelper.AnalyzeImageAsync(imageStreamCallback, DefaultVisualFeaturesList);

            ImageInsights result = new ImageInsights
            {
                ImageId = imageId,
                Caption = imageAnalysisResult.Description.Captions[0].Text,
                Tags    = imageAnalysisResult.Tags.Select(t => t.Name).ToArray()
            };

            return(result);
        }
Exemple #2
0
        // Step 2: Create the ProcessImageAsync method:
        public static async Task <ImageInsights> ProcessImageAsync(Func <Task <Stream> > imageStreamCallback, string imageId)
        {
            // Step 3: Set up an array that we'll fill in over the course of the processor:
            VisualFeature[] DefaultVisualFeaturesList = new VisualFeature[] { VisualFeature.Tags, VisualFeature.Description };
            // Step 4: Call the Computer Vision service and store the results in imageAnalysisResult:
            var imageAnalysisResult = await VisionServiceHelper.AnalyzeImageAsync(imageStreamCallback, DefaultVisualFeaturesList);

            // Step 5: Create an entry in ImageInsights:
            ImageInsights result = new ImageInsights
            {
                ImageId = imageId,
                Caption = imageAnalysisResult.Description.Captions[0].Text,
                Tags    = imageAnalysisResult.Tags.Select(t => t.Name).ToArray()
            };

            // Step 6: Return results:
            return(result);
        }