64 std::locale::global(std::locale(
""));
65 free_boxes_it_.set_to_list(&free_boxes_);
66 finder_ = std::make_unique<TestableTableFinder>();
69 finder_->set_global_median_xheight(5);
70 finder_->set_global_median_blob_width(5);
85 void MakePartition(
int x_min,
int y_min,
int x_max,
int y_max,
int first_column,
98 finder_->InsertTextPartition(part);
99 free_boxes_it_.add_after_then_move(part);
114 finder_->InsertLeaderPartition(part);
115 free_boxes_it_.add_after_then_move(part);
119 for (free_boxes_it_.mark_cycle_pt(); !free_boxes_it_.cycled_list(); free_boxes_it_.forward()) {
129 tesseract::ColPartition_CLIST free_boxes_;
130 tesseract::ColPartition_C_IT free_boxes_it_;
135 for (
int &
i : data) {
143 for (
int i = 0;
i < 10; ++
i) {
146 for (
int i = 10;
i < 90; ++
i) {
149 for (
int i = 90;
i < 100; ++
i) {
157 for (
int i = 0;
i < 10; ++
i) {
160 for (
int i = 10;
i < 90; ++
i) {
163 for (
int i = 90;
i < 100; ++
i) {
170 InsertLeaderPartition(90, 0, 150, 5);
171 MakePartition(0, 0, 100, 10);
172 EXPECT_TRUE(finder_->HasLeaderAdjacent(*partition_));
173 MakePartition(0, 25, 100, 40);
175 MakePartition(145, 0, 200, 20);
176 EXPECT_TRUE(finder_->HasLeaderAdjacent(*partition_));
177 MakePartition(40, 0, 50, 4);
178 EXPECT_TRUE(finder_->HasLeaderAdjacent(*partition_));
182 InsertLeaderPartition(90, 10, 150, 15);
183 MakePartition(0, 10, 85, 20);
184 EXPECT_TRUE(finder_->HasLeaderAdjacent(*partition_));
185 MakePartition(0, 25, 100, 40);
187 MakePartition(0, 0, 100, 10);
195 InsertLeaderPartition(90, 0, 150, 5, 1, 2);
196 MakePartition(0, 0, 85, 10, 0, 0);
198 MakePartition(0, 0, 100, 10, 0, 1);
199 EXPECT_TRUE(finder_->HasLeaderAdjacent(*partition_));
200 MakePartition(0, 0, 200, 10, 0, 5);
201 EXPECT_TRUE(finder_->HasLeaderAdjacent(*partition_));
202 MakePartition(155, 0, 200, 10, 5, 5);
209 finder_->set_global_median_blob_width(3);
210 finder_->set_global_median_xheight(10);
212 TBOX part_box(10, 5, 100, 15);
217 all->set_left_margin(10);
218 all->set_right_margin(100);
219 TBOX blob_box = part_box;
220 for (
int i = 10;
i <= 20;
i += 5) {
225 for (
int i = 35;
i <= 55;
i += 5) {
230 for (
int i = 80;
i <= 95;
i += 5) {
237 all->ComputeLimits();
238 InsertTextPartition(all);
241 finder_->SplitAndInsertFragmentedTextPartition(fragment_me);
242 finder_->ExpectPartition(
TBOX(11, 5, 24, 15));
243 finder_->ExpectPartition(
TBOX(36, 5, 59, 15));
244 finder_->ExpectPartition(
TBOX(81, 5, 99, 15));
245 finder_->ExpectPartitionCount(3);
249 finder_->set_global_median_blob_width(3);
250 finder_->set_global_median_xheight(10);
252 TBOX part_box(10, 5, 100, 15);
257 all->set_left_margin(10);
258 all->set_right_margin(100);
259 TBOX blob_box = part_box;
260 for (
int i = 10;
i <= 95;
i += 5) {
267 all->ComputeLimits();
268 InsertTextPartition(all);
271 finder_->SplitAndInsertFragmentedTextPartition(fragment_me);
272 finder_->ExpectPartition(
TBOX(11, 5, 99, 15));
273 finder_->ExpectPartitionCount(1);
#define EXPECT_EQ(val1, val2)
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
TEST_F(EuroText, FastLatinOCR)
void set_to_given_coords(int x_min, int y_min, int x_max, int y_max)
TDimension bottom() const
static C_BLOB * FakeBlob(const TBOX &box)
void SetUniqueMode(bool mode)
static ColPartition * FakePartition(const TBOX &box, PolyBlockType block_type, BlobRegionType blob_type, BlobTextFlowType flow)
ColPartition * CopyButDontOwnBlobs()
const TBOX & bounding_box() const
void set_last_column(int column)
void set_first_column(int column)
void SplitAndInsertFragmentedTextPartition(ColPartition *part)
bool HasLeaderAdjacent(const ColPartition &part)
void set_global_median_blob_width(int width)
void InsertLeaderPartition(ColPartition *part)
bool GapInXProjection(int *xprojection, int length)
void set_global_median_xheight(int xheight)
void set_global_median_ledding(int ledding)
ColPartitionGrid fragmented_text_grid_
void InsertTextPartition(ColPartition *part)
void ExpectPartitionCount(int expected_count)
void ExpectPartition(const TBOX &box)
void InsertLeaderPartition(int x_min, int y_min, int x_max, int y_max)
void MakePartition(int x_min, int y_min, int x_max, int y_max, int first_column, int last_column)
void InsertLeaderPartition(int x_min, int y_min, int x_max, int y_max, int first_column, int last_column)
std::unique_ptr< ColPartition > partition_
void DeletePartitionListBoxes()
void InsertTextPartition(ColPartition *part)
std::unique_ptr< TestableTableFinder > finder_
void MakePartition(int x_min, int y_min, int x_max, int y_max)