9#ifndef TESSERACT_FUZZER_WIDTH
10# define TESSERACT_FUZZER_WIDTH 100
13#ifndef TESSERACT_FUZZER_HEIGHT
14# define TESSERACT_FUZZER_HEIGHT 100
24 BitReader(
const uint8_t *data,
size_t size) : data(data), size(size), shift(0) {}
31 const int ret = ((*data) >> shift) & 1;
47 if (std::getenv(
"TESSDATA_PREFIX") ==
nullptr) {
48 std::string binary_path = *pArgv[0];
49 const std::string filepath = dirname(&binary_path[0]);
51 const std::string tessdata_path = filepath +
"/" +
"tessdata";
52 if (setenv(
"TESSDATA_PREFIX", tessdata_path.c_str(), 1) != 0) {
53 printf(
"Setenv failed\n");
59 if (api->
Init(
nullptr,
"eng") != 0) {
60 printf(
"Cannot initialize API\n");
70static PIX *createPix(
BitReader &BR,
const size_t width,
const size_t height) {
71 Pix *pix = pixCreate(width, height, 1);
74 printf(
"pix creation failed\n");
78 for (
size_t i = 0; i < width; i++) {
79 for (
size_t j = 0; j < height; j++) {
80 pixSetPixel(pix, i, j, BR.
Read());
#define TESSERACT_FUZZER_WIDTH
int LLVMFuzzerInitialize(int *, char ***pArgv)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
#define TESSERACT_FUZZER_HEIGHT
bool SetVariable(const char *name, const char *value)
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)
BitReader(const uint8_t *data, size_t size)