mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-05 02:47:00 +08:00
Merge pull request #1818 from stweil/psm
Fix potential crash with --psm 0 and use osd.traineddata automatically
This commit is contained in:
commit
c044b8c916
@ -359,6 +359,14 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
|
|||||||
|
|
||||||
*arg_i = i;
|
*arg_i = i;
|
||||||
|
|
||||||
|
if (*pagesegmode == tesseract::PSM_OSD_ONLY) {
|
||||||
|
// That mode requires osd.traineddata, no other language or script files.
|
||||||
|
if (*lang != nullptr && strcmp(*lang, "osd")) {
|
||||||
|
fprintf(stderr, "Warning, ignoring -l %s for --psm 0\n", *lang);
|
||||||
|
}
|
||||||
|
*lang = "osd";
|
||||||
|
}
|
||||||
|
|
||||||
if (*outputbase == nullptr && noocr == false) {
|
if (*outputbase == nullptr && noocr == false) {
|
||||||
PrintHelpMessage(argv[0]);
|
PrintHelpMessage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -432,7 +440,7 @@ static void PreloadRenderers(
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
const char* lang = "eng";
|
const char* lang = nullptr;
|
||||||
const char* image = nullptr;
|
const char* image = nullptr;
|
||||||
const char* outputbase = nullptr;
|
const char* outputbase = nullptr;
|
||||||
const char* datapath = nullptr;
|
const char* datapath = nullptr;
|
||||||
@ -465,6 +473,11 @@ int main(int argc, char** argv) {
|
|||||||
&print_parameters, &vars_vec, &vars_values, &arg_i, &pagesegmode,
|
&print_parameters, &vars_vec, &vars_values, &arg_i, &pagesegmode,
|
||||||
&enginemode);
|
&enginemode);
|
||||||
|
|
||||||
|
if (lang == nullptr) {
|
||||||
|
// Set default language if none was given.
|
||||||
|
lang = "eng";
|
||||||
|
}
|
||||||
|
|
||||||
if (image == nullptr && !list_langs && !print_parameters)
|
if (image == nullptr && !list_langs && !print_parameters)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user