Skip to content

Instantly share code, notes, and snippets.

@Iyemon-018
Last active May 13, 2018 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Iyemon-018/3360a19fc2683ff51647777237c71c5a to your computer and use it in GitHub Desktop.
Save Iyemon-018/3360a19fc2683ff51647777237c71c5a to your computer and use it in GitHub Desktop.
//
// 以下の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