17#include <allheaders.h>
31static const char *kPolyBlockNames[] = {
50const char *
kStrings8087_054[] = {
"dat",
"Dalmatian",
"",
"DAMAGED DURING",
"margarine,",
nullptr};
71 void SetImage(
const char *filename,
const char *lang) {
91 if (block_text !=
nullptr && it->
BlockType() == blocks[string_index] &&
92 strstr(block_text, strings[string_index]) !=
nullptr) {
93 LOG(
INFO) <<
"Found string " << strings[string_index] <<
" in block " << block_index
94 <<
" of type " << kPolyBlockNames[blocks[string_index]] <<
"\n";
97 }
else if (it->
BlockType() == blocks[string_index] && block_text ==
nullptr &&
98 strings[string_index][0] ==
'\0') {
99 LOG(
INFO) <<
"Found block of type " << kPolyBlockNames[blocks[string_index]] <<
" at block "
100 << block_index <<
"\n";
104 LOG(
INFO) <<
"No match found in block with text:\n" << block_text;
108 if (strings[string_index] ==
nullptr) {
126 int left, top, right, bottom;
129 if (prev_right > prev_left) {
130 if (std::min(right, prev_right) > std::max(left, prev_left)) {
131 EXPECT_GE(top, prev_bottom) <<
"Overlapping block should be below";
132 }
else if (top < prev_bottom) {
134 EXPECT_GE(prev_left, right) <<
"Block should be to the left";
136 EXPECT_GE(left, prev_right) <<
"Block should be to the right";
142 prev_bottom = bottom;
153 int left, top, right, bottom;
158 CHECK(pb !=
nullptr);
168 for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
169 C_BLOB *blob = b_it.data();
171 C_OUTLINE_IT ol_it(blob->
out_list());
172 for (ol_it.mark_cycle_pt(); !ol_it.cycled_list(); ol_it.forward()) {
193 for (size = 0; kPolyBlockNames[size][0] !=
'\0'; ++size) {
202 SetImage(
"8087_054.3B.tif",
"eng");
215 SetImage(
"hebrew.png",
"eng");
220 VerifyRoughBlockOrder(
false, it);
221 VerifyTotalContainment(1, it);
224 SetImage(
"hebrew.png",
"heb");
227 it = api_.GetMutableIterator();
229 VerifyRoughBlockOrder(
true, it);
231 VerifyTotalContainment(-1, it);
#define EXPECT_EQ(val1, val2)
#define EXPECT_GT(val1, val2)
#define EXPECT_GE(val1, val2)
#define EXPECT_TRUE(condition)
@ PSM_AUTO
Fully automatic page segmentation, but no OSD.
const char * kStrings8087_054[]
const PolyBlockType kBlocks8087_054[]
bool PTIsTextType(PolyBlockType type)
TEST_F(EuroText, FastLatinOCR)
void SetPageSegMode(PageSegMode mode)
int Init(const char *datapath, const char *language, OcrEngineMode mode, char **configs, int configs_size, const std::vector< std::string > *vars_vec, const std::vector< std::string > *vars_values, bool set_only_non_debug_params)
void SetImage(const unsigned char *imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line)
PolyBlockType BlockType() const
bool BoundingBox(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
virtual char * GetUTF8Text(PageIteratorLevel level) const
bool IsAtBeginningOf(PageIteratorLevel level) const override
bool Next(PageIteratorLevel level) override
const PAGE_RES_IT * PageResIt() const
const TBOX & bounding_box() const
PDBLK pdblk
Page Description Block.
BLOCK_RES * block() const
POLY_BLOCK * poly_block() const
int16_t winding_number(const ICOORD &test_pt)
TDimension bottom() const
C_OUTLINE_LIST * out_list()
C_BLOB_LIST * cblob_list()
static std::string JoinPath(const std::string &s1, const std::string &s2)
tesseract::TessBaseAPI api_
void SetImage(const char *filename, const char *lang)
void VerifyRoughBlockOrder(bool right_to_left, ResultIterator *it)
void VerifyBlockTextOrder(const char *strings[], const PolyBlockType *blocks, ResultIterator *it)
std::string TestDataNameToPath(const std::string &name)
std::string TessdataPath()
void VerifyTotalContainment(int winding_target, MutableIterator *it)