21 #include "config_auto.h" 30 #if defined(__MINGW32__) 32 #undef __STRICT_ANSI__ 39 #include <sys/types.h> 53 #include "allheaders.h" 56 #include "config_auto.h" 118 static void addAvailableLanguages(
const STRING &datadir,
const STRING &base,
121 const STRING base2 = (base.
string()[0] ==
'\0') ? base : base +
"/";
122 const size_t extlen =
sizeof(kTrainedDataSuffix);
124 WIN32_FIND_DATA data;
125 HANDLE handle = FindFirstFile((datadir + base2 +
"*").
string(), &data);
126 if (handle != INVALID_HANDLE_VALUE) {
129 char *name = data.cFileName;
131 if (name[0] !=
'.') {
132 if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ==
133 FILE_ATTRIBUTE_DIRECTORY) {
134 addAvailableLanguages(datadir, base2 + name, langs);
136 size_t len = strlen(name);
137 if (len > extlen && name[len - extlen] ==
'.' &&
138 strcmp(&name[len - extlen + 1], kTrainedDataSuffix) == 0) {
139 name[len - extlen] =
'\0';
144 result = FindNextFile(handle, &data);
149 DIR* dir = opendir((datadir + base).
string());
150 if (dir !=
nullptr) {
152 while ((de = readdir(dir))) {
153 char *name = de->d_name;
155 if (name[0] !=
'.') {
157 if (stat((datadir + base2 + name).
string(), &st) == 0 &&
158 (st.st_mode & S_IFDIR) == S_IFDIR) {
159 addAvailableLanguages(datadir, base2 + name, langs);
161 size_t len = strlen(name);
162 if (len > extlen && name[len - extlen] ==
'.' &&
163 strcmp(&name[len - extlen + 1], kTrainedDataSuffix) == 0) {
164 name[len - extlen] =
'\0';
176 static int CompareSTRING(
const void* p1,
const void* p2) {
183 : tesseract_(nullptr),
184 osd_tesseract_(nullptr),
185 equ_detect_(nullptr),
190 thresholder_(nullptr),
191 paragraph_models_(nullptr),
192 block_list_(nullptr),
194 input_file_(nullptr),
195 output_file_(nullptr),
199 recognition_done_(false),
208 locale = std::setlocale(LC_ALL,
nullptr);
210 locale = std::setlocale(LC_CTYPE,
nullptr);
212 locale = std::setlocale(LC_NUMERIC,
nullptr);
224 return PACKAGE_VERSION;
235 #ifdef USE_DEVICE_SELECTION 241 #ifdef USE_DEVICE_SELECTION 242 ds_device device = OpenclDevice::getDeviceSelection();
243 if (device.type == DS_DEVICE_OPENCL_DEVICE) {
244 *data =
new cl_device_id;
245 memcpy(*data, &device.oclDeviceID,
sizeof(cl_device_id));
246 return sizeof(cl_device_id);
261 struct sigaction action;
262 memset(&action, 0,
sizeof(action));
264 action.sa_flags = SA_RESETHAND;
265 sigaction(SIGSEGV, &action,
nullptr);
266 sigaction(SIGFPE, &action,
nullptr);
267 sigaction(SIGBUS, &action,
nullptr);
270 tprintf(
"CatchSignals has no non-linux implementation!\n");
306 IntParam *p = ParamUtils::FindParam<IntParam>(
308 if (p ==
nullptr)
return false;
309 *value = (int32_t)(*p);
314 BoolParam *p = ParamUtils::FindParam<BoolParam>(
316 if (p ==
nullptr)
return false;
317 *value = (
BOOL8)(*p);
322 StringParam *p = ParamUtils::FindParam<StringParam>(
324 return (p !=
nullptr) ? p->
string() :
nullptr;
328 DoubleParam *p = ParamUtils::FindParam<DoubleParam>(
330 if (p ==
nullptr)
return false;
331 *value = (double)(*p);
357 bool set_only_non_debug_params) {
358 return Init(datapath, 0, language,
oem, configs, configs_size, vars_vec,
359 vars_values, set_only_non_debug_params,
nullptr);
369 bool set_only_non_debug_params,
FileReader reader) {
372 if (language ==
nullptr) language =
"eng";
373 STRING datapath = data_size == 0 ? data : language;
392 bool reset_classifier =
true;
394 reset_classifier =
false;
396 if (reader !=
nullptr)
reader_ = reader;
398 if (data_size != 0) {
404 language,
oem, configs, configs_size, vars_vec, vars_values,
405 set_only_non_debug_params, &mgr) != 0) {
426 #ifndef DISABLED_LEGACY_ENGINE 429 if (reset_classifier) {
433 #endif // ndef DISABLED_LEGACY_ENGINE 462 for (
int i = 0; i < num_subs; ++i)
475 langs->
sort(CompareSTRING);
480 #ifndef DISABLED_LEGACY_ENGINE 495 #endif // ndef DISABLED_LEGACY_ENGINE 504 #ifndef DISABLED_LEGACY_ENGINE 560 int width,
int height) {
566 int bits_per_pixel = bytes_per_pixel == 0 ? 1 : bytes_per_pixel * 8;
567 SetImage(imagedata, bytes_per_line * 8 / bits_per_pixel, height + top,
568 bytes_per_pixel, bytes_per_line);
574 #ifndef DISABLED_LEGACY_ENGINE 585 #endif // ndef DISABLED_LEGACY_ENGINE 595 int width,
int height,
596 int bytes_per_pixel,
int bytes_per_line) {
599 bytes_per_pixel, bytes_per_line);
608 tprintf(
"Please call SetImage before SetSourceResolution.\n");
621 if (pixGetSpp(pix) == 4 && pixGetInputFormat(pix) == IFF_PNG) {
623 PIX* p1 = pixRemoveAlpha(pix);
625 pix = pixCopy(
nullptr, p1);
676 Pixa** pixa,
int** blockids,
int** paraids) {
678 pixa, blockids, paraids);
721 bool text_only,
bool raw_image,
722 const int raw_padding,
723 Pixa** pixa,
int** blockids,
726 if (page_it ==
nullptr)
728 if (page_it ==
nullptr)
732 int component_count = 0;
733 int left, top, right, bottom;
740 &left, &top, &right, &bottom);
746 level, &left, &top, &right, &bottom);
749 if (get_bbox->
Run() &&
752 }
while (page_it->
Next(level));
754 Boxa* boxa = boxaCreate(component_count);
756 *pixa = pixaCreate(component_count);
757 if (blockids !=
nullptr)
758 *blockids =
new int[component_count];
759 if (paraids !=
nullptr)
760 *paraids =
new int[component_count];
764 int component_index = 0;
767 if (get_bbox->
Run() &&
769 Box* lbox = boxCreate(left, top, right - left, bottom - top);
770 boxaAddBox(boxa, lbox, L_INSERT);
771 if (pixa !=
nullptr) {
779 pixaAddPix(*pixa, pix, L_INSERT);
780 pixaAddBox(*pixa, lbox, L_CLONE);
782 if (paraids !=
nullptr) {
783 (*paraids)[component_index] = paraid;
787 if (blockids !=
nullptr) {
788 (*blockids)[component_index] = blockid;
796 }
while (page_it->
Next(level));
858 #ifndef DISABLED_LEGACY_ENGINE 864 #endif // ndef DISABLED_LEGACY_ENGINE 879 #ifndef DISABLED_LEGACY_ENGINE 884 #endif // ndef DISABLED_LEGACY_ENGINE 899 #ifndef GRAPHICS_DISABLED 901 #endif // GRAPHICS_DISABLED 907 #ifndef DISABLED_LEGACY_ENGINE 917 fclose(training_output_file);
918 #endif // ndef DISABLED_LEGACY_ENGINE 921 bool wait_for_text =
true;
933 #ifndef DISABLED_LEGACY_ENGINE 939 tprintf(
"Please call SetImage before attempting recognition.\n");
956 while (page_res_it.
word() !=
nullptr) {
960 page_res_it.
row()->
row, word_res);
965 #endif // ndef DISABLED_LEGACY_ENGINE 990 bool TessBaseAPI::ProcessPagesFileList(FILE *flist,
992 const char* retry_config,
993 int timeout_millisec,
995 int tessedit_page_number) {
996 if (!flist && !buf)
return false;
997 int page = (tessedit_page_number >= 0) ? tessedit_page_number : 0;
1002 buf->
split(
'\n', &lines);
1003 if (lines.
empty())
return false;
1007 for (
int i = 0; i < page; i++) {
1009 if (fgets(pagename,
sizeof(pagename), flist) ==
nullptr)
break;
1021 if (fgets(pagename,
sizeof(pagename), flist) ==
nullptr)
break;
1023 if (page >= lines.
size())
break;
1024 snprintf(pagename,
sizeof(pagename),
"%s", lines[page].c_str());
1027 Pix *pix = pixRead(pagename);
1028 if (pix ==
nullptr) {
1029 tprintf(
"Image file %s cannot be read!\n", pagename);
1032 tprintf(
"Page %d : %s\n", page, pagename);
1033 bool r =
ProcessPage(pix, page, pagename, retry_config,
1034 timeout_millisec, renderer);
1036 if (!r)
return false;
1037 if (tessedit_page_number >= 0)
break;
1048 bool TessBaseAPI::ProcessPagesMultipageTiff(
const l_uint8 *data,
1050 const char* filename,
1051 const char* retry_config,
1052 int timeout_millisec,
1054 int tessedit_page_number) {
1055 #ifndef ANDROID_BUILD 1057 int page = (tessedit_page_number >= 0) ? tessedit_page_number : 0;
1060 if (tessedit_page_number >= 0)
1061 page = tessedit_page_number;
1062 pix = (data) ? pixReadMemFromMultipageTiff(data, size, &offset)
1063 : pixReadFromMultipageTiff(filename, &offset);
1064 if (pix ==
nullptr)
break;
1065 tprintf(
"Page %d\n", page + 1);
1069 bool r =
ProcessPage(pix, page, filename, retry_config,
1070 timeout_millisec, renderer);
1072 if (!r)
return false;
1073 if (tessedit_page_number >= 0)
break;
1085 int timeout_millisec,
1089 #ifndef DISABLED_LEGACY_ENGINE 1097 #endif // ndef DISABLED_LEGACY_ENGINE 1113 const char* retry_config,
1114 int timeout_millisec,
1117 bool stdInput = !strcmp(filename,
"stdin") || !strcmp(filename,
"-");
1120 if (_setmode(_fileno(stdin), _O_BINARY) == -1)
1121 tprintf(
"ERROR: cin to binary: %s", strerror(errno));
1126 return ProcessPagesFileList(stdin,
nullptr, retry_config,
1127 timeout_millisec, renderer,
1135 const l_uint8 *data =
nullptr;
1137 buf.
assign((std::istreambuf_iterator<char>(std::cin)),
1138 (std::istreambuf_iterator<char>()));
1139 data =
reinterpret_cast<const l_uint8 *
>(buf.data());
1142 if (FILE* file = fopen(filename,
"rb")) {
1145 fprintf(stderr,
"Error, cannot read input file %s: %s\n",
1146 filename, strerror(errno));
1153 int r = (stdInput) ?
1154 findFileFormatBuffer(data, &format) :
1155 findFileFormat(filename, &format);
1158 if (r != 0 || format == IFF_UNKNOWN) {
1163 std::ifstream t(filename);
1164 std::string u((std::istreambuf_iterator<char>(t)),
1165 std::istreambuf_iterator<char>());
1168 return ProcessPagesFileList(
nullptr, &s, retry_config,
1169 timeout_millisec, renderer,
1174 bool tiff = (format == IFF_TIFF || format == IFF_TIFF_PACKBITS ||
1175 format == IFF_TIFF_RLE || format == IFF_TIFF_G3 ||
1176 format == IFF_TIFF_G4 || format == IFF_TIFF_LZW ||
1177 format == IFF_TIFF_ZIP);
1182 pix = (stdInput) ? pixReadMem(data, buf.size()) : pixRead(filename);
1183 if (pix ==
nullptr) {
1196 ProcessPagesMultipageTiff(data, buf.size(), filename, retry_config,
1197 timeout_millisec, renderer,
1200 timeout_millisec, renderer);
1206 if (!r || (renderer && !renderer->EndDocument())) {
1214 const char* retry_config,
int timeout_millisec,
1219 bool failed =
false;
1225 if (it ==
nullptr) {
1232 }
else if (timeout_millisec > 0) {
1235 monitor.
cancel =
nullptr;
1247 #ifndef ANDROID_BUILD 1249 pixWrite(
"tessinput.tif", page_pix, IFF_TIFF_G4);
1250 #endif // ANDROID_BUILD 1253 if (failed && retry_config !=
nullptr && retry_config[0] !=
'\0') {
1256 if (fp ==
nullptr) {
1270 if (renderer && !failed) {
1271 failed = !renderer->
AddImage(
this);
1335 text += para_text.get();
1337 char* result =
new char[text.
length() + 1];
1351 it->
Orientation(&orientation, &writing_direction, &textline_order,
1364 static void AddBaselineCoordsTohOCR(
const PageIterator *it,
1369 hocr_str->
add_str_int(
"; textangle ", 360 - orientation * 90);
1373 int left, top, right, bottom;
1374 it->BoundingBox(level, &left, &top, &right, &bottom);
1378 if (!it->Baseline(level, &x1, &y1, &x2, &y2))
1396 p1 = (y2 - y1) / static_cast<double>(x2 - x1);
1397 p0 = y1 -
static_cast<double>(p1 * x1);
1399 hocr_str->
add_str_double(
"; baseline ", round(p1 * 1000.0) / 1000.0);
1403 static void AddIdTohOCR(
STRING* hocr_str,
const std::string base,
int num1,
1405 const size_t BUFSIZE = 64;
1406 char id_buffer[BUFSIZE];
1408 snprintf(id_buffer, BUFSIZE - 1,
"%s_%d_%d", base.c_str(), num1, num2);
1410 snprintf(id_buffer, BUFSIZE - 1,
"%s_%d", base.c_str(), num1);
1412 id_buffer[BUFSIZE - 1] =
'\0';
1413 *hocr_str +=
" id='";
1414 *hocr_str += id_buffer;
1418 static void AddIdTohOCR(
STRING* hocr_str,
const std::string base,
int num1,
1419 int num2,
int num3) {
1420 const size_t BUFSIZE = 64;
1421 char id_buffer[BUFSIZE];
1422 snprintf(id_buffer, BUFSIZE - 1,
"%s_%d_%d_%d", base.c_str(), num1, num2,num3);
1423 id_buffer[BUFSIZE - 1] =
'\0';
1424 *hocr_str +=
" id='";
1425 *hocr_str += id_buffer;
1431 int left, top, right, bottom;
1432 it->BoundingBox(level, &left, &top, &right, &bottom);
1441 AddBaselineCoordsTohOCR(it, level, hocr_str);
1443 float row_height, descenders, ascenders;
1444 it->RowAttributes(&row_height, &descenders, &ascenders);
1455 int left, top, right, bottom;
1456 it->BoundingBox(level, &left, &top, &right, &bottom);
1489 int lcnt = 1, bcnt = 1, pcnt = 1, wcnt = 1, tcnt = 1, gcnt = 1;
1490 int page_id = page_number + 1;
1491 bool para_is_ltr =
true;
1492 const char* paragraph_lang =
nullptr;
1493 bool font_info =
false;
1505 wchar_t *uni16_str =
new WCHAR[str16_len];
1507 uni16_str, str16_len);
1508 int utf8_len = WideCharToMultiByte(CP_UTF8, 0, uni16_str, str16_len,
nullptr, 0,
1510 char *utf8_str =
new char[utf8_len];
1511 WideCharToMultiByte(CP_UTF8, 0, uni16_str, str16_len, utf8_str,
1512 utf8_len,
nullptr,
nullptr);
1518 hocr_str +=
" <div class='ocr_page'";
1519 AddIdTohOCR(&hocr_str,
"page", page_id, -1);
1520 hocr_str +=
" title='image \"";
1524 hocr_str +=
"unknown";
1543 hocr_str +=
" <div class='ocr_carea'";
1544 AddIdTohOCR(&hocr_str,
"block", page_id, bcnt);
1545 AddBoxTohOCR(res_it,
RIL_BLOCK, &hocr_str);
1548 hocr_str +=
"\n <p class='ocr_par'";
1551 hocr_str +=
" dir='rtl'";
1553 AddIdTohOCR(&hocr_str,
"par", page_id, pcnt);
1555 if (paragraph_lang) {
1556 hocr_str +=
" lang='";
1557 hocr_str += paragraph_lang;
1560 AddBoxTohOCR(res_it,
RIL_PARA, &hocr_str);
1563 hocr_str +=
"\n <span class='ocr_line'";
1564 AddIdTohOCR(&hocr_str,
"line", page_id, lcnt);
1569 std::vector<std::vector<std::pair<const char*, float>>>* confidencemap =
nullptr;
1573 hocr_str +=
"\n <span class='ocrx_word'";
1574 AddIdTohOCR(&hocr_str,
"word", page_id, wcnt);
1575 int left, top, right, bottom;
1576 bool bold, italic, underlined, monospace, serif, smallcaps;
1577 int pointsize, font_id;
1578 const char *font_name;
1581 &monospace, &serif, &smallcaps,
1582 &pointsize, &font_id);
1590 hocr_str +=
"; x_font ";
1597 if (lang && (!paragraph_lang || strcmp(lang, paragraph_lang))) {
1598 hocr_str +=
" lang='";
1605 if (!para_is_ltr) hocr_str +=
" dir='ltr'";
1608 if (para_is_ltr) hocr_str +=
" dir='rtl'";
1619 if (bold) hocr_str +=
"<strong>";
1620 if (italic) hocr_str +=
"<em>";
1622 const std::unique_ptr<const char[]> grapheme(
1624 if (grapheme && grapheme[0] != 0) {
1629 if (italic) hocr_str +=
"</em>";
1630 if (bold) hocr_str +=
"</strong>";
1633 for (
size_t i = 0; i < confidencemap->size(); i++) {
1634 hocr_str +=
"\n <span class='ocrx_cinfo'";
1635 AddIdTohOCR(&hocr_str,
"timestep", page_id, wcnt, tcnt);
1637 std::vector<std::pair<const char*, float>> timestep = (*confidencemap)[i];
1638 for (std::pair<const char*, float> conf : timestep) {
1639 hocr_str +=
"<span class='ocr_glyph'";
1640 AddIdTohOCR(&hocr_str,
"choice", page_id, wcnt, gcnt);
1641 hocr_str.
add_str_int(
" title='x_confs ",
int(conf.second * 100));
1644 hocr_str += conf.first;
1645 hocr_str +=
"</span>";
1648 hocr_str +=
"</span>";
1652 for (
size_t i = 0; i < confidencemap->size(); i++) {
1653 std::vector<std::pair<const char*, float>> timestep = (*confidencemap)[i];
1654 if (timestep.size() > 0) {
1655 hocr_str +=
"\n <span class='ocrx_cinfo'";
1656 AddIdTohOCR(&hocr_str,
"lstm_choices", page_id, wcnt, tcnt);
1657 hocr_str +=
" chosen='";
1658 hocr_str += timestep[0].first;
1660 for (
size_t j = 1; j < timestep.size(); j++) {
1661 hocr_str +=
"<span class='ocr_glyph'";
1662 AddIdTohOCR(&hocr_str,
"choice", page_id, wcnt, gcnt);
1663 hocr_str.
add_str_int(
" title='x_confs ",
int(timestep[j].second * 100));
1666 hocr_str += timestep[j].first;
1667 hocr_str +=
"</span>";
1670 hocr_str +=
"</span>";
1675 hocr_str +=
"</span>";
1680 if (last_word_in_line) {
1681 hocr_str +=
"\n </span>";
1684 if (last_word_in_para) {
1685 hocr_str +=
"\n </p>\n";
1689 if (last_word_in_block) {
1690 hocr_str +=
" </div>\n";
1694 hocr_str +=
" </div>\n";
1696 char *ret =
new char[hocr_str.
length() + 1];
1697 strcpy(ret, hocr_str.
string());
1711 int lcnt = 1, bcnt = 1, pcnt = 1, wcnt = 1;
1712 int page_id = page_number + 1;
1716 int page_num = page_id;
1731 tsv_str +=
"\t-1\t\n";
1751 AddBoxToTSV(res_it,
RIL_BLOCK, &tsv_str);
1752 tsv_str +=
"\t-1\t\n";
1763 AddBoxToTSV(res_it,
RIL_PARA, &tsv_str);
1764 tsv_str +=
"\t-1\t\n";
1775 tsv_str +=
"\t-1\t\n";
1779 int left, top, right, bottom;
1808 char* ret =
new char[tsv_str.
length() + 1];
1809 strcpy(ret, tsv_str.
string());
1852 char* result =
new char[total_length];
1854 int output_length = 0;
1857 int left, top, right, bottom;
1859 const std::unique_ptr<
char[]> text(
1863 for (
int i = 0; text[i] !=
'\0'; ++i) {
1867 snprintf(result + output_length, total_length - output_length,
1868 "%s %d %d %d %d %d\n", text.get(), left,
image_height_ - bottom,
1870 output_length += strlen(result + output_length);
1886 0x20ac, 0x201c, 0x201d, 0x2018, 0x2019, 0x2022, 0x2014, 0
1890 0x00a2, 0x0022, 0x0022, 0x0027, 0x0027, 0x00b7, 0x002d, 0
1902 bool tilde_crunch_written =
false;
1903 bool last_char_was_newline =
true;
1904 bool last_char_was_tilde =
false;
1908 char* result =
new char[total_length];
1916 (!tilde_crunch_written ||
1927 last_char_was_tilde =
false;
1929 if (!last_char_was_tilde) {
1931 last_char_was_tilde =
true;
1933 tilde_crunch_written =
true;
1934 last_char_was_newline =
false;
1939 tilde_crunch_written =
false;
1943 int length = lengths.
length();
1947 if (last_char_was_tilde &&
1948 word->
word->
space() == 0 && wordstr[offset] ==
' ') {
1952 offset = lengths[i++];
1954 if (i < length && wordstr[offset] != 0) {
1955 if (!last_char_was_newline)
1958 last_char_was_newline =
false;
1959 for (; i < length; offset += lengths[i++]) {
1960 if (wordstr[offset] ==
' ' ||
1963 last_char_was_tilde =
true;
1967 UNICHAR ch(wordstr + offset, lengths[i]);
1969 for (
int j = 0;
kUniChs[j] != 0; ++j) {
1975 if (uni_ch <= 0xff) {
1976 *ptr++ =
static_cast<char>(uni_ch);
1977 last_char_was_tilde =
false;
1980 last_char_was_tilde =
true;
1989 tilde_crunch_written =
false;
1990 last_char_was_newline =
true;
1991 last_char_was_tilde =
false;
1999 #ifndef DISABLED_LEGACY_ENGINE 2011 const char** script_name,
2012 float* script_conf) {
2023 if (orient_deg) *orient_deg = orient_id * 90;
2028 *script_name = script;
2044 const char* script_name;
2054 const int kOsdBufsize = 255;
2055 char* osd_buf =
new char[kOsdBufsize];
2056 snprintf(osd_buf, kOsdBufsize,
2058 "Orientation in degrees: %d\n" 2060 "Orientation confidence: %.2f\n" 2062 "Script confidence: %.2f\n",
2063 page_number, orient_deg, rotate, orient_conf, script_name,
2069 #endif // ndef DISABLED_LEGACY_ENGINE 2074 if (!conf)
return 0;
2077 while (*pt >= 0) sum += *pt++;
2078 if (pt != conf) sum /= pt - conf;
2093 int* conf =
new int[n_word+1];
2098 int w_conf =
static_cast<int>(100 + 5 * choice->
certainty());
2100 if (w_conf < 0) w_conf = 0;
2101 if (w_conf > 100) w_conf = 100;
2102 conf[n_word++] = w_conf;
2108 #ifndef DISABLED_LEGACY_ENGINE 2122 bool success =
true;
2126 const std::unique_ptr<const char[]> text(
GetUTF8Text());
2128 tprintf(
"Trying to adapt \"%s\" to \"%s\"\n", text.get(), wordstr);
2130 if (text !=
nullptr) {
2133 if (word_res !=
nullptr) {
2138 for (t = 0; text[t] !=
'\0'; ++t) {
2139 if (text[t] ==
'\n' || text[t] ==
' ')
2141 while (wordstr[w] ==
' ') ++w;
2142 if (text[t] != wordstr[w])
2146 if (text[t] !=
'\0' || wordstr[w] !=
'\0') {
2154 if (pr_it.
word() ==
nullptr)
2157 word_res = pr_it.
word();
2174 #endif // ndef DISABLED_LEGACY_ENGINE 2251 if (it ==
nullptr) {
2257 if (x2 <= x1) x2 = x1 + 1;
2259 *out_slope =
static_cast<float>(y2 - y1) / (x2 - x1);
2260 *out_offset =
static_cast<int>(y1 - *out_slope * x1);
2263 int left, top, right, bottom;
2273 *out_offset += bottom - std::max(left_y, right_y);
2276 *out_slope = -*out_slope;
2303 for (
int i = 0; i < num_subs; ++i) {
2309 #ifndef DISABLED_LEGACY_ENGINE 2314 #endif // ndef DISABLED_LEGACY_ENGINE 2319 tprintf(
"Please call Init before attempting to set an image.\n");
2336 if (*pix !=
nullptr)
2344 tprintf(
"Warning: User defined image dpi is outside of expected range " 2353 tprintf(
"Warning: Invalid resolution %d dpi. Using %d instead.\n",
2379 tprintf(
"Estimated internal resolution %d out of range! " 2380 "Corrected to %d.\n",
2391 tprintf(
"Please call SetImage before attempting recognition.\n");
2401 #ifndef DISABLED_LEGACY_ENGINE 2412 #ifndef DISABLED_LEGACY_ENGINE 2418 tprintf(
"Warning: Could not set equation detector\n");
2423 #endif // ndef DISABLED_LEGACY_ENGINE 2428 osd_tess ==
nullptr) {
2435 tprintf(
"Warning: Auto orientation and script detection requested," 2436 " but data path is undefined\n");
2441 nullptr, 0,
nullptr,
nullptr,
2442 false, &mgr) == 0) {
2447 tprintf(
"Warning: Auto orientation and script detection requested," 2448 " but osd language failed to load\n");
2496 int total_length = 2;
2497 int total_blobs = 0;
2503 if (choice !=
nullptr) {
2504 total_blobs += choice->
length() + 2;
2512 if (blob_count !=
nullptr)
2513 *blob_count = total_blobs;
2514 return total_length;
2517 #ifndef DISABLED_LEGACY_ENGINE 2535 #endif // ndef DISABLED_LEGACY_ENGINE 2556 bool** vertical_writing) {
2557 delete[] *block_orientation;
2558 *block_orientation =
nullptr;
2559 delete[] *vertical_writing;
2560 *vertical_writing =
nullptr;
2563 block_it.move_to_first();
2565 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
2566 if (!block_it.data()->pdblk.poly_block()->IsText()) {
2572 tprintf(
"WARNING: Found no blocks\n");
2575 *block_orientation =
new int[num_blocks];
2576 *vertical_writing =
new bool[num_blocks];
2577 block_it.move_to_first();
2579 for (block_it.mark_cycle_pt(); !block_it.cycled_list();
2580 block_it.forward()) {
2581 if (!block_it.data()->pdblk.poly_block()->IsText()) {
2584 FCOORD re_rotation = block_it.data()->re_rotation();
2585 float re_theta = re_rotation.
angle();
2586 FCOORD classify_rotation = block_it.data()->classify_rotation();
2587 float classify_theta = classify_rotation.
angle();
2588 double rot_theta = - (re_theta - classify_theta) * 2.0 / M_PI;
2589 if (rot_theta < 0) rot_theta += 4;
2590 int num_rotations =
static_cast<int>(rot_theta + 0.5);
2591 (*block_orientation)[i] = num_rotations;
2594 (*vertical_writing)[i] = classify_rotation.
y() != 0.0f;
2601 int debug_level = 0;
2609 result_it, &models);
2635 for (ptr = text; *ptr; ptr++) {
2637 case '<': ret +=
"<";
break;
2638 case '>': ret +=
">";
break;
2639 case '&': ret +=
"&";
break;
2640 case '"': ret +=
""";
break;
2641 case '\'': ret +=
"'";
break;
2642 default: ret += *ptr;
2649 #ifndef DISABLED_LEGACY_ENGINE 2677 int32_t xstarts[] = {-32000};
2678 double quad_coeffs[] = {0, 0,
baseline};
2691 int width = pixGetWidth(pix);
2692 int height = pixGetHeight(pix);
2693 BLOCK block(
"a character",
TRUE, 0, 0, 0, 0, width, height);
2700 C_BLOB_IT c_blob_it(list);
2701 if (c_blob_it.empty())
2704 C_OUTLINE_IT ol_it(c_blob_it.data()->out_list());
2705 for (c_blob_it.forward();
2706 !c_blob_it.at_first();
2707 c_blob_it.forward()) {
2708 C_BLOB *c_blob = c_blob_it.data();
2709 ol_it.add_list_after(c_blob->
out_list());
2722 float x_center = (box.
left() + box.
right()) / 2.0f;
2733 static TBLOB *make_tesseract_blob(
float baseline,
float xheight,
2734 float descender,
float ascender,
2735 bool numeric_mode, Pix* pix) {
2758 TBLOB *blob = make_tesseract_blob(
baseline, xheight, descender, ascender,
2762 float best_rating = -100;
2766 BLOB_CHOICE_LIST choices;
2768 BLOB_CHOICE_IT choice_it;
2769 choice_it.set_to_list(&choices);
2770 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2771 choice_it.forward()) {
2772 if (choice_it.data()->rating() > best_rating) {
2773 best_rating = choice_it.data()->rating();
2796 pass1_result =
new PAGE_RES(
false, block_list,
2799 return pass1_result;
2809 length = (len == -1 ? strlen(repr) : len);
2828 static void add_space(TESS_CHAR_IT* it) {
2829 TESS_CHAR *t =
new TESS_CHAR(0,
" ");
2830 it->add_after_then_move(t);
2834 static float rating_to_cost(
float rating) {
2835 rating = 100 + rating;
2839 if (rating < 0) rating = 0;
2847 static void extract_result(TESS_CHAR_IT* out,
2851 while (page_res_it.word() !=
nullptr) {
2859 int n = strlen(len);
2860 for (
int i = 0; i < n; i++) {
2864 out->add_after_then_move(tc);
2868 page_res_it.forward();
2885 TESS_CHAR_LIST tess_chars;
2886 TESS_CHAR_IT tess_chars_it(&tess_chars);
2887 extract_result(&tess_chars_it, page_res);
2888 tess_chars_it.move_to_first();
2889 int n = tess_chars.length();
2891 *lengths =
new int[n];
2892 *costs =
new float[n];
2898 for (tess_chars_it.mark_cycle_pt();
2899 !tess_chars_it.cycled_list();
2900 tess_chars_it.forward(), i++) {
2902 text_len += (*lengths)[i] = tc->
length;
2903 (*costs)[i] = tc->
cost;
2907 (*y1)[i] = tc->
box.
top();
2909 char *p = *text =
new char[text_len];
2911 tess_chars_it.move_to_first();
2912 for (tess_chars_it.mark_cycle_pt();
2913 !tess_chars_it.cycled_list();
2914 tess_chars_it.forward()) {
2932 int* feature_outline_index) {
2938 &cn_features, &fx_info, &outline_counts);
2943 *num_features = cn_features.
size();
2944 memcpy(int_features, &cn_features[0], *num_features *
sizeof(cn_features[0]));
2946 if (feature_outline_index !=
nullptr) {
2948 for (
int i = 0; i < outline_counts.
size(); ++i) {
2949 while (f < outline_counts[i])
2950 feature_outline_index[f++] = i;
2958 int left,
int top,
int right,
int bottom) {
2959 TBOX box(left, bottom, right, top);
2960 BLOCK_IT b_it(blocks);
2961 for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
2962 BLOCK* block = b_it.data();
2966 for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward()) {
2967 ROW* row = r_it.data();
2971 for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
2972 WERD* word = w_it.data();
2983 int num_max_matches,
2986 int* num_matches_returned) {
2987 BLOB_CHOICE_LIST* choices =
new BLOB_CHOICE_LIST;
2989 BLOB_CHOICE_IT choices_it(choices);
2990 int& index = *num_matches_returned;
2992 for (choices_it.mark_cycle_pt();
2993 !choices_it.cycled_list() && index < num_max_matches;
2994 choices_it.forward()) {
2997 ratings[index] = choice->
rating();
3000 *num_matches_returned = index;
3003 #endif // ndef DISABLED_LEGACY_ENGINE
void set_unlv_suspects(WERD_RES *word)
TESS_LOCAL LTRResultIterator * GetLTRIterator()
BLOCK_RES * block() const
Pix ** mutable_pix_binary()
static DawgCache * GlobalDawgCache()
void MaximallyChopWord(const GenericVector< TBOX > &boxes, BLOCK *block, ROW *row, WERD_RES *word_res)
TESS_LOCAL int FindLines()
void ReSegmentByClassification(PAGE_RES *page_res)
void GetLoadedLanguagesAsVector(GenericVector< STRING > *langs) const
void SetOutputName(const char *name)
PageSegMode GetPageSegMode() const
TESS_LOCAL int TextLength(int *blob_count)
bool tessedit_write_images
int SegmentPage(const STRING *input_file, BLOCK_LIST *blocks, Tesseract *osd_tess, OSResults *osr)
PolyBlockType BlockType() const
void ExtractFontName(const STRING &filename, STRING *fontname)
static TBLOB * PolygonalCopy(bool allow_detailed_fx, C_BLOB *src)
void InitAdaptiveClassifier(TessdataManager *mgr)
void SetPageSegMode(PageSegMode mode)
char * GetHOCRText(ETEXT_DESC *monitor, int page_number)
int Recognize(ETEXT_DESC *monitor)
bool SetDebugVariable(const char *name, const char *value)
bool ParagraphIsLtr() const
GenericVector< IntParam * > int_params
void SetImage(const unsigned char *imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line)
GenericVector< BoolParam * > bool_params
static void PrintParams(FILE *fp, const ParamsVectors *member_params)
#define BOOL_VAR(name, val, comment)
Tesseract * tesseract() const
const char * GetInitLanguagesAsString() const
void PrepareForTessOCR(BLOCK_LIST *block_list, Tesseract *osd_tess, OSResults *osr)
static void ExtractFeatures(const TBLOB &blob, bool nonlinear_norm, GenericVector< INT_FEATURE_STRUCT > *bl_features, GenericVector< INT_FEATURE_STRUCT > *cn_features, INT_FX_RESULT_STRUCT *results, GenericVector< int > *outline_cn_counts)
void SavePixForCrash(int resolution, Pix *pix)
#define ELISTIZEH(CLASSNAME)
Assume a single uniform block of text. (Default.)
WERD_CHOICE * prev_word_best_choice_
int valid_word(const WERD_CHOICE &word, bool numbers_ok) const
bool PSM_OSD_ENABLED(int pageseg_mode)
void set_pix_original(Pix *original_pix)
Dict & getDict() override
char * GetTSVText(int page_number)
double min_orientation_margin
double(Dict::* probability_in_context_)(const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
Probability in context function used by the ngram permuter.
bool GetTextDirection(int *out_offset, float *out_slope)
TBOX intersection(const TBOX &box) const
bool BoundingBox(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
const int kBytesPerNumber
STRING HOcrEscape(const char *text)
void * cancel_this
monitor-aware progress callback
bool GetBoolVariable(const char *name, bool *value) const
const char * get_script_from_script_id(int id) const
const char * string() const
bool LoadMemBuffer(const char *name, const char *data, int size)
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
ImageThresholder * thresholder_
Image thresholding module.
int InitLangMod(const char *datapath, const char *language)
TBOX bounding_box() const
static bool SetParam(const char *name, const char *value, SetParamConstraint constraint, ParamsVectors *member_params)
float base_line(float xpos) const
bool classify_bln_numeric_mode
int init_tesseract_lm(const char *arg0, const char *textbase, const char *language, TessdataManager *mgr)
virtual void Clear()
Destroy the Pix if there is one, freeing memory.
ROW_LIST * row_list()
get rows
Pix * pix_original() const
static void ResetToDefaults(ParamsVectors *member_params)
TESS_LOCAL void DetectParagraphs(bool after_text_recognition)
BLOCK_LIST * block_list_
The page layout.
void RunAdaptiveClassifier(TBLOB *blob, int num_max_matches, int *unichar_ids, float *ratings, int *num_matches_returned)
GenericVector< StringParam * > string_params
Tesseract * osd_tesseract_
For orientation & script detection.
bool tessedit_resegment_from_boxes
void ApplyBoxTraining(const STRING &fontname, PAGE_RES *page_res)
virtual Pix * GetPixRectGrey()
void set_pix_grey(Pix *grey_pix)
TESS_LOCAL bool InternalSetImage()
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
float angle() const
find angle
void GetFeaturesForBlob(TBLOB *blob, INT_FEATURE_STRUCT *int_features, int *num_features, int *feature_outline_index)
C_BLOB_LIST * blob_list()
get blobs
virtual char * GetUTF8Text(PageIteratorLevel level) const
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
BLOCK_LIST * FindLinesCreateBlockList()
const int kBlnBaselineOffset
#define PERF_COUNT_START(FUNCT_NAME)
virtual Pix * GetPixRectThresholds()
void set_text(const char *new_text)
int orientation_and_script_detection(STRING &filename, OSResults *osr, tesseract::Tesseract *tess)
void SetFillLatticeFunc(FillLatticeFunc f)
virtual TESS_LOCAL bool Threshold(Pix **pix)
bool IsEmpty() const
Return true if no image has been set.
void SetImage(const unsigned char *imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line)
const char * WordRecognitionLanguage() const
const char * string() const
bool tessedit_resegment_from_line_boxes
bool tessedit_make_boxes_from_boxes
const TBOX & BlobBox(int index) const
void(Wordrec::* fill_lattice_)(const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
int NumDawgs() const
Return the number of dawgs in the dawgs_ vector.
const char * GetStringVariable(const char *name) const
const int kBytesPer64BitNumber
TESS_LOCAL PAGE_RES * RecognitionPass2(BLOCK_LIST *block_list, PAGE_RES *pass1_result)
static ROW * FindRowForBox(BLOCK_LIST *blocks, int left, int top, int right, int bottom)
char * GetBoxText(int page_number)
int GetScaleFactor() const
Pix * GetThresholdedImage()
void InitForAnalysePage()
int(Dict::* DictFunc)(void *void_dawg_args, const UNICHARSET &unicharset, UNICHAR_ID unichar_id, bool word_end) const
bool BeginDocument(const char *title)
Boxa * GetConnectedComponents(Pixa **cc)
virtual std::vector< std::vector< std::pair< const char *, float > > > * GetBestLSTMSymbolChoices() const
bool GetVariableAsString(const char *name, STRING *val)
const char * GetDatapath()
const char kTesseractReject
const char * GetUnichar(int unichar_id)
int GetScaledYResolution() const
bool interactive_display_mode
const char * c_str() const
WERD_RES * restart_page()
void SetEquationDetect(EquationDetect *detector)
int init_tesseract(const char *arg0, const char *textbase, const char *language, OcrEngineMode oem, char **configs, int configs_size, const GenericVector< STRING > *vars_vec, const GenericVector< STRING > *vars_values, bool set_only_init_params, TessdataManager *mgr)
const char * WordFontAttributes(bool *is_bold, bool *is_italic, bool *is_underlined, bool *is_monospace, bool *is_serif, bool *is_smallcaps, int *pointsize, int *font_id) const
void SetProbabilityInContextFunc(ProbabilityInContextFunc f)
void ReadDebugConfigFile(const char *filename)
void SetInputImage(Pix *pix)
void split(const char c, GenericVector< STRING > *splited)
void TrainLineRecognizer(const STRING &input_imagename, const STRING &output_basename, BLOCK_LIST *block_list)
const Dawg * GetDawg(int i) const
static void NormalizeTBLOB(TBLOB *tblob, ROW *row, bool numeric_mode)
PAGE_RES * SetupApplyBoxes(const GenericVector< TBOX > &boxes, BLOCK_LIST *block_list)
Tesseract * tesseract_
The underlying data object.
GenericVector< ParagraphModel * > * paragraph_models_
bool flag(WERD_FLAGS mask) const
const STRING & unichar_lengths() const
bool AdaptToWordStr(PageSegMode mode, const char *wordstr)
const Dawg * GetDawg(int index) const
Return i-th dawg pointer recorded in the dawgs_ vector.
static bool GetParamAsString(const char *name, const ParamsVectors *member_params, STRING *value)
StrongScriptDirection WordDirection() const
tesseract::ParamsVectors * GlobalParams()
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, const bool raw_image, const int raw_padding, Pixa **pixa, int **blockids, int **paraids)
bool ProcessPages(const char *filename, const char *retry_config, int timeout_millisec, TessResultRenderer *renderer)
bool GetDoubleVariable(const char *name, double *value) const
void chomp_string(char *str)
void PrintVariables(FILE *fp) const
int RecognizeForChopTest(ETEXT_DESC *monitor)
CRUNCH_MODE unlv_crunch_mode
bool tessedit_ambigs_training
int GetThresholdedImageScaleFactor() const
static void ClearPersistentCache()
static void CatchSignals()
TruthCallback * truth_cb_
void Normalize(const BLOCK *block, const FCOORD *rotation, const DENORM *predecessor, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift, bool inverse, Pix *pix)
void ResetAdaptiveClassifier()
bool AddImage(TessBaseAPI *api)
bool tessedit_train_from_boxes
bool contains_unichar(const char *const unichar_repr) const
char * TesseractRect(const unsigned char *imagedata, int bytes_per_pixel, int bytes_per_line, int left, int top, int width, int height)
bool major_overlap(const TBOX &box) const
void pgeditor_main(int width, int height, PAGE_RES *page_res)
double matcher_good_threshold
void add_str_double(const char *str, double number)
PAGE_RES * ApplyBoxes(const STRING &fname, bool find_segmentation, BLOCK_LIST *block_list)
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
static ResultIterator * StartOfParagraph(const LTRResultIterator &resit)
#define MAX_NUM_INT_FEATURES
bool textord_equation_detect
int IntCastRounded(double x)
void set_pix_thresholds(Pix *thresholds)
bool DetectOS(OSResults *)
int GetScaledEstimatedResolution() const
#define ELISTIZE(CLASSNAME)
void BestChoiceToCorrectText()
bool Baseline(PageIteratorLevel level, int *x1, int *y1, int *x2, int *y2) const
bool GetIntVariable(const char *name, int *value) const
void SetSourceYResolution(int ppi)
Boxa * GetStrips(Pixa **pixa, int **blockids)
TBOX bounding_box() const
STRING * datapath_
Current location of tessdata.
TESS_LOCAL void AdaptToCharacter(const char *unichar_repr, int length, float baseline, float xheight, float descender, float ascender)
bool recognition_done_
page_res_ contains recognition data.
void SetSourceResolution(int ppi)
ADAPT_TEMPLATES AdaptedTemplates
DLLSYM void tprintf(const char *format,...)
TBOX bounding_box() const
bool ProcessPage(Pix *pix, int page_index, const char *filename, const char *retry_config, int timeout_millisec, TessResultRenderer *renderer)
TESS_CHAR(float _cost, const char *repr, int len=-1)
void set_min_orientation_margin(double margin)
void GetAvailableLanguagesAsVector(GenericVector< STRING > *langs) const
void ResetDocumentDictionary()
bool(* FileReader)(const STRING &filename, GenericVector< char > *data)
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
int GetSourceYResolution()
void SetRectangle(int left, int top, int width, int height)
FILE * init_recog_training(const STRING &fname)
virtual bool IsAtFinalElement(PageIteratorLevel level, PageIteratorLevel element) const
void set_source_resolution(int ppi)
void TidyUp(PAGE_RES *page_res)
void GetBlockTextOrientations(int **block_orientation, bool **vertical_writing)
void ReadConfigFile(const char *filename)
int GetSourceYResolution() const
void add_str_int(const char *str, int number)
GenericVector< DoubleParam * > double_params
bool IsBinary() const
Returns true if the source image is binary.
void SetRectangle(int left, int top, int width, int height)
static TBLOB * MakeTBLOB(Pix *pix)
PAGE_RES * page_res_
The page-level data.
EquationDetect * equ_detect_
The equation detector.
Automatic page segmentation, but no OSD, or OCR.
static void DeleteBlockList(BLOCK_LIST *block_list)
void signal_exit(int signal_code)
static size_t getOpenCLDevice(void **device)
bool IsValidCharacter(const char *utf8_character)
virtual bool IsAtBeginningOf(PageIteratorLevel level) const
float Confidence(PageIteratorLevel level) const
Tesseract * get_sub_lang(int index) const
PageIterator * AnalyseLayout()
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel *> *models)
STRING * language_
Last initialized language.
static TESS_LOCAL int TesseractExtractResult(char **text, int **lengths, float **costs, int **x0, int **y0, int **x1, int **y1, PAGE_RES *page_res)
OcrEngineMode oem() const
virtual bool Next(PageIteratorLevel level)
int tessedit_pageseg_mode
C_OUTLINE_LIST * out_list()
const char * id_to_unichar(UNICHAR_ID id) const
void delete_data_pointers()
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
CANCEL_FUNC cancel
for errcode use
bool PTIsTextType(PolyBlockType type)
const char * kOldVarsFile
bool WriteTRFile(const STRING &filename)
const UNICHARSET & getUnicharset() const
struct TessResultRenderer TessResultRenderer
Pix * GetBinaryImage(PageIteratorLevel level) const
const STRING & unichar_string() const
const int kMaxBytesPerLine
Boxa * GetTextlines(const bool raw_image, const int raw_padding, Pixa **pixa, int **blockids, int **paraids)
MutableIterator * GetMutableIterator()
STRING * output_file_
Name used by debug code.
void SetInputName(const char *name)
bool tessedit_train_line_recognizer
double(Dict::* ProbabilityInContextFunc)(const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
void SetBlackAndWhitelist()
static const char * Version()
bool Empty(PageIteratorLevel level) const
void ClearAdaptiveClassifier()
static ROW * MakeTessOCRRow(float baseline, float xheight, float descender, float ascender)
virtual bool Next(PageIteratorLevel level)
int OrientationIdToValue(const int &id)
const char * GetInputName()
Orientation and script detection only.
STRING * input_file_
Name used by training code.
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Boxa * GetRegions(Pixa **pixa)
void read_config_file(const char *filename, SetParamConstraint constraint)
int IsValidWord(const char *word)
virtual void Run(A1, A2, A3, A4)=0
void Orientation(tesseract::Orientation *orientation, tesseract::WritingDirection *writing_direction, tesseract::TextlineOrder *textline_order, float *deskew_angle) const
void CorrectClassifyWords(PAGE_RES *page_res)
TESS_API int get_best_script(int orientation_id) const
virtual bool IsAtFinalElement(PageIteratorLevel level, PageIteratorLevel element) const
bool BoundingBoxInternal(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, float Threshold, ADAPT_TEMPLATES adaptive_templates)
int * AllWordConfidences()
void recog_training_segmented(const STRING &fname, PAGE_RES *page_res, volatile ETEXT_DESC *monitor, FILE *output_file)
int Init(const char *datapath, const char *language, OcrEngineMode mode, char **configs, int configs_size, const GenericVector< STRING > *vars_vec, const GenericVector< STRING > *vars_values, bool set_only_non_debug_params)
constexpr int kMinCredibleResolution
#define PERF_COUNT_SUB(SUB)
void set_deadline_msecs(int32_t deadline_msecs)
void extract_edges(Pix *pix, BLOCK *block)
Boxa * GetWords(Pixa **pixa)
void SetDictFunc(DictFunc f)
UNICHAR_ID unichar_id() const
TESS_LOCAL PAGE_RES * RecognitionPass1(BLOCK_LIST *block_list)
const int kNumbersPerBlob
WERD_CHOICE * best_choice
char * GetOsdText(int page_number)
virtual void GetImageSizes(int *left, int *top, int *width, int *height, int *imagewidth, int *imageheight)
constexpr int kMaxCredibleResolution
tesseract::BoxWord * box_word
bool DetectOrientationScript(int *orient_deg, float *orient_conf, const char **script_name, float *script_conf)
void LearnWord(const char *fontname, WERD_RES *word)
int num_sub_langs() const
ResultIterator * GetIterator()
int(Dict::* letter_is_okay_)(void *void_dawg_args, const UNICHARSET &unicharset, UNICHAR_ID unichar_id, bool word_end) const
bool SetVariable(const char *name, const char *value)
void(Wordrec::* FillLatticeFunc)(const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
bool ProcessPagesInternal(const char *filename, const char *retry_config, int timeout_millisec, TessResultRenderer *renderer)
void assign(const char *cstr, int len)
virtual bool ThresholdToPix(PageSegMode pageseg_mode, Pix **pix)
Returns false on error.
FileReader reader_
Reads files from any filesystem.
char * GetUTF8Text(PageIteratorLevel level) const
const int kBytesPerBoxFileLine
Pix * GetImage(PageIteratorLevel level, int padding, Pix *original_img, int *left, int *top) const