25#include <allheaders.h>
47 const time_t MAX_SECONDS_FOR_TEST = 240;
51 const time_t MAX_SECONDS_FOR_TEST = 55;
53 const time_t end_time = time(
nullptr);
60void OCRTester(
const char *imgname,
const char *groundtruth,
const char *tessdatadir,
65 std::ifstream
file(groundtruth);
67 std::string gtText((std::istreambuf_iterator<char>(
file)), std::istreambuf_iterator<char>());
68 auto api = std::make_unique<tesseract::TessBaseAPI>();
69 ASSERT_FALSE(api->Init(tessdatadir, lang)) <<
"Could not initialize tesseract.";
70 Image image = pixRead(imgname);
71 ASSERT_TRUE(image !=
nullptr) <<
"Failed to read test image.";
73 outText = api->GetUTF8Text();
74 EXPECT_EQ(gtText, outText) <<
"Phototest.tif OCR does not match ground truth for "
77 api->ClearPersistentCache();
85 OCRTester(TESTING_DIR
"/phototest.tif", TESTING_DIR
"/phototest.txt", TESSDATA_DIR
"_fast",
90 OCRTester(TESTING_DIR
"/phototest.tif", TESTING_DIR
"/phototest.txt", TESSDATA_DIR
"_best",
95 OCRTester(TESTING_DIR
"/phototest.tif", TESTING_DIR
"/phototest.txt", TESSDATA_DIR, GetParam());
106 OCRTester(TESTING_DIR
"/eurotext.tif", TESTING_DIR
"/eurotext.txt", TESSDATA_DIR
"_fast",
#define EXPECT_EQ(val1, val2)
#define ASSERT_FALSE(condition)
#define EXPECT_TRUE(condition)
#define ASSERT_TRUE(condition)
void OCRTester(const char *imgname, const char *groundtruth, const char *tessdatadir, const char *lang)
INSTANTIATE_TEST_SUITE_P(Eng, MatchGroundTruth, ::testing::Values("eng"))
TEST_P(MatchGroundTruth, FastPhototestOCR)
TEST_F(EuroText, FastLatinOCR)
::std::string PrintToString(const T &value)
internal::ValueArray< T... > Values(T... v)