From 5e0f9a48989892e620cb281c9f88dda0f26027e9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 24 Dec 2016 10:42:35 +0300 Subject: [PATCH] Disabled info and warnings from Tesseract --- src/lib_ccx/hardsubx.c | 8 +++++++- src/lib_ccx/ocr.c | 24 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c index 9afa0c07..b1d22a2b 100644 --- a/src/lib_ccx/hardsubx.c +++ b/src/lib_ccx/hardsubx.c @@ -215,7 +215,13 @@ struct lib_hardsubx_ctx* _init_hardsubx(struct ccx_s_options *options) memset(ctx, 0, sizeof(struct lib_hardsubx_ctx)); ctx->tess_handle = TessBaseAPICreate(); - if(TessBaseAPIInit3(ctx->tess_handle, NULL, "eng") != 0) + char* pars_vec = strdup("debug_file"); + char* pars_values = strdup("/dev/null"); + int res = TessBaseAPIInit4(ctx->tess_handle, NULL, "eng", OEM_TESSERACT_ONLY, NULL, 0, &pars_vec, + &pars_values, 1, false); + free(pars_vec); + free(pars_values); + if(res != 0) { fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory to initialize Tesseract!"); } diff --git a/src/lib_ccx/ocr.c b/src/lib_ccx/ocr.c index 81921854..2639e491 100644 --- a/src/lib_ccx/ocr.c +++ b/src/lib_ccx/ocr.c @@ -126,12 +126,24 @@ void* init_ocr(int lang_index) lang_index = 1; } - if(ccx_options.ocrlang) - ret = TessBaseAPIInit3(ctx->api, NULL, ccx_options.ocrlang); - else if(data_location == 1) - ret = TessBaseAPIInit3(ctx->api, NULL, language[lang_index]); - else - ret = TessBaseAPIInit3(ctx->api, tessdata_dir_path, language[lang_index]); + char* lang = NULL, *tessdata_path = NULL; + if (ccx_options.ocrlang) + lang = ccx_options.ocrlang; + else if (data_location == 1) + lang = language[lang_index]; + else { + lang = language[lang_index]; + tessdata_path = tessdata_dir_path; + } + + char* pars_vec = strdup("debug_file"); + char* pars_values = strdup("/dev/null"); + + ret = TessBaseAPIInit4(ctx->api, tessdata_path, lang, OEM_TESSERACT_ONLY, NULL, 0, &pars_vec, + &pars_values, 1, false); + + free(pars_vec); + free(pars_values); if(ret < 0) {