mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-23 19:49:17 +08:00
Made Image to Text raise error on empty output
This commit is contained in:
parent
a0754023d2
commit
ddbf4a30a8
@ -22,7 +22,9 @@ public static class OcrHelpers
|
||||
var ocrEngine = OcrEngine.TryCreateFromLanguage(ocrLanguage) ?? throw new InvalidOperationException("Unable to create OCR engine");
|
||||
var ocrResult = await ocrEngine.RecognizeAsync(bitmap);
|
||||
|
||||
return ocrResult.Text;
|
||||
return string.IsNullOrWhiteSpace(ocrResult.Text)
|
||||
? throw new InvalidOperationException("Unable to extract text from image or image does not contain text")
|
||||
: ocrResult.Text;
|
||||
}
|
||||
|
||||
private static Language GetOCRLanguage()
|
||||
|
Loading…
Reference in New Issue
Block a user