12#include <allheaders.h>
70 auto osd_tess = std::make_unique<Tesseract>();
73 nullptr, 0,
nullptr,
nullptr,
false, &mgr),
77 nullptr, 0,
nullptr,
nullptr,
false, &mgr),
86 auto *block =
new BLOCK(
"",
true, 0, 0, 0, 0, width, height);
87 block->set_right_to_left(
false);
88 BLOCK_LIST src_blocks;
89 BLOCK_IT block_it(&src_blocks);
90 block_it.add_to_end(block);
91 Image photomask_pix =
nullptr;
93 BLOCK_LIST found_blocks;
94 TO_BLOCK_LIST temp_blocks;
97 &osr, &temp_blocks, &photomask_pix,
nullptr);
98 TO_BLOCK_IT to_block_it(&temp_blocks);
99 TO_BLOCK *to_block = to_block_it.data();
101 TO_BLOCK_LIST to_blocks;
102 BLOBNBOX_LIST diacritic_blobs;
104 nullptr,
nullptr, &found_blocks, &diacritic_blobs, &to_blocks),
112 void EvaluateBox(
const TBOX &box,
bool greater_or_equal,
int target_value,
const char *text,
115 if (greater_or_equal != (
value > target_value)) {
116 LOG(
INFO) <<
"EvaluateBox too " << (greater_or_equal ?
"low" :
"high")
117 <<
":" <<
value <<
" vs " << target_value <<
" for " <<
message <<
" word '" << text <<
"' at:";
121 LOG(
INFO) <<
"EvaluateBox OK(" <<
value <<
") for " <<
message <<
" word '" << text <<
"'";
123 if (greater_or_equal) {
133 const char *text,
const char *
message) {
136 if (false_dist <= true_dist) {
137 LOG(
INFO) <<
"Distance wrong:" << false_dist <<
" vs " << true_dist
138 <<
" for " <<
message <<
" word '" << text <<
"' at:";
143 LOG(
INFO) <<
"Distance OK(" << false_dist <<
" vs " << true_dist
144 <<
") for " <<
message <<
" word '" << text <<
"'";
161 bool small_word = word_box.
height() * 1.5 < line_height;
162 bool tall_word = word_box.
height() * 1.125 > line_height;
167 padding = word_box.
height();
168 }
else if (tall_word) {
169 padding = word_box.
height() / 3;
171 padding = word_box.
height() / 2;
177 TBOX upper_box(word_box);
181 EvaluateBox(upper_box,
true, -1, text,
"Upper Word not vertical");
182 TBOX lower_box = word_box;
189 EvaluateBox(lower_box,
true, -1, text,
"Lower Word not vertical");
193 bool upper_or_lower_out_of_textline =
196 if (!upper_or_lower_out_of_textline) {
206 padding = line_height / 4;
208 TBOX target_box(word_box);
213 TBOX upper_challenger(upper_box);
216 EvaluateDistance(upper_box, target_box, upper_challenger, text,
"Upper Word");
221 target_box = word_box;
223 TBOX lower_challenger(lower_box);
226 EvaluateDistance(lower_box, target_box, lower_challenger, text,
"Lower Word");
246 VerifyBoxes(
"phototest.tif", 31);
251 VerifyBoxes(
"phototestrot.tif", 31);
#define EXPECT_EQ(val1, val2)
#define EXPECT_GE(val1, val2)
#define EXPECT_TRUE(condition)
#define EXPECT_LT(val1, val2)
@ PSM_AUTO
Fully automatic page segmentation, but no OSD.
const int kMinStrongTextValue
TEST_F(EuroText, FastLatinOCR)
int Recognize(ETEXT_DESC *monitor)
void SetPageSegMode(PageSegMode mode)
MutableIterator * GetMutableIterator()
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)
Tesseract * tesseract() const
Pix * GetThresholdedImage()
virtual char * GetUTF8Text(PageIteratorLevel level) const
bool Next(PageIteratorLevel level) override
const PAGE_RES_IT * PageResIt() const
int source_resolution() const
TDimension height() const
void move(const ICOORD vec)
TDimension bottom() const
TBOX bounding_box() const
const TextlineProjection * projection() const
const DENORM * denorm() const
int FindBlocks(PageSegMode pageseg_mode, Image scaled_color, int scaled_factor, TO_BLOCK *block, Image photo_mask_pix, Image thresholds_pix, Image grey_pix, DebugPixa *pixa_debug, BLOCK_LIST *blocks, BLOBNBOX_LIST *diacritic_blobs, TO_BLOCK_LIST *to_blocks)
bool BoxOutOfHTextline(const TBOX &box, const DENORM *denorm, bool debug) const
int EvaluateBox(const TBOX &box, const DENORM *denorm, bool debug) const
int DistanceOfBoxFromBox(const TBOX &from_box, const TBOX &to_box, bool horizontal_textline, const DENORM *denorm, bool debug) const
static std::string JoinPath(const std::string &s1, const std::string &s2)
~TextlineProjectionTest() override
void EvaluateDistance(const TBOX &box, const TBOX &true_box, const TBOX &false_box, const char *text, const char *message)
void EvaluateBox(const TBOX &box, bool greater_or_equal, int target_value, const char *text, const char *message)
std::string OutputNameToPath(const std::string &name)
void VerifyBoxes(const char *imagefile, int line_height)
tesseract::TessBaseAPI api_
void SetImage(const char *filename)
const TextlineProjection * projection_
std::unique_ptr< Tesseract > tesseract_