Created
March 19, 2021 21:53
-
-
Save bogdanbujdea/d4a09d78615f785b1332ddf6db65028f to your computer and use it in GitHub Desktop.
Retrieve fields from ID with Form Recognizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async Task Main(string[] args) | |
{ | |
var resultUrl = await StartAnalyzingImage(); // defined here https://gist.github.com/thewindev/a3a06af46693b890e968fbf810d2b50d | |
IdentificationResult result; | |
do | |
{ | |
await Task.Delay(1000); // wait 1 second before checking, otherwise the API will return 429 | |
var json = await _client.GetStringAsync(resultUrl); | |
result = JsonConvert.DeserializeObject<IdentificationResult>(json); | |
} while (result?.Status != "succeeded"); | |
var documentResults = result.AnalyzeResult.DocumentResults; | |
if (documentResults != null && documentResults.Length != 0) | |
{ | |
foreach (var documentResult in documentResults) | |
{ | |
Console.WriteLine($"First name: {documentResult.Fields.FirstName}, confidence: {documentResult.Fields.FirstName.Confidence}"); | |
Console.WriteLine($"Last name: {documentResult.Fields.FirstName}, confidence: {documentResult.Fields.LastName.Confidence}"); | |
Console.WriteLine($"Address: {documentResult.Fields.Address}, confidence: {documentResult.Fields.Address.Confidence}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment