1using System.Net.Http.Headers;
34 Uri Uri =
new(
"https://" + ServiceRef.TagProfile.Domain +
"/Tesseract/Api");
35 using HttpClient HttpClient =
new();
36 using HttpRequestMessage Request =
new()
39 Method = HttpMethod.Post,
40 Content =
new ByteArrayContent(Png)
43 Request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(
"image/png");
44 Request.Headers.Authorization =
new AuthenticationHeaderValue(
"Bearer", Token);
46 if (!
string.IsNullOrEmpty(Language))
47 Request.Headers.Add(
"X-LANGUAGE", Language);
52 HttpResponseMessage Response = await HttpClient.SendAsync(Request);
53 Response.EnsureSuccessStatusCode();
55 byte[] Bin = await Response.Content.ReadAsByteArrayAsync();
56 string? ContentType = Response.Content.Headers.ContentType?.ToString();
59 if (Obj is not
string Text)
60 throw new Exception(
"Unexpected response.");
62 if (
string.IsNullOrEmpty(Text))
65 return Text.Split(
CommonTypes.
CRLF, StringSplitOptions.RemoveEmptyEntries);
Static methods managing conversion to and from bitmap representations.
static byte[] EncodeAsPng(IMatrix M)
Encodes an image in a matrix using PNG.
Optical Character Recognition (OCR) Service.
async Task< string[]> ProcessImage(IMatrix Image, string Language, PageSegmentationMode? PageSegmentationMode)
Processes an image and tries to extract strings of characters from it.
OcrService()
Optical Character Recognition (OCR) Service.
Base class that references services in the app.
static IXmppService XmppService
The XMPP service for XMPP communication.
Helps with parsing of commong data types.
static readonly char[] CRLF
Contains the CR LF character sequence.
Static class managing encoding and decoding of internet content.
static Task< object > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
Interface for the Optical Character Recognition (OCR) Service.
PageSegmentationMode
Page Segmentation Mode