mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +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 ocrEngine = OcrEngine.TryCreateFromLanguage(ocrLanguage) ?? throw new InvalidOperationException("Unable to create OCR engine");
|
||||||
var ocrResult = await ocrEngine.RecognizeAsync(bitmap);
|
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()
|
private static Language GetOCRLanguage()
|
||||||
|
Loading…
Reference in New Issue
Block a user