289 {
290 photo_mask_pix |= nontext_map_;
296 denorm_, cjk_script_, &projection_, diacritic_blobs,
297 &part_grid_, &big_parts_);
300 pixa_debug, &part_grid_, &big_parts_);
303 pixa_debug, &part_grid_, &big_parts_);
304 }
308
309 ColPartition_IT p_it(&big_parts_);
310 for (p_it.mark_cycle_pt(); !p_it.cycled_list(); p_it.forward()) {
311 p_it.data()->DisownBoxesNoAssert();
312 }
313 big_parts_.clear();
314 delete stroke_width_;
315 stroke_width_ = nullptr;
316
317
318
319
320 input_block->ComputeEdgeOffsets(thresholds_pix, grey_pix);
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336 bool input_is_rtl = input_block->block->right_to_left();
337 if (input_is_rtl) {
338
340
341 ReflectForRtl(input_block, &image_bblobs_);
343 }
344
347
349 } else {
351
352
353 FindTabVectors(&horizontal_lines_, &image_bblobs_, input_block, min_gutter_width_,
354 tabfind_aligned_gap_fraction_, &part_grid_, &deskew_, &reskew_);
355
356 auto *new_denorm = new DENORM;
357 new_denorm->SetupNormalization(nullptr, &deskew_, denorm_, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
358 0.0f);
359 denorm_ = new_denorm;
360 }
363
364
365 if (!MakeColumns(false)) {
368 return 0;
369 }
370
371
372
374#ifndef GRAPHICS_DISABLED
375 if (textord_tabfind_show_reject_blobs) {
376 ScrollView *rej_win =
MakeWindow(500, 300,
"Rejected blobs");
377 input_block->plot_graded_blobs(rej_win);
378 }
379#endif
382
384
385 GridSplitPartitions();
386
387
389 GridMergePartitions();
390
391
392 InsertRemainingNoise(input_block);
393
394 GridInsertHLinePartitions();
395 GridInsertVLinePartitions();
396
398 SetPartitionTypes();
399 }
400#ifndef GRAPHICS_DISABLED
401 if (textord_tabfind_show_initial_partitions) {
402 ScrollView *part_win =
MakeWindow(100, 300,
"InitialPartitions");
405 }
406#endif
408#ifndef DISABLED_LEGACY_ENGINE
409 if (equation_detect_) {
411 }
412#endif
413 if (textord_tabfind_find_tables) {
414 TableFinder table_finder;
417 table_finder.set_left_to_right_language(!input_block->block->right_to_left());
418
419
420 table_finder.InsertCleanPartitions(&part_grid_, input_block);
421
422 table_finder.LocateTables(&part_grid_, best_columns_,
WidthCB(), reskew_);
423 }
424 GridRemoveUnderlinePartitions();
426
427
428
432 SmoothPartnerRuns();
433
434#ifndef GRAPHICS_DISABLED
435 if (textord_tabfind_show_partitions) {
436 ScrollView *window =
MakeWindow(400, 300,
"Partitions");
437 if (window != nullptr) {
441 }
442 if (window != nullptr && textord_tabfind_show_partitions > 1) {
444 }
445 }
446 }
447#endif
449 }
450
451
452
453 ReleaseBlobsAndCleanupUnused(input_block);
454
455
456
457
460 } else {
461 TransformToBlocks(blocks, to_blocks);
462 }
464 tprintf(
"Found %d blocks, %d to_blocks\n", blocks->length(), to_blocks->length());
465 }
466
467#ifndef GRAPHICS_DISABLED
468 if (textord_tabfind_show_blocks) {
469 DisplayBlocks(blocks);
470 }
471#endif
472 RotateAndReskewBlocks(input_is_rtl, to_blocks);
473 int result = 0;
474#ifndef GRAPHICS_DISABLED
475 if (blocks_win_ != nullptr) {
476 bool waiting = false;
477 do {
478 waiting = false;
480 if (event->type ==
SVET_INPUT && event->parameter !=
nullptr) {
481 if (*event->parameter == 'd') {
482 result = -1;
483 } else {
484 blocks->clear();
485 }
487 blocks_win_ = nullptr;
488 } else {
489 waiting = true;
490 }
491 } while (waiting);
492 }
493#endif
494 return result;
495}
bool PSM_COL_FIND_ENABLED(int pageseg_mode)
bool textord_debug_printable
bool PSM_SPARSE(int pageseg_mode)
void DisplayBoxes(ScrollView *window)
void AssertNoDuplicates()
ScrollView * MakeWindow(int x, int y, const char *window_name)
void ExtractPartitionsAsBlocks(BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
void SetTabStops(TabFind *tabgrid)
void RefinePartitionPartners(bool get_desperate)
void GridFindMargins(ColPartitionSet **best_columns)
void FindPartitionPartners()
void DeleteUnknownParts(TO_BLOCK *block)
void FindFigureCaptions()
void ReTypeBlobs(BLOBNBOX_LIST *im_blobs)
virtual int FindEquationParts(ColPartitionGrid *part_grid, ColPartitionSet **best_columns)=0
static void FindImagePartitions(Image image_pix, const FCOORD &rotation, const FCOORD &rerotation, TO_BLOCK *block, TabFind *tab_grid, DebugPixa *pixa_debug, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
static void TransferImagePartsToImageMask(const FCOORD &rerotation, ColPartitionGrid *part_grid, Image image_mask)
void RemoveLineResidue(ColPartition_LIST *big_part_list)
void GradeBlobsIntoPartitions(PageSegMode pageseg_mode, const FCOORD &rerotation, TO_BLOCK *block, Image nontext_pix, const DENORM *denorm, bool cjk_script, TextlineProjection *projection, BLOBNBOX_LIST *diacritic_blobs, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
void FindLeaderPartitions(TO_BLOCK *block, ColPartitionGrid *part_grid)
void InsertBlobsToGrid(bool h_spread, bool v_spread, BLOBNBOX_LIST *blobs, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid)
void DontFindTabVectors(BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, FCOORD *deskew, FCOORD *reskew)
int resolution_
Of source image in pixels per inch.
bool FindTabVectors(TabVector_LIST *hlines, BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, int min_gutter_width, double tabfind_aligned_gap_fraction, ColPartitionGrid *part_grid, FCOORD *deskew, FCOORD *reskew)
void TidyBlobs(TO_BLOCK *block)
ScrollView * FindInitialTabVectors(BLOBNBOX_LIST *image_blobs, int min_gutter_width, double tabfind_aligned_gap_fraction, TO_BLOCK *block)
ScrollView * DisplayTabVectors(ScrollView *tab_win)
std::unique_ptr< SVEvent > AwaitEvent(SVEventType type)