@@ -176,16 +176,16 @@ void PrintLangsList(tesseract::TessBaseAPI* api) {
176
176
/* *
177
177
* We have 2 possible sources of pagesegmode: a config file and
178
178
* the command line. For backwards compatibility reasons, the
179
- * default in tesseract is tesseract::PSM_SINGLE_BLOCK, but the
180
- * default for this program is tesseract::PSM_AUTO. We will let
181
- * the config file take priority, so the command-line default
182
- * can take priority over the tesseract default, so we use the
183
- * value from the command line only if the retrieved mode
184
- * is still tesseract::PSM_SINGLE_BLOCK, indicating no change
185
- * in any config file. Therefore the only way to force
186
- * tesseract::PSM_SINGLE_BLOCK is from the command line.
187
- * It would be simpler if we could set the value before Init,
188
- * but that doesn't work.
179
+ * default in tesseract is tesseract::PSM_SINGLE_BLOCK, but the
180
+ * default for this program is tesseract::PSM_AUTO. We will let
181
+ * the config file take priority, so the command-line default
182
+ * can take priority over the tesseract default, so we use the
183
+ * value from the command line only if the retrieved mode
184
+ * is still tesseract::PSM_SINGLE_BLOCK, indicating no change
185
+ * in any config file. Therefore the only way to force
186
+ * tesseract::PSM_SINGLE_BLOCK is from the command line.
187
+ * It would be simpler if we could set the value before Init,
188
+ * but that doesn't work.
189
189
*/
190
190
void FixPageSegMode (tesseract::TessBaseAPI* api,
191
191
tesseract::PageSegMode pagesegmode) {
@@ -295,19 +295,37 @@ void PreloadRenderers(tesseract::TessBaseAPI* api,
295
295
if (b) {
296
296
bool font_info;
297
297
api->GetBoolVariable (" hocr_font_info" , &font_info);
298
- renderers->push_back (new tesseract::TessHOcrRenderer (outputbase, font_info));
298
+ renderers->push_back (
299
+ new tesseract::TessHOcrRenderer (outputbase, font_info));
299
300
}
301
+
300
302
api->GetBoolVariable (" tessedit_create_pdf" , &b);
301
303
if (b) {
302
304
renderers->push_back (new tesseract::TessPDFRenderer (outputbase,
303
- api->GetDatapath ()));
305
+ api->GetDatapath ()));
304
306
}
307
+
305
308
api->GetBoolVariable (" tessedit_write_unlv" , &b);
306
- if (b) renderers->push_back (new tesseract::TessUnlvRenderer (outputbase));
309
+ if (b) {
310
+ renderers->push_back (new tesseract::TessUnlvRenderer (outputbase));
311
+ }
312
+
307
313
api->GetBoolVariable (" tessedit_create_boxfile" , &b);
308
- if (b) renderers->push_back (new tesseract::TessBoxTextRenderer (outputbase));
314
+ if (b) {
315
+ renderers->push_back (new tesseract::TessBoxTextRenderer (outputbase));
316
+ }
317
+
318
+ // disable text renderer when using one of these configs:
319
+ // ambigs.train, box.train, box.train.stderr, linebox, rebox
320
+ bool disable_text_renderer =
321
+ (api->GetBoolVariable (" tessedit_ambigs_training" , &b) && b) ||
322
+ (api->GetBoolVariable (" tessedit_resegment_from_boxes" , &b) && b) ||
323
+ (api->GetBoolVariable (" tessedit_make_boxes_from_boxes" , &b) && b);
324
+
309
325
api->GetBoolVariable (" tessedit_create_txt" , &b);
310
- if (b) renderers->push_back (new tesseract::TessTextRenderer (outputbase));
326
+ if (b || (renderers->empty () && !disable_text_renderer) {
327
+ renderers->push_back (new tesseract::TessTextRenderer (outputbase));
328
+ }
311
329
}
312
330
313
331
if (!renderers->empty ()) {
0 commit comments