2 #include "leptonica/allheaders.h"
9 #ifndef TESSERACT_FUZZER_WIDTH
10 #define TESSERACT_FUZZER_WIDTH 100
13 #ifndef TESSERACT_FUZZER_HEIGHT
14 #define TESSERACT_FUZZER_HEIGHT 100
25 : data(data), size(size), shift(0) {}
32 const int ret = ((*data) >> shift) & 1;
48 if (std::getenv(
"TESSDATA_PREFIX") ==
nullptr) {
50 const std::string filepath = dirname(&binary_path[0]);
52 const std::string tessdata_path = filepath +
"/" +
"tessdata";
53 if (setenv(
"TESSDATA_PREFIX", tessdata_path.c_str(), 1) != 0) {
54 printf(
"Setenv failed\n");
60 if (api->
Init(
nullptr,
"eng") != 0) {
61 printf(
"Cannot initialize API\n");
71 static PIX* createPix(
BitReader& BR,
const size_t width,
const size_t height) {
72 Pix* pix = pixCreate(width, height, 1);
75 printf(
"pix creation failed\n");
79 for (
size_t i = 0; i < width; i++) {
80 for (
size_t j = 0; j < height; j++) {
81 pixSetPixel(pix, i, j, BR.
Read());