public static async Task ProcessImageAsync(ComputerVisionClient client, Uri imageUri, string outFolder) { string fileName = Path.GetFileName(imageUri.AbsolutePath); string outFilePath = Path.Combine(outFolder, fileName); Directory.CreateDirectory(outFolder); // Analyze var features = ComputerVision.GetSampleVisualFeatureTypes(); var json = ComputerVisionHelper.GetJson(await ComputerVision.AnalyzeImageUri(client, imageUri, features)); WriteToJsonFile <JObject>(outFilePath + "-AnalyzeResults.json", json); // Detect Domain Specific "landmarks as an example" var domainspecific = await ComputerVision.DetectDomainSpecific(client, imageUri, "landmarks"); WriteToJsonFile <JObject>(outFilePath + "-DomainSpecific.json", domainspecific); // Read Image - text detection var readResult = ComputerVisionHelper.GetReadResultLines( await ComputerVision.ReadImageAsync(client, imageUri)); await File.WriteAllLinesAsync(outFilePath + "-ReadResults.txt", readResult); // OCR - text extraction var ocrResult = await ComputerVision.RecognizeTextFromImageUri(client, imageUri, false); var ocrLineTexts = ComputerVisionHelper.GetOcrResultLineTexts(ocrResult); await File.WriteAllLinesAsync(outFilePath + "-ReadOcrResults.txt", ocrLineTexts); }
public static async Task ProcessImagesFromFolderAsync(string key, string endpoint, string sourceFolder, string outFolder) { ComputerVisionClient client = ComputerVision.Authenticate(endpoint, key); IEnumerable <Uri> fileUris = GetFileUris(sourceFolder); foreach (var fileUri in fileUris) { await ProcessImageAsync(client, fileUri, outFolder); } }
public static async Task ProcessImageAsync(string key, string endpoint, Uri imageUri, string outFolder) { ComputerVisionClient client = ComputerVision.Authenticate(endpoint, key); await ProcessImageAsync(client, imageUri, outFolder); }