@@ -242,12 +242,9 @@ int Tesseract::AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST* blocks,
242
242
BLOCK_LIST found_blocks;
243
243
TO_BLOCK_LIST temp_blocks;
244
244
245
- bool single_column = !PSM_COL_FIND_ENABLED (pageseg_mode);
246
- bool osd_enabled = PSM_OSD_ENABLED (pageseg_mode);
247
- bool osd_only = pageseg_mode == PSM_OSD_ONLY;
248
245
ColumnFinder* finder = SetupPageSegAndDetectOrientation (
249
- single_column, osd_enabled, osd_only, blocks, osd_tess, osr ,
250
- &temp_blocks, &photomask_pix, & musicmask_pix);
246
+ pageseg_mode, blocks, osd_tess, osr, &temp_blocks, &photomask_pix ,
247
+ &musicmask_pix);
251
248
int result = 0 ;
252
249
if (finder != NULL ) {
253
250
TO_BLOCK_IT to_block_it (&temp_blocks);
@@ -310,9 +307,9 @@ static void AddAllScriptsConverted(const UNICHARSET& sid_set,
310
307
* The returned ColumnFinder must be deleted after use.
311
308
*/
312
309
ColumnFinder* Tesseract::SetupPageSegAndDetectOrientation (
313
- bool single_column, bool osd, bool only_osd ,
314
- BLOCK_LIST* blocks, Tesseract* osd_tess, OSResults* osr ,
315
- TO_BLOCK_LIST* to_blocks, Pix** photo_mask_pix, Pix** music_mask_pix) {
310
+ PageSegMode pageseg_mode, BLOCK_LIST* blocks, Tesseract* osd_tess ,
311
+ OSResults* osr, TO_BLOCK_LIST* to_blocks, Pix** photo_mask_pix ,
312
+ Pix** music_mask_pix) {
316
313
int vertical_x = 0 ;
317
314
int vertical_y = 1 ;
318
315
TabVector_LIST v_lines;
@@ -334,8 +331,7 @@ ColumnFinder* Tesseract::SetupPageSegAndDetectOrientation(
334
331
*photo_mask_pix = ImageFind::FindImages (pix_binary_);
335
332
if (tessedit_dump_pageseg_images)
336
333
pixWrite (" tessnoimages.png" , pix_binary_, IFF_PNG);
337
- if (single_column)
338
- v_lines.clear ();
334
+ if (!PSM_COL_FIND_ENABLED (pageseg_mode)) v_lines.clear ();
339
335
340
336
// The rest of the algorithm uses the usual connected components.
341
337
textord_.find_components (pix_binary_, blocks, to_blocks);
@@ -355,7 +351,7 @@ ColumnFinder* Tesseract::SetupPageSegAndDetectOrientation(
355
351
textord_tabfind_aligned_gap_fraction,
356
352
&v_lines, &h_lines, vertical_x, vertical_y);
357
353
358
- finder->SetupAndFilterNoise (*photo_mask_pix, to_block);
354
+ finder->SetupAndFilterNoise (pageseg_mode, *photo_mask_pix, to_block);
359
355
360
356
if (equ_detect_) {
361
357
equ_detect_->LabelSpecialText (to_block);
@@ -367,13 +363,15 @@ ColumnFinder* Tesseract::SetupPageSegAndDetectOrientation(
367
363
// We want the text lines horizontal, (vertical text indicates vertical
368
364
// textlines) which may conflict (eg vertically written CJK).
369
365
int osd_orientation = 0 ;
370
- bool vertical_text = textord_tabfind_force_vertical_text;
371
- if (!vertical_text && textord_tabfind_vertical_text) {
366
+ bool vertical_text = textord_tabfind_force_vertical_text ||
367
+ pageseg_mode == PSM_SINGLE_BLOCK_VERT_TEXT;
368
+ if (!vertical_text && textord_tabfind_vertical_text &&
369
+ PSM_ORIENTATION_ENABLED (pageseg_mode)) {
372
370
vertical_text =
373
371
finder->IsVerticallyAlignedText (textord_tabfind_vertical_text_ratio,
374
372
to_block, &osd_blobs);
375
373
}
376
- if (osd && osd_tess != NULL && osr != NULL ) {
374
+ if (PSM_OSD_ENABLED (pageseg_mode) && osd_tess != NULL && osr != NULL ) {
377
375
GenericVector<int > osd_scripts;
378
376
if (osd_tess != this ) {
379
377
// We are running osd as part of layout analysis, so constrain the
@@ -385,7 +383,7 @@ ColumnFinder* Tesseract::SetupPageSegAndDetectOrientation(
385
383
}
386
384
}
387
385
os_detect_blobs (&osd_scripts, &osd_blobs, osr, osd_tess);
388
- if (only_osd ) {
386
+ if (pageseg_mode == PSM_OSD_ONLY ) {
389
387
delete finder;
390
388
return NULL ;
391
389
}
0 commit comments