mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
tesseract app: check if input file exists; fixes #1023
This commit is contained in:
parent
abe40f17c9
commit
1a096441d0
@ -530,6 +530,13 @@ int main(int argc, char** argv) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (FILE* file = fopen(image, "r")) {
|
||||
fclose(file);
|
||||
} else {
|
||||
fprintf(stderr, "Cannot open input file: %s\n", image);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
FixPageSegMode(&api, pagesegmode);
|
||||
|
||||
if (dpi) {
|
||||
@ -537,12 +544,13 @@ int main(int argc, char** argv) {
|
||||
snprintf(dpi_string, 254, "%d", dpi);
|
||||
api.SetVariable("user_defined_dpi", dpi_string);
|
||||
}
|
||||
|
||||
if (pagesegmode == tesseract::PSM_AUTO_ONLY) {
|
||||
int ret_val = EXIT_SUCCESS;
|
||||
|
||||
Pix* pixs = pixRead(image);
|
||||
if (!pixs) {
|
||||
fprintf(stderr, "Cannot open input file: %s\n", image);
|
||||
fprintf(stderr, "Leptonica can process input file: %s\n", image);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user