public async Task <OcrResult> RecognizeAsync(Stream image, CancellationToken token)
        {
            var inputFile = await WriteFileAsync(image, token);

            var result = await Cli.Wrap(TesseractBinary)
                         .SetArguments(FormatCliArguments(inputFile))
                         .SetStandardOutputEncoding(Encoding.UTF8)
                         .SetWorkingDirectory(WorkingDirectory)
                         .SetCancellationToken(token)
                         .ExecuteAsync();

            if (result.ExitCode == 0)
            {
                var text = result.StandardOutput;
                return(OcrResult.Success(text));
            }
            else
            {
                var error = result.StandardError;
                return(OcrResult.Fail(error));
            }
        }
Exemple #2
0
 public Task <OcrResult> RecognizeAsync(Stream image, CancellationToken token)
 {
     return(Task.FromResult(OcrResult.Success(Text)));
 }