Skip to content

Commit 4b821b2

Browse files
committed
Fix and enable layout_test
Signed-off-by: Stefan Weil <[email protected]>
1 parent 0d6d810 commit 4b821b2

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

unittest/Makefile.am

+4-3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ check_PROGRAMS = \
115115
intfeaturemap_test \
116116
intsimdmatrix_test \
117117
lang_model_test \
118+
layout_test \
118119
linlsq_test \
119120
loadlang_test \
120121
mastertrainer_test \
@@ -168,12 +169,12 @@ colpartition_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
168169
commandlineflags_test_SOURCES = commandlineflags_test.cc
169170
commandlineflags_test_LDADD = $(GTEST_LIBS) $(TRAINING_LIBS) $(TESS_LIBS) $(ICU_UC_LIBS)
170171

171-
denorm_test_SOURCES = denorm_test.cc
172-
denorm_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
173-
174172
dawg_test_SOURCES = dawg_test.cc
175173
dawg_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
176174

175+
denorm_test_SOURCES = denorm_test.cc
176+
denorm_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
177+
177178
fileio_test_SOURCES = fileio_test.cc
178179
fileio_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)
179180

unittest/layout_test.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "coutln.h"
1010
#include "log.h" // for LOG
1111
#include "mutableiterator.h"
12+
#include "ocrblock.h" // for class BLOCK
1213
#include "pageres.h"
1314
#include "polyblk.h"
1415
#include "resultiterator.h"
@@ -61,16 +62,15 @@ class LayoutTest : public testing::Test {
6162
char* block_text = it->GetUTF8Text(tesseract::RIL_BLOCK);
6263
if (block_text != nullptr && it->BlockType() == blocks[string_index] &&
6364
strstr(block_text, strings[string_index]) != nullptr) {
64-
LOG(INFO) << "Found string %s in block %d of type %s" <<
65-
strings[string_index], block_index,
66-
kPolyBlockNames[blocks[string_index]];
65+
LOG(INFO) << "Found string " << strings[string_index]
66+
<< " in block " << block_index
67+
<< " of type " << kPolyBlockNames[blocks[string_index]];
6768
// Found this one.
6869
++string_index;
6970
} else if (it->BlockType() == blocks[string_index] &&
7071
block_text == nullptr && strings[string_index][0] == '\0') {
71-
LOG(INFO) << "Found block of type %s at block %d" <<
72-
kPolyBlockNames[blocks[string_index]],
73-
block_index;
72+
LOG(INFO) << "Found block of type " << kPolyBlockNames[blocks[string_index]]
73+
<< " at block " << block_index;
7474
// Found this one.
7575
++string_index;
7676
} else {
@@ -90,7 +90,6 @@ class LayoutTest : public testing::Test {
9090
// be to the left of it if right_to_left is true, or to the right otherwise.
9191
void VerifyRoughBlockOrder(bool right_to_left, ResultIterator* it) {
9292
int prev_left = 0;
93-
int prev_top = 0;
9493
int prev_right = 0;
9594
int prev_bottom = 0;
9695
it->Begin();
@@ -111,7 +110,6 @@ class LayoutTest : public testing::Test {
111110
}
112111
}
113112
prev_left = left;
114-
prev_top = top;
115113
prev_right = right;
116114
prev_bottom = bottom;
117115
}
@@ -129,7 +127,7 @@ class LayoutTest : public testing::Test {
129127
PTIsTextType(it->BlockType()) && right - left > 800 &&
130128
bottom - top > 200) {
131129
const PAGE_RES_IT* pr_it = it->PageResIt();
132-
POLY_BLOCK* pb = pr_it->block()->block->poly_block();
130+
POLY_BLOCK* pb = pr_it->block()->block->pdblk.poly_block();
133131
CHECK(pb != nullptr);
134132
FCOORD skew = pr_it->block()->block->skew();
135133
EXPECT_GT(skew.x(), 0.0f);
@@ -165,6 +163,7 @@ class LayoutTest : public testing::Test {
165163

166164
// Tests that Tesseract gets the important blocks and in the right order
167165
// on a UNLV page numbered 8087_054.3B.tif. (Dubrovnik)
166+
#if 0 // TODO: Get missing image needed for this test.
168167
TEST_F(LayoutTest, UNLV8087_054) {
169168
SetImage("8087_054.3B.tif", "eng");
170169
// Just run recognition.
@@ -174,6 +173,7 @@ TEST_F(LayoutTest, UNLV8087_054) {
174173
VerifyBlockTextOrder(kStrings8087_054, kBlocks8087_054, it);
175174
delete it;
176175
}
176+
#endif
177177

178178
// Tests that Tesseract gets the important blocks and in the right order
179179
// on GOOGLE:13510798882202548:74:84.sj-79.tif (Hebrew image)

0 commit comments

Comments
 (0)