1
1
2
2
#include < string>
3
3
#include < utility>
4
- #include " leptonica/include/allheaders.h"
5
- #include " tesseract/api/baseapi.h"
6
- #include " tesseract/ccmain/mutableiterator.h"
7
- #include " tesseract/ccmain/resultiterator.h"
8
- #include " tesseract/ccstruct/coutln.h"
9
- #include " tesseract/ccstruct/pageres.h"
10
- #include " tesseract/ccstruct/polyblk.h"
11
- #include " tesseract/ccstruct/stepblob.h"
4
+
5
+ #include " include_gunit.h"
6
+
7
+ #include " allheaders.h"
8
+ #include " baseapi.h"
9
+ #include " coutln.h"
10
+ #include " log.h" // for LOG
11
+ #include " mutableiterator.h"
12
+ #include " pageres.h"
13
+ #include " polyblk.h"
14
+ #include " resultiterator.h"
15
+ #include " stepblob.h"
12
16
13
17
namespace {
14
18
@@ -25,11 +29,11 @@ const PolyBlockType kBlocks8087_054[] = {PT_HEADING_TEXT, PT_FLOWING_TEXT,
25
29
// The fixture for testing Tesseract.
26
30
class LayoutTest : public testing ::Test {
27
31
protected:
28
- string TestDataNameToPath (const string& name) {
29
- return file::JoinPath (FLAGS_test_srcdir , " testdata /" + name);
32
+ std:: string TestDataNameToPath (const std:: string& name) {
33
+ return file::JoinPath (TESTING_DIR , " /" + name);
30
34
}
31
- string TessdataPath () {
32
- return file::JoinPath (FLAGS_test_srcdir , " tessdata " );
35
+ std:: string TessdataPath () {
36
+ return file::JoinPath (TESSDATA_DIR , " " );
33
37
}
34
38
35
39
LayoutTest () { src_pix_ = nullptr ; }
@@ -57,21 +61,20 @@ class LayoutTest : public testing::Test {
57
61
char * block_text = it->GetUTF8Text (tesseract::RIL_BLOCK);
58
62
if (block_text != nullptr && it->BlockType () == blocks[string_index] &&
59
63
strstr (block_text, strings[string_index]) != nullptr ) {
60
- VLOG ( 1 ) << StringPrintf ( " Found string %s in block %d of type %s" ,
64
+ LOG (INFO ) << " Found string %s in block %d of type %s" <<
61
65
strings[string_index], block_index,
62
- kPolyBlockNames [blocks[string_index]]) ;
66
+ kPolyBlockNames [blocks[string_index]];
63
67
// Found this one.
64
68
++string_index;
65
69
} else if (it->BlockType () == blocks[string_index] &&
66
70
block_text == nullptr && strings[string_index][0 ] == ' \0 ' ) {
67
- VLOG ( 1 ) << StringPrintf ( " Found block of type %s at block %d" ,
71
+ LOG (INFO ) << " Found block of type %s at block %d" <<
68
72
kPolyBlockNames [blocks[string_index]],
69
- block_index) ;
73
+ block_index;
70
74
// Found this one.
71
75
++string_index;
72
76
} else {
73
- VLOG (1 ) << StringPrintf (" No match found in block with text:\n %s" ,
74
- block_text);
77
+ LOG (INFO) << " No match found in block with text:\n %s" << block_text;
75
78
}
76
79
delete[] block_text;
77
80
++block_index;
@@ -97,7 +100,7 @@ class LayoutTest : public testing::Test {
97
100
PTIsTextType (it->BlockType ()) && right - left > 800 &&
98
101
bottom - top > 200 ) {
99
102
if (prev_right > prev_left) {
100
- if (min (right, prev_right) > max (left, prev_left)) {
103
+ if (std:: min (right, prev_right) > std:: max (left, prev_left)) {
101
104
EXPECT_GE (top, prev_bottom) << " Overlapping block should be below" ;
102
105
} else if (top < prev_bottom) {
103
106
if (right_to_left) {
@@ -156,7 +159,7 @@ class LayoutTest : public testing::Test {
156
159
}
157
160
158
161
Pix* src_pix_;
159
- string ocr_text_;
162
+ std:: string ocr_text_;
160
163
tesseract::TessBaseAPI api_;
161
164
};
162
165
@@ -173,9 +176,10 @@ TEST_F(LayoutTest, UNLV8087_054) {
173
176
}
174
177
175
178
// Tests that Tesseract gets the important blocks and in the right order
176
- // on a UNLV page numbered 8087_054.3B.tif. (Dubrovnik)
179
+ // on GOOGLE:13510798882202548:74:84.sj-79.tif (Hebrew image)
180
+ // TODO: replace hebrew.png by Google image referred above
177
181
TEST_F (LayoutTest, HebrewOrderingAndSkew) {
178
- SetImage (" GOOGLE:13510798882202548:74:84.sj-79.tif " , " eng" );
182
+ SetImage (" hebrew.png " , " eng" );
179
183
// Just run recognition.
180
184
EXPECT_EQ (api_.Recognize (nullptr ), 0 );
181
185
tesseract::MutableIterator* it = api_.GetMutableIterator ();
@@ -184,7 +188,7 @@ TEST_F(LayoutTest, HebrewOrderingAndSkew) {
184
188
VerifyTotalContainment (1 , it);
185
189
delete it;
186
190
// Now try again using Hebrew.
187
- SetImage (" GOOGLE:13510798882202548:74:84.sj-79.tif " , " heb" );
191
+ SetImage (" hebrew.png " , " heb" );
188
192
// Just run recognition.
189
193
EXPECT_EQ (api_.Recognize (nullptr ), 0 );
190
194
it = api_.GetMutableIterator ();
0 commit comments