21 #include "config_auto.h" 130 bool any_done =
false;
132 bool merge_done =
false;
142 if (!box_cb->
Run(part, &box))
145 ColPartition_CLIST merge_candidates;
146 FindMergeCandidates(part, box, debug, &merge_candidates);
148 int overlap_increase;
152 if (neighbour !=
nullptr && overlap_increase <= 0) {
154 tprintf(
"Merging:hoverlap=%d, voverlap=%d, OLI=%d\n",
163 part->
Absorb(neighbour,
nullptr);
167 }
else if (neighbour !=
nullptr) {
169 tprintf(
"Overlapped when merged with increase %d: ", overlap_increase);
173 tprintf(
"No candidate neighbour returned\n");
175 }
while (merge_done);
188 if (candidate == part)
195 tprintf(
"Examining merge candidate:");
201 if (h_dist >= std::max(part_box.
width(), c_box.
width()) / 2) {
203 tprintf(
"Too far away: h_dist = %d\n", h_dist);
209 if (v_dist >= std::max(part_box.
height(), c_box.
height()) / 2) {
211 tprintf(
"Too far away: v_dist = %d\n", v_dist);
220 tprintf(
"Candidate fails overlap and diacritic tests!\n");
232 static int IncreaseInOverlap(
const ColPartition* merge1,
233 const ColPartition* merge2,
235 ColPartition_CLIST* parts) {
236 ASSERT_HOST(merge1 !=
nullptr && merge2 !=
nullptr);
238 ColPartition_C_IT it(parts);
239 TBOX merged_box(merge1->bounding_box());
240 merged_box += merge2->bounding_box();
241 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
242 ColPartition* part = it.data();
243 if (part == merge1 || part == merge2)
245 TBOX part_box = part->bounding_box();
248 if (overlap_area > 0 && !part->OKMergeOverlap(*merge1, *merge2,
249 ok_overlap,
false)) {
250 total_area += overlap_area;
252 overlap_area = part_box.
intersection(merge1->bounding_box()).area();
253 if (overlap_area > 0)
254 total_area -= overlap_area;
256 overlap_area = intersection_box.
area();
257 if (overlap_area > 0) {
258 total_area -= overlap_area;
260 intersection_box &= merge1->bounding_box();
261 overlap_area = intersection_box.
area();
262 if (overlap_area > 0)
263 total_area += overlap_area;
291 static bool TestCompatibleCandidates(
const ColPartition& part,
bool debug,
292 ColPartition_CLIST* candidates) {
293 ColPartition_C_IT it(candidates);
294 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
295 ColPartition* candidate = it.data();
296 if (!candidate->OKDiacriticMerge(part,
false)) {
297 ColPartition_C_IT it2(it);
298 for (it2.mark_cycle_pt(); !it2.cycled_list(); it2.forward()) {
299 ColPartition* candidate2 = it2.data();
300 if (candidate2 != candidate &&
301 !OKMergeCandidate(candidate, candidate2,
false)) {
303 tprintf(
"NC overlap failed:Candidate:");
304 candidate2->bounding_box().print();
305 tprintf(
"fails to be a good merge with:");
306 candidate->bounding_box().print();
320 int total_overlap = 0;
326 ColPartition_CLIST neighbors;
329 ColPartition_C_IT n_it(&neighbors);
330 bool any_part_overlap =
false;
331 for (n_it.mark_cycle_pt(); !n_it.cycled_list(); n_it.forward()) {
332 const TBOX& n_box = n_it.data()->bounding_box();
334 if (overlap > 0 && overlap_grid !=
nullptr) {
335 if (*overlap_grid ==
nullptr) {
338 (*overlap_grid)->InsertBBox(
true,
true, n_it.data()->ShallowCopy());
339 if (!any_part_overlap) {
340 (*overlap_grid)->InsertBBox(
true,
true, part->
ShallowCopy());
343 any_part_overlap =
true;
344 total_overlap += overlap;
347 return total_overlap;
355 ColPartition_CLIST* parts) {
360 if (part != not_this)
361 parts->add_sorted(SortByBoxLeft<ColPartition>,
true, part);
407 const ColPartition* part, ColPartition_CLIST* candidates,
bool debug,
409 int* overlap_increase) {
410 if (overlap_increase !=
nullptr)
411 *overlap_increase = 0;
412 if (candidates->empty())
421 ColPartition_C_IT it(candidates);
424 TBOX full_box(part_box);
425 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
430 ColPartition_CLIST neighbours;
435 tprintf(
"Finding best merge candidate from %d, %d neighbours for box:",
436 candidates->length(), neighbours.length());
444 ColPartition_CLIST non_candidate_neighbours;
445 non_candidate_neighbours.set_subtract(SortByBoxLeft<ColPartition>,
true,
446 &neighbours, candidates);
447 int worst_nc_increase = 0;
448 int best_increase = INT32_MAX;
450 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
452 if (confirm_cb !=
nullptr && !confirm_cb->
Run(part, candidate)) {
454 tprintf(
"Candidate not confirmed:");
459 int increase = IncreaseInOverlap(part, candidate, ok_overlap, &neighbours);
461 if (best_candidate ==
nullptr || increase < best_increase) {
462 best_candidate = candidate;
463 best_increase = increase;
466 tprintf(
"New best merge candidate has increase %d, area %d, over box:",
467 increase, best_area);
471 }
else if (increase == best_increase) {
473 if (area < best_area) {
475 best_candidate = candidate;
478 increase = IncreaseInOverlap(part, candidate, ok_overlap,
479 &non_candidate_neighbours);
480 if (increase > worst_nc_increase)
481 worst_nc_increase = increase;
483 if (best_increase > 0) {
490 if (worst_nc_increase < best_increase &&
491 TestCompatibleCandidates(*part, debug, candidates)) {
492 best_increase = worst_nc_increase;
495 if (overlap_increase !=
nullptr)
496 *overlap_increase = best_increase;
497 return best_candidate;
503 ColPartition_LIST* part_list) {
516 ColPartition_LIST* big_parts) {
529 int unresolved_overlaps = 0;
533 if (neighbour == part)
547 if (!shrunken.
overlap(neighbour_box) &&
552 RemoveBadBox(excluded, part, big_parts);
557 }
else if (box.
contains(neighbour_box)) {
558 ++unresolved_overlaps;
569 RemoveBadBox(excluded, neighbour, big_parts);
578 if (neighbour_overlap_count <= part_overlap_count ||
582 if (split_blob !=
nullptr) {
591 if (split_blob !=
nullptr) {
598 if (right_part !=
nullptr) {
605 if (unresolved_overlaps > 2 && part->
IsSingleton()) {
608 ColPartition_IT big_it(big_parts);
610 big_it.add_to_end(part);
633 bool any_changed =
false;
639 if (SmoothRegionType(nontext_map, im_box, rotation, debug, part))
648 ColPartition_LIST parts;
649 ColPartition_IT part_it(&parts);
655 part_it.add_after_then_move(part);
662 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
663 part = part_it.extract();
676 TO_BLOCK_LIST* to_blocks) {
677 TO_BLOCK_IT to_block_it(to_blocks);
678 BLOCK_IT block_it(blocks);
680 ColPartition_LIST parts;
681 ColPartition_IT part_it(&parts);
687 part_it.add_after_then_move(part);
700 if (row ==
nullptr) {
709 TO_ROW_IT row_it(to_block->
get_rows());
710 row_it.add_after_then_move(row);
714 to_block->
line_size =
static_cast<float>(median_width);
718 to_block->
line_size =
static_cast<float>(median_height);
723 block_it.add_to_end(block);
724 to_block_it.add_to_end(to_block);
737 ColPartition_LIST parts;
738 ColPartition_IT part_it(&parts);
744 part_it.add_after_then_move(part);
752 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
753 part = part_it.extract();
769 if (left_line !=
nullptr && !left_line->
IsLeftTab())
771 if (left_line !=
nullptr && left_line->
IsLeftTab())
774 if (right_line !=
nullptr && !right_line->
IsRightTab())
776 if (right_line !=
nullptr && right_line->
IsRightTab())
785 ColPartition_LIST* part_lists =
new ColPartition_LIST[
gridheight()];
792 bool any_parts_found =
false;
800 ColPartition_IT part_it(&part_lists[grid_y]);
801 part_it.add_to_end(part);
802 any_parts_found =
true;
805 if (any_parts_found) {
806 for (
int grid_y = 0; grid_y <
gridheight(); ++grid_y) {
808 if (!part_lists[grid_y].empty()) {
814 delete [] part_lists;
815 return any_parts_found;
839 if (single_column_part ==
nullptr) {
843 single_column_part->
CopyLeftTab(*single_column_part,
false);
844 single_column_part->
CopyRightTab(*single_column_part,
false);
854 if (single_column_part !=
nullptr) {
878 BLOBNBOX_IT im_blob_it(im_blobs);
879 ColPartition_LIST dead_parts;
880 ColPartition_IT dead_part_it(&dead_parts);
888 bool any_blobs_moved =
false;
890 BLOBNBOX_C_IT blob_it(part->
boxes());
891 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
893 im_blob_it.add_after_then_move(blob);
897 BLOBNBOX_C_IT blob_it(part->
boxes());
898 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
906 any_blobs_moved =
true;
915 BLOBNBOX_C_IT blob_it(part->
boxes());
917 dead_part_it.add_to_end(part);
919 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
923 delete blob->
cblob();
927 }
else if (any_blobs_moved) {
942 ColPartition_LIST saved_parts;
943 ColPartition_IT part_it(&saved_parts);
949 part_it.add_to_end(part);
954 for (part_it.move_to_first(); !part_it.empty(); part_it.forward()) {
955 part = part_it.extract();
975 ? best_columns[gsearch.
GridY()]
977 FindPartitionMargins(columns, part);
980 tprintf(
"Computed margins for part:");
992 ColPartition_LIST* parts) {
993 ColPartition_IT part_it(parts);
994 for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
997 if (best_columns !=
nullptr) {
1002 columns = best_columns[grid_y];
1004 FindPartitionMargins(columns, part);
1010 ColPartition_LIST dead_parts;
1011 ColPartition_IT dead_it(&dead_parts);
1017 dead_it.add_to_end(part);
1076 for (
int upper = 0; upper < 2; ++upper) {
1080 for (partner_it.mark_cycle_pt(); !partner_it.cycled_list();
1081 partner_it.forward()) {
1087 if (!partner_it.cycled_list())
continue;
1089 for (partner_it.mark_cycle_pt(); !partner_it.cycled_list();
1090 partner_it.forward()) {
1095 tprintf(
"Finding figure captions for image part:");
1097 tprintf(
"Considering partner:");
1098 partner_box.
print();
1100 if (partner_box.
left() >= part_box.
left() &&
1102 int dist = partner_box.
y_gap(part_box);
1103 if (best_caption ==
nullptr || dist < best_dist) {
1105 best_caption = partner;
1111 if (best_caption !=
nullptr) {
1113 tprintf(
"Best caption candidate:");
1114 best_caption->bounding_box().print();
1120 int biggest_gap = 0;
1121 int smallest_gap = INT16_MAX;
1122 int total_height = 0;
1123 int mean_height = 0;
1126 for (
ColPartition* partner = best_caption; partner !=
nullptr &&
1128 partner = next_partner) {
1129 if (!partner->IsTextType()) {
1130 end_partner = partner;
1136 if (next_partner !=
nullptr) {
1139 if (gap > biggest_gap) {
1141 end_partner = next_partner;
1142 mean_height = total_height / line_count;
1143 }
else if (gap < smallest_gap) {
1154 tprintf(
"Line count=%d, biggest gap %d, smallest%d, mean height %d\n",
1155 line_count, biggest_gap, smallest_gap, mean_height);
1156 if (end_partner !=
nullptr) {
1162 end_partner =
nullptr;
1165 for (
ColPartition* partner = best_caption; partner !=
nullptr &&
1166 partner != end_partner;
1167 partner = next_partner) {
1169 partner->SetBlobTypes();
1171 tprintf(
"Set caption type for partition:");
1172 partner->bounding_box().print();
1209 int height = top - bottom;
1210 int mid_y = (bottom + top) / 2;
1216 int best_dist = INT32_MAX;
1218 if (neighbour == part || neighbour->
type() ==
PT_NOISE)
1222 int neighbour_y = (neighbour_bottom + neighbour_top) / 2;
1223 if (upper != (neighbour_y > mid_y))
1228 if (best_neighbour ==
nullptr)
1229 best_neighbour = neighbour;
1232 int dist = upper ? neighbour_bottom - top : bottom - neighbour_top;
1234 if (dist < best_dist) {
1236 best_neighbour = neighbour;
1242 if (best_neighbour !=
nullptr)
1255 int width = right >= left ? right - left : -1;
1256 int mid_x = (left + right) / 2;
1262 int best_dist = INT32_MAX;
1263 while ((neighbour = hsearch.
NextSideSearch(to_the_left)) !=
nullptr) {
1264 if (neighbour == part || neighbour->
type() ==
PT_NOISE)
1268 int neighbour_x = (neighbour_left + neighbour_right) / 2;
1269 if (to_the_left != (neighbour_x < mid_x))
1275 int dist = to_the_left ? left - neighbour_right : neighbour_left - right;
1277 if (dist < best_dist || best_neighbour ==
nullptr) {
1279 best_neighbour = neighbour;
1287 if (best_neighbour !=
nullptr)
1288 part->
AddPartner(to_the_left, best_neighbour);
1304 get_desperate,
this);
1317 void ColPartitionGrid::FindMergeCandidates(
const ColPartition* part,
1318 const TBOX& search_box,
bool debug,
1319 ColPartition_CLIST* candidates) {
1325 rsearch.SetUniqueMode(
true);
1326 rsearch.StartRectSearch(search_box);
1328 while ((candidate = rsearch.NextRectSearch()) !=
nullptr) {
1329 if (!OKMergeCandidate(part, candidate, debug))
1346 TBOX merged_box(part_box);
1347 merged_box += c_box;
1349 msearch.SetUniqueMode(
true);
1350 msearch.StartRectSearch(merged_box);
1352 while ((neighbour = msearch.NextRectSearch()) !=
nullptr) {
1353 if (neighbour == part || neighbour == candidate)
1355 if (neighbour->
OKMergeOverlap(*part, *candidate, ok_overlap,
false))
1362 !OKMergeCandidate(part, neighbour,
false) &&
1363 !OKMergeCandidate(candidate, neighbour,
false))
1366 if (neighbour !=
nullptr) {
1368 tprintf(
"Combined box overlaps another that is not OK despite" 1369 " allowance of %d:", ok_overlap);
1372 OKMergeCandidate(part, neighbour,
true);
1374 OKMergeCandidate(candidate, neighbour,
true);
1386 candidates->add_sorted(SortByBoxLeft<ColPartition>,
true, candidate);
1401 bool ColPartitionGrid::SmoothRegionType(Pix* nontext_map,
1403 const FCOORD& rerotation,
1405 ColPartition* part) {
1406 const TBOX& part_box = part->bounding_box();
1408 tprintf(
"Smooothing part at:");
1412 int best_dist = INT32_MAX;
1413 int max_dist = std::min(part_box.
width(), part_box.
height());
1416 bool any_image =
false;
1417 bool all_image =
true;
1421 BlobRegionType type = SmoothInOneDirection(dir, nontext_map, im_box,
1422 rerotation, debug, *part,
1425 tprintf(
"Result in dir %d = %d at dist %d\n", dir, type, dist);
1436 if (best_dist > max_dist)
1443 if (best_type ==
BRT_TEXT && !any_image) {
1453 if (new_type != part->blob_type() || new_flow != part->flow()) {
1454 part->set_flow(new_flow);
1455 part->set_blob_type(new_type);
1456 part->SetBlobTypes();
1471 const TBOX& part_box,
1475 *search_box = part_box;
1478 int padding = std::min(part_box.
height(), part_box.
width());
1479 padding = std::max(padding, min_padding);
1481 search_box->
pad(padding, padding);
1487 *dist_scaling =
ICOORD(2, 1);
1491 *dist_scaling =
ICOORD(1, 2);
1495 *dist_scaling =
ICOORD(2, 1);
1499 *dist_scaling =
ICOORD(1, 2);
1527 const TBOX& im_box,
const FCOORD& rerotation,
1528 bool debug,
const ColPartition& part,
int* best_distance) {
1530 const TBOX& part_box = part.bounding_box();
1534 &search_box, &dist_scaling);
1539 AccumulatePartDistances(part, dist_scaling, search_box,
1540 nontext_map, im_box, rerotation, debug, dists);
1545 memset(counts, 0,
sizeof(counts[0]) *
NPT_COUNT);
1553 min_dist = INT32_MAX;
1555 if (counts[i] < dists[i].size() && dists[i][counts[i]] < min_dist)
1556 min_dist = dists[i][counts[i]];
1560 while (counts[i] < dists[i].size() && dists[i][counts[i]] <= min_dist)
1563 *best_distance = min_dist;
1565 tprintf(
"Totals: htext=%d+%d, vtext=%d+%d, image=%d+%d, at dist=%d\n",
1568 counts[
NPT_IMAGE], image_bias, min_dist);
1576 if (image_count > 0 &&
1597 }
while (min_dist < INT32_MAX);
1608 void ColPartitionGrid::AccumulatePartDistances(
const ColPartition& base_part,
1609 const ICOORD& dist_scaling,
1610 const TBOX& search_box,
1613 const FCOORD& rerotation,
1616 const TBOX& part_box = base_part.bounding_box();
1618 rsearch.SetUniqueMode(
true);
1619 rsearch.StartRectSearch(search_box);
1620 ColPartition* neighbour;
1623 while ((neighbour = rsearch.NextRectSearch()) !=
nullptr) {
1624 if (neighbour->IsUnMergeableType() ||
1625 !base_part.ConfirmNoTabViolation(*neighbour) ||
1626 neighbour == &base_part)
1628 TBOX nbox = neighbour->bounding_box();
1636 int x_gap = std::max(part_box.
x_gap(nbox), 0);
1637 int y_gap = std::max(part_box.
y_gap(nbox), 0);
1638 int n_dist = x_gap * dist_scaling.
x() + y_gap* dist_scaling.
y();
1640 tprintf(
"Part has x-gap=%d, y=%d, dist=%d at:",
1641 x_gap, y_gap, n_dist);
1663 if (debug)
tprintf(
"Weak %d\n", n_boxes);
1666 if (debug)
tprintf(
"Image %d\n", n_boxes);
1668 if (count_vector !=
nullptr) {
1669 for (
int i = 0; i < n_boxes; ++i)
1684 void ColPartitionGrid::FindPartitionMargins(ColPartitionSet* columns,
1685 ColPartition* part) {
1688 int y = part->MidY();
1690 int left_margin =
bleft().
x();
1691 int right_margin =
tright().
x();
1692 if (columns !=
nullptr) {
1693 ColPartition* column = columns->ColumnContaining(box.
left(), y);
1694 if (column !=
nullptr)
1695 left_margin = column->LeftAtY(y);
1696 column = columns->ColumnContaining(box.
right(), y);
1697 if (column !=
nullptr)
1698 right_margin = column->RightAtY(y);
1703 left_margin = FindMargin(box.
left() + box.
height(),
true, left_margin,
1705 part->set_left_margin(left_margin);
1707 right_margin = FindMargin(box.
right() - box.
height(),
false, right_margin,
1709 part->set_right_margin(right_margin);
1715 int ColPartitionGrid::FindMargin(
int x,
bool right_to_left,
int x_limit,
1716 int y_bottom,
int y_top,
1717 const ColPartition* not_this) {
1718 int height = y_top - y_bottom;
1721 side_search.SetUniqueMode(
true);
1722 side_search.StartSideSearch(x, y_bottom, y_top);
1724 while ((part = side_search.NextSideSearch(right_to_left)) !=
nullptr) {
1726 if (part == not_this)
1730 TBOX box = part->bounding_box();
1731 int min_overlap = std::min(height, static_cast<int>(box.
height()));
1733 int y_overlap = std::min(y_top, static_cast<int>(box.
top())) - std::max(y_bottom, static_cast<int>(box.
bottom()));
1734 if (y_overlap < min_overlap)
1737 int x_edge = right_to_left ? box.
right() : box.
left();
1738 if ((x_edge < x) != right_to_left)
1741 if ((x_edge < x_limit) == right_to_left)
void ReTypeBlobs(BLOBNBOX_LIST *im_blobs)
void CopyRightTab(const ColPartition &src, bool take_box)
bool textord_tabfind_show_color_fit
void RepositionIterator()
const ICOORD & topright() const
void ListFindMargins(ColPartitionSet **best_columns, ColPartition_LIST *parts)
const double kMinCaptionGapRatio
void set_poly_block(POLY_BLOCK *blk)
set the poly block
const int kMaxNeighbourDistFactor
bool TypesMatch(const ColPartition &other) const
void DeleteUnknownParts(TO_BLOCK *block)
void GridFindMargins(ColPartitionSet **best_columns)
void RemoveBox(BLOBNBOX *box)
void SetRightTab(const TabVector *tab_vector)
void FindPartitionPartners()
#define BOOL_VAR(name, val, comment)
static int CountPixelsInRotatedBox(TBOX box, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
const int kSmoothDecisionMargin
const double kMaxPartitionSpacing
void set_vertical(const ICOORD &v)
void StartSideSearch(int x, int ymin, int ymax)
TBOX intersection(const TBOX &box) const
void Merges(TessResultCallback2< bool, ColPartition *, TBOX *> *box_cb, TessResultCallback2< bool, const ColPartition *, const ColPartition *> *confirm_cb)
int y_gap(const TBOX &box) const
const double kBigPartSizeRatio
BlobRegionType blob_type() const
const ICOORD & bleft() const
int16_t y() const
access_function
BlobTextFlowType flow() const
int median_height() const
ColPartition * SingletonPartner(bool upper)
static bool WithinTestRegion(int detail_level, int x, int y)
int x_gap(const TBOX &box) const
int direction(EDGEPT *point)
const double kMarginOverlapFraction
void HandleClick(int x, int y)
void SplitOverlappingPartitions(ColPartition_LIST *big_parts)
int HCoreOverlap(const ColPartition &other) const
TabVector * RightTabForBox(const TBOX &box, bool crossing, bool extended)
void SetTabStops(TabFind *tabgrid)
bool MergePart(TessResultCallback2< bool, ColPartition *, TBOX *> *box_cb, TessResultCallback2< bool, const ColPartition *, const ColPartition *> *confirm_cb, ColPartition *part)
void Absorb(ColPartition *other, WidthCallback *cb)
bool OKDiacriticMerge(const ColPartition &candidate, bool debug) const
bool HOverlaps(const ColPartition &other) const
TabVector * LeftTabForBox(const TBOX &box, bool crossing, bool extended)
ColPartition_CLIST * lower_partners()
void StartRectSearch(const TBOX &rect)
const int kColumnWidthFactor
void FindFigureCaptions()
void CopyLeftTab(const ColPartition &src, bool take_box)
bool WithinSameMargins(const ColPartition &other) const
void set_blob_type(BlobRegionType t)
void set_flow(BlobTextFlowType f)
bool GridSmoothNeighbours(BlobTextFlowType source_type, Pix *nontext_map, const TBOX &im_box, const FCOORD &rerotation)
void RefinePartners(PolyBlockType type, bool get_desperate, ColPartitionGrid *grid)
static ColPartition * MakeBigPartition(BLOBNBOX *box, ColPartition_LIST *big_part_list)
GridSearch< ColPartition, ColPartition_CLIST, ColPartition_C_IT > ColPartitionGridSearch
void StartRadSearch(int x, int y, int max_radius)
void set_region_type(BlobRegionType new_type)
BBC * NextSideSearch(bool right_to_left)
int median_bottom() const
const double kTinyEnoughTextlineOverlapFraction
void set_owner(tesseract::ColPartition *new_owner)
ColPartition * SplitAtBlob(BLOBNBOX *split_blob)
int16_t x() const
access function
void RemoveBBox(ColPartition *bbox)
bool MakeColPartSets(PartSetVector *part_sets)
BlobRegionType region_type() const
const double kMinCaptionGapHeightRatio
void FindVPartitionPartners(bool to_the_left, ColPartition *part)
const int kMaxCaptionLines
void InsertBBox(bool h_spread, bool v_spread, ColPartition *bbox)
ColPartition_CLIST * upper_partners()
void rotate_large(const FCOORD &vec)
WidthCallback * WidthCB()
ColPartitionGrid()=default
void StartVerticalSearch(int xmin, int xmax, int y)
DLLSYM void tprintf(const char *format,...)
void GridCoords(int x, int y, int *grid_x, int *grid_y) const
void AddPartner(bool upper, ColPartition *partner)
void DeleteUnownedNoise()
bool IsUnMergeableType() const
ColPartition * BestMergeCandidate(const ColPartition *part, ColPartition_CLIST *candidates, bool debug, TessResultCallback2< bool, const ColPartition *, const ColPartition *> *confirm_cb, int *overlap_increase)
void FindOverlappingPartitions(const TBOX &box, const ColPartition *not_this, ColPartition_CLIST *parts)
const ICOORD & botleft() const
bool ReleaseNonLeaderBoxes()
BlobTextFlowType flow() const
void set_flow(BlobTextFlowType value)
const TBOX & bounding_box() const
bool VSignificantCoreOverlap(const ColPartition &other) const
int CountOverlappingBoxes(const TBOX &box)
bool overlap(const TBOX &box) const
int VCoreOverlap(const ColPartition &other) const
BLOBNBOX * OverlapSplitBlob(const TBOX &box)
bool contains(const FCOORD pt) const
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
void RefinePartitionPartners(bool get_desperate)
int ComputeTotalOverlap(ColPartitionGrid **overlap_grid)
const TBOX & bounding_box() const
ColPartitionSet * MakeSingleColumnSet(WidthCallback *cb)
bool IsVerticalType() const
static bool BlankImageInBetween(const TBOX &box1, const TBOX &box2, const TBOX &im_box, const FCOORD &rotation, Pix *pix)
bool OKMergeOverlap(const ColPartition &merge1, const ColPartition &merge2, int ok_box_overlap, bool debug)
void Deskew(const FCOORD &deskew)
TBOX bounding_union(const TBOX &box) const
void ExtractPartitionsAsBlocks(BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
BBC * NextVerticalSearch(bool top_to_bottom)
TBOX BoundsWithoutBox(BLOBNBOX *box)
void SetLeftTab(const TabVector *tab_vector)
void SetUniqueMode(bool mode)
void SetColumnGoodness(WidthCallback *cb)
ColPartition * ShallowCopy() const
bool VOverlaps(const ColPartition &other) const
void set_type(PolyBlockType t)
void pad(int xpad, int ypad)
const ICOORD & tright() const
void DeleteNonLeaderParts()
static bool IsTextType(BlobRegionType type)
void RecomputeBounds(int gridsize, const ICOORD &bleft, const ICOORD &tright, const ICOORD &vertical)
void set_block_owned(bool owned)
PolyBlockType type() const
static bool IsLineType(BlobRegionType type)