Skip to content

Instantly share code, notes, and snippets.

@Iyemon-018 Iyemon-018/VisionAPIExample01.cs Secret

Last active May 13, 2018
Embed
What would you like to do?
//
// 以下のusing を追加しておく。
//
// using GCP.VisionAPI.Sample.Services;
// using Google.Cloud.Vision.V1;
//
Image image = Image.FromFile(fileName);
ImageAnnotatorClient client = ImageAnnotatorClient.Create();
// ここで解析結果を取得する。
TextAnnotation response = client.DetectDocumentText(image);
Block[] blocks = response.Pages.SelectMany(x => x.Blocks).ToArray();
Paragraph[] paragraphs = blocks.SelectMany(x => x.Paragraphs).ToArray();
Word[] words = paragraphs.SelectMany(x => x.Words).ToArray();
Symbol[] symbols = words.SelectMany(x => x.Symbols).ToArray();
string[] textList = symbols.Select(x => x.Text).ToArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.