tesseract  4.0.0-1-g2a2b
capi.cpp
Go to the documentation of this file.
1 // File: capi.cpp
3 // Description: C-API TessBaseAPI
4 //
5 // (C) Copyright 2012, Google Inc.
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
17 
18 #ifndef TESS_CAPI_INCLUDE_BASEAPI
19 # define TESS_CAPI_INCLUDE_BASEAPI
20 #endif
21 #include "capi.h"
22 #include "genericvector.h"
23 #include "strngs.h"
24 
26 {
27  return TessBaseAPI::Version();
28 }
29 
31 {
32  delete [] text;
33 }
34 
36 {
37  for (char** pos = arr; *pos != nullptr; ++pos)
38  delete [] *pos;
39  delete [] arr;
40 }
41 
43 {
44  delete [] arr;
45 }
46 
47 #ifndef DISABLED_LEGACY_ENGINE
48 TESS_API void TESS_CALL TessDeleteBlockList(BLOCK_LIST* block_list)
49 {
50  TessBaseAPI::DeleteBlockList(block_list);
51 }
52 #endif
53 
55 {
56  return new TessTextRenderer(outputbase);
57 }
58 
60 {
61  return new TessHOcrRenderer(outputbase);
62 }
63 
65 {
66  return new TessHOcrRenderer(outputbase, font_info);
67 }
68 
69 TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir,
70  BOOL textonly)
71 {
72  return new TessPDFRenderer(outputbase, datadir, textonly);
73 }
74 
76 {
77  return new TessUnlvRenderer(outputbase);
78 }
79 
81 {
82  return new TessBoxTextRenderer(outputbase);
83 }
84 
86 {
87  delete renderer;
88 }
89 
91 {
92  renderer->insert(next);
93 }
94 
96 {
97  return renderer->next();
98 }
99 
101 {
102  return renderer->BeginDocument(title);
103 }
104 
106 {
107  return renderer->AddImage(api);
108 }
109 
111 {
112  return renderer->EndDocument();
113 }
114 
116 {
117  return renderer->file_extension();
118 }
119 
121 {
122  return renderer->title();
123 }
124 
126 {
127  return renderer->imagenum();
128 }
129 
131 {
132  return new TessBaseAPI;
133 }
134 
136 {
137  delete handle;
138 }
139 
141 {
142  return handle->getOpenCLDevice(device);
143 }
144 
145 TESS_API void TESS_CALL TessBaseAPISetInputName(TessBaseAPI* handle, const char* name)
146 {
147  handle->SetInputName(name);
148 }
149 
151 {
152  return handle->GetInputName();
153 }
154 
156 {
157  handle->SetInputImage(pix);
158 }
159 
161 {
162  return handle->GetInputImage();
163 }
164 
166 {
167  return handle->GetSourceYResolution();
168 }
169 
171 {
172  return handle->GetDatapath();
173 }
174 
176 {
177  handle->SetOutputName(name);
178 }
179 
180 TESS_API BOOL TESS_CALL TessBaseAPISetVariable(TessBaseAPI* handle, const char* name, const char* value)
181 {
182  return handle->SetVariable(name, value) ? TRUE : FALSE;
183 }
184 
185 TESS_API BOOL TESS_CALL TessBaseAPISetDebugVariable(TessBaseAPI* handle, const char* name, const char* value)
186 {
187  return handle->SetVariable(name, value) ? TRUE : FALSE;
188 }
189 
190 TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable(const TessBaseAPI* handle, const char* name, int* value)
191 {
192  return handle->GetIntVariable(name, value) ? TRUE : FALSE;
193 }
194 
195 TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable(const TessBaseAPI* handle, const char* name, BOOL* value)
196 {
197  bool boolValue;
198  if (handle->GetBoolVariable(name, &boolValue))
199  {
200  *value = boolValue ? TRUE : FALSE;
201  return TRUE;
202  }
203  else
204  {
205  return FALSE;
206  }
207 }
208 
209 TESS_API BOOL TESS_CALL TessBaseAPIGetDoubleVariable(const TessBaseAPI* handle, const char* name, double* value)
210 {
211  return handle->GetDoubleVariable(name, value) ? TRUE : FALSE;
212 }
213 
214 TESS_API const char* TESS_CALL TessBaseAPIGetStringVariable(const TessBaseAPI* handle, const char* name)
215 {
216  return handle->GetStringVariable(name);
217 }
218 
220 {
221  handle->PrintVariables(fp);
222 }
223 
225 {
226  FILE* fp = fopen(filename, "w");
227  if (fp != nullptr)
228  {
229  handle->PrintVariables(fp);
230  fclose(fp);
231  return TRUE;
232  }
233  return FALSE;
234 }
235 
237 {
238  return handle->GetVariableAsString(name, val) ? TRUE : FALSE;
239 }
240 
241 TESS_API int TESS_CALL TessBaseAPIInit4(TessBaseAPI* handle, const char* datapath, const char* language,
242  TessOcrEngineMode mode, char** configs, int configs_size,
243  char** vars_vec, char** vars_values, size_t vars_vec_size,
244  BOOL set_only_non_debug_params)
245 {
246  GenericVector<STRING> varNames;
247  GenericVector<STRING> varValues;
248  if (vars_vec != nullptr && vars_values != nullptr) {
249  for (size_t i = 0; i < vars_vec_size; i++) {
250  varNames.push_back(STRING(vars_vec[i]));
251  varValues.push_back(STRING(vars_values[i]));
252  }
253  }
254 
255  return handle->Init(datapath, language, mode, configs, configs_size, &varNames, &varValues, set_only_non_debug_params);
256 }
257 
258 
259 TESS_API int TESS_CALL TessBaseAPIInit1(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode oem,
260  char** configs, int configs_size)
261 {
262  return handle->Init(datapath, language, oem, configs, configs_size, nullptr, nullptr, false);
263 }
264 
265 TESS_API int TESS_CALL TessBaseAPIInit2(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode oem)
266 {
267  return handle->Init(datapath, language, oem);
268 }
269 
270 TESS_API int TESS_CALL TessBaseAPIInit3(TessBaseAPI* handle, const char* datapath, const char* language)
271 {
272  return handle->Init(datapath, language);
273 }
274 
276 {
277  return handle->GetInitLanguagesAsString();
278 }
279 
281 {
282  GenericVector<STRING> languages;
283  handle->GetLoadedLanguagesAsVector(&languages);
284  char** arr = new char*[languages.size() + 1];
285  for (int index = 0; index < languages.size(); ++index)
286  arr[index] = languages[index].strdup();
287  arr[languages.size()] = nullptr;
288  return arr;
289 }
290 
292 {
293  GenericVector<STRING> languages;
294  handle->GetAvailableLanguagesAsVector(&languages);
295  char** arr = new char*[languages.size() + 1];
296  for (int index = 0; index < languages.size(); ++index)
297  arr[index] = languages[index].strdup();
298  arr[languages.size()] = nullptr;
299  return arr;
300 }
301 
302 #ifndef DISABLED_LEGACY_ENGINE
303 TESS_API int TESS_CALL TessBaseAPIInitLangMod(TessBaseAPI* handle, const char* datapath, const char* language)
304 {
305  return handle->InitLangMod(datapath, language);
306 }
307 #endif
308 
310 {
311  handle->InitForAnalysePage();
312 }
313 
314 TESS_API void TESS_CALL TessBaseAPIReadConfigFile(TessBaseAPI* handle, const char* filename)
315 {
316  handle->ReadConfigFile(filename);
317 }
318 
320 {
321  handle->ReadDebugConfigFile(filename);
322 }
323 
325 {
326  handle->SetPageSegMode(mode);
327 }
328 
330 {
331  return handle->GetPageSegMode();
332 }
333 
334 TESS_API char* TESS_CALL TessBaseAPIRect(TessBaseAPI* handle, const unsigned char* imagedata,
335  int bytes_per_pixel, int bytes_per_line,
336  int left, int top, int width, int height)
337 {
338  return handle->TesseractRect(imagedata, bytes_per_pixel, bytes_per_line, left, top, width, height);
339 }
340 
341 #ifndef DISABLED_LEGACY_ENGINE
343 {
344  handle->ClearAdaptiveClassifier();
345 }
346 #endif
347 
348 TESS_API void TESS_CALL TessBaseAPISetImage(TessBaseAPI* handle, const unsigned char* imagedata, int width, int height,
349  int bytes_per_pixel, int bytes_per_line)
350 {
351  handle->SetImage(imagedata, width, height, bytes_per_pixel, bytes_per_line);
352 }
353 
354 TESS_API void TESS_CALL TessBaseAPISetImage2(TessBaseAPI* handle, struct Pix* pix)
355 {
356  return handle->SetImage(pix);
357 }
358 
360 {
361  handle->SetSourceResolution(ppi);
362 }
363 
364 TESS_API void TESS_CALL TessBaseAPISetRectangle(TessBaseAPI* handle, int left, int top, int width, int height)
365 {
366  handle->SetRectangle(left, top, width, height);
367 }
368 
369 TESS_API void TESS_CALL TessBaseAPISetThresholder(TessBaseAPI* handle, TessImageThresholder* thresholder)
370 {
371  handle->SetThresholder(thresholder);
372 }
373 
375 {
376  return handle->GetThresholdedImage();
377 }
378 
379 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetRegions(TessBaseAPI* handle, struct Pixa** pixa)
380 {
381  return handle->GetRegions(pixa);
382 }
383 
384 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetTextlines(TessBaseAPI* handle, struct Pixa** pixa, int** blockids)
385 {
386  return handle->GetTextlines(pixa, blockids);
387 }
388 
389 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetTextlines1(TessBaseAPI* handle, const BOOL raw_image, const int raw_padding,
390  struct Pixa** pixa, int** blockids, int** paraids)
391 {
392  return handle->GetTextlines(raw_image, raw_padding, pixa, blockids, paraids);
393 }
394 
395 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetStrips(TessBaseAPI* handle, struct Pixa** pixa, int** blockids)
396 {
397  return handle->GetStrips(pixa, blockids);
398 }
399 
400 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetWords(TessBaseAPI* handle, struct Pixa** pixa)
401 {
402  return handle->GetWords(pixa);
403 }
404 
405 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetConnectedComponents(TessBaseAPI* handle, struct Pixa** cc)
406 {
407  return handle->GetConnectedComponents(cc);
408 }
409 
410 TESS_API struct Boxa* TESS_CALL TessBaseAPIGetComponentImages(TessBaseAPI* handle, TessPageIteratorLevel level, BOOL text_only, struct Pixa** pixa, int** blockids)
411 {
412  return handle->GetComponentImages(level, text_only != FALSE, pixa, blockids);
413 }
414 
415 TESS_API struct Boxa*
417  const BOOL raw_image, const int raw_padding,
418  struct Pixa** pixa, int** blockids, int** paraids)
419 {
420  return handle->GetComponentImages(level, text_only != FALSE, raw_image, raw_padding, pixa, blockids, paraids);
421 }
422 
424 {
425  return handle->GetThresholdedImageScaleFactor();
426 }
427 
429 {
430  return handle->AnalyseLayout();
431 }
432 
434 {
435  return handle->Recognize(monitor);
436 }
437 
438 #ifndef DISABLED_LEGACY_ENGINE
440 {
441  return handle->RecognizeForChopTest(monitor);
442 }
443 #endif
444 
445 TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle, const char* filename, const char* retry_config,
446  int timeout_millisec, TessResultRenderer* renderer)
447 {
448  if (handle->ProcessPages(filename, retry_config, timeout_millisec, renderer))
449  return TRUE;
450  else
451  return FALSE;
452 }
453 
454 TESS_API BOOL TESS_CALL TessBaseAPIProcessPage(TessBaseAPI* handle, struct Pix* pix, int page_index, const char* filename,
455  const char* retry_config, int timeout_millisec, TessResultRenderer* renderer)
456 {
457  if (handle->ProcessPage(pix, page_index, filename, retry_config, timeout_millisec, renderer))
458  return TRUE;
459  else
460  return FALSE;
461 }
462 
464 {
465  return handle->GetIterator();
466 }
467 
469 {
470  return handle->GetMutableIterator();
471 }
472 
474 {
475  return handle->GetUTF8Text();
476 }
477 
478 TESS_API char* TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI* handle, int page_number)
479 {
480  return handle->GetHOCRText(nullptr, page_number);
481 }
482 
483 TESS_API char* TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI* handle, int page_number)
484 {
485  return handle->GetBoxText(page_number);
486 }
487 
489 {
490  return handle->GetUNLVText();
491 }
492 
494 {
495  return handle->MeanTextConf();
496 }
497 
499 {
500  return handle->AllWordConfidences();
501 }
502 
503 #ifndef DISABLED_LEGACY_ENGINE
505 {
506  return handle->AdaptToWordStr(mode, wordstr) ? TRUE : FALSE;
507 }
508 #endif
509 
511 {
512  handle->Clear();
513 }
514 
516 {
517  handle->End();
518 }
519 
520 TESS_API int TESS_CALL TessBaseAPIIsValidWord(TessBaseAPI* handle, const char* word)
521 {
522  return handle->IsValidWord(word);
523 }
524 
525 TESS_API BOOL TESS_CALL TessBaseAPIGetTextDirection(TessBaseAPI* handle, int* out_offset, float* out_slope)
526 {
527  return handle->GetTextDirection(out_offset, out_slope) ? TRUE : FALSE;
528 }
529 
531 {
532  handle->SetDictFunc(f);
533 }
534 
536 {
537  handle->ClearPersistentCache();
538 }
539 
540 TESS_API void TESS_CALL TessBaseAPISetProbabilityInContextFunc(TessBaseAPI* handle, TessProbabilityInContextFunc f)
541 {
542  handle->SetProbabilityInContextFunc(f);
543 }
544 
545 #ifndef DISABLED_LEGACY_ENGINE
546 
548  int* orient_deg, float* orient_conf, const char** script_name, float* script_conf)
549 {
550  bool success;
551  success = handle->DetectOrientationScript(orient_deg, orient_conf, script_name, script_conf);
552  return (BOOL)success;
553 }
554 
556  int* num_features, int* FeatureOutlineIndex)
557 {
558  handle->GetFeaturesForBlob(blob, int_features, num_features, FeatureOutlineIndex);
559 }
560 
561 TESS_API ROW* TESS_CALL TessFindRowForBox(BLOCK_LIST* blocks, int left, int top, int right, int bottom)
562 {
563  return TessBaseAPI::FindRowForBox(blocks, left, top, right, bottom);
564 }
565 
566 TESS_API void TESS_CALL TessBaseAPIRunAdaptiveClassifier(TessBaseAPI* handle, TBLOB* blob, int num_max_matches,
567  int* unichar_ids, float* ratings, int* num_matches_returned)
568 {
569  handle->RunAdaptiveClassifier(blob, num_max_matches, unichar_ids, ratings, num_matches_returned);
570 }
571 
572 #endif // ndef DISABLED_LEGACY_ENGINE
573 
574 TESS_API const char* TESS_CALL TessBaseAPIGetUnichar(TessBaseAPI* handle, int unichar_id)
575 {
576  return handle->GetUnichar(unichar_id);
577 }
578 
579 TESS_API const TessDawg* TESS_CALL TessBaseAPIGetDawg(const TessBaseAPI* handle, int i)
580 {
581  return handle->GetDawg(i);
582 }
583 
585 {
586  return handle->NumDawgs();
587 }
588 
589 #ifndef DISABLED_LEGACY_ENGINE
590 TESS_API ROW* TESS_CALL TessMakeTessOCRRow(float baseline, float xheight, float descender, float ascender)
591 {
592  return TessBaseAPI::MakeTessOCRRow(baseline, xheight, descender, ascender);
593 }
594 
596 {
597  return TessBaseAPI::MakeTBLOB(pix);
598 }
599 
600 TESS_API void TESS_CALL TessNormalizeTBLOB(TBLOB* tblob, ROW* row, BOOL numeric_mode)
601 {
602  TessBaseAPI::NormalizeTBLOB(tblob, row, numeric_mode != FALSE);
603 }
604 #endif // ndef DISABLED_LEGACY_ENGINE
605 
607 {
608  return handle->oem();
609 }
610 
611 TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI* handle, TessTruthCallback* cb)
612 {
613  handle->InitTruthCallback(cb);
614 }
615 
617 {
618  handle->set_min_orientation_margin(margin);
619 }
620 
621 TESS_API void TESS_CALL TessBaseGetBlockTextOrientations(TessBaseAPI* handle, int** block_orientation, bool** vertical_writing)
622 {
623  handle->GetBlockTextOrientations(block_orientation, vertical_writing);
624 }
625 
626 #ifndef DISABLED_LEGACY_ENGINE
628 {
629  return handle->FindLinesCreateBlockList();
630 }
631 #endif
632 
634 {
635  delete handle;
636 }
637 
639 {
640  return new TessPageIterator(*handle);
641 }
642 
644 {
645  handle->Begin();
646 }
647 
649 {
650  return handle->Next(level) ? TRUE : FALSE;
651 }
652 
654 {
655  return handle->IsAtBeginningOf(level) ? TRUE : FALSE;
656 }
657 
659  TessPageIteratorLevel element)
660 {
661  return handle->IsAtFinalElement(level, element) ? TRUE : FALSE;
662 }
663 
665  int* left, int* top, int* right, int* bottom)
666 {
667  return handle->BoundingBox(level, left, top, right, bottom) ? TRUE : FALSE;
668 }
669 
671 {
672  return handle->BlockType();
673 }
674 
676 {
677  return handle->GetBinaryImage(level);
678 }
679 
681  struct Pix* original_image, int* left, int* top)
682 {
683  return handle->GetImage(level, padding, original_image, left, top);
684 }
685 
687  int* x1, int* y1, int* x2, int* y2)
688 {
689  return handle->Baseline(level, x1, y1, x2, y2) ? TRUE : FALSE;
690 }
691 
693  TessWritingDirection* writing_direction, TessTextlineOrder* textline_order,
694  float* deskew_angle)
695 {
696  handle->Orientation(orientation, writing_direction, textline_order, deskew_angle);
697 }
698 
700  BOOL *is_list_item, BOOL *is_crown, int *first_line_indent)
701 {
702  bool bool_is_list_item, bool_is_crown;
703  handle->ParagraphInfo(justification, &bool_is_list_item, &bool_is_crown, first_line_indent);
704  if (is_list_item)
705  *is_list_item = bool_is_list_item ? TRUE : FALSE;
706  if (is_crown)
707  *is_crown = bool_is_crown ? TRUE : FALSE;
708 }
709 
710 
712 {
713  delete handle;
714 }
715 
717 {
718  return new TessResultIterator(*handle);
719 }
720 
722 {
723  return handle;
724 }
725 
727 {
728  return handle;
729 }
730 
732 {
733  return new TessChoiceIterator(*handle);
734 }
735 
737 {
738  return handle->Next(level);
739 }
740 
742 {
743  return handle->GetUTF8Text(level);
744 }
745 
747 {
748  return handle->Confidence(level);
749 }
750 
752 {
753  return handle->WordRecognitionLanguage();
754 }
755 
756 TESS_API const char* TESS_CALL TessResultIteratorWordFontAttributes(const TessResultIterator* handle, BOOL* is_bold, BOOL* is_italic,
757  BOOL* is_underlined, BOOL* is_monospace, BOOL* is_serif,
758  BOOL* is_smallcaps, int* pointsize, int* font_id)
759 {
760  bool bool_is_bold, bool_is_italic, bool_is_underlined, bool_is_monospace, bool_is_serif, bool_is_smallcaps;
761  const char* ret = handle->WordFontAttributes(&bool_is_bold, &bool_is_italic, &bool_is_underlined, &bool_is_monospace, &bool_is_serif,
762  &bool_is_smallcaps, pointsize, font_id);
763  if (is_bold)
764  *is_bold = bool_is_bold ? TRUE : FALSE;
765  if (is_italic)
766  *is_italic = bool_is_italic ? TRUE : FALSE;
767  if (is_underlined)
768  *is_underlined = bool_is_underlined ? TRUE : FALSE;
769  if (is_monospace)
770  *is_monospace = bool_is_monospace ? TRUE : FALSE;
771  if (is_serif)
772  *is_serif = bool_is_serif ? TRUE : FALSE;
773  if (is_smallcaps)
774  *is_smallcaps = bool_is_smallcaps ? TRUE : FALSE;
775  return ret;
776 }
777 
779 {
780  return handle->WordIsFromDictionary() ? TRUE : FALSE;
781 }
782 
784 {
785  return handle->WordIsNumeric() ? TRUE : FALSE;
786 }
787 
789 {
790  return handle->SymbolIsSuperscript() ? TRUE : FALSE;
791 }
792 
794 {
795  return handle->SymbolIsSubscript() ? TRUE : FALSE;
796 }
797 
799 {
800  return handle->SymbolIsDropcap() ? TRUE : FALSE;
801 }
802 
804 {
805  delete handle;
806 }
807 
809 {
810  return handle->Next();
811 }
812 
814 {
815  return handle->GetUTF8Text();
816 }
817 
819 {
820  return handle->Confidence();
821 }
822 
824 {
825  return new ETEXT_DESC();
826 }
827 
829 {
830  delete monitor;
831 }
832 
834 {
835  monitor->cancel = cancelFunc;
836 }
837 
838 TESS_API void TESS_CALL TessMonitorSetCancelThis(ETEXT_DESC* monitor, void* cancelThis)
839 {
840  monitor->cancel_this = cancelThis;
841 }
842 
844 {
845  return monitor->cancel_this;
846 }
847 
849 {
850  monitor->progress_callback2 = progressFunc;
851 }
852 
854 {
855  return monitor->progress;
856 }
857 
859 {
860  monitor->set_deadline_msecs(deadline);
861 }
TESS_API struct Pix *TESS_CALL TessBaseAPIGetThresholdedImage(TessBaseAPI *handle)
Definition: capi.cpp:374
TESS_API void TESS_CALL TessBaseAPISetInputName(TessBaseAPI *handle, const char *name)
Definition: capi.cpp:145
#define TESS_CALL
Definition: capi.h:45
struct TessChoiceIterator TessChoiceIterator
Definition: capi.h:93
bool(* TessCancelFunc)(void *cancel_this, int words)
Definition: capi.h:109
TESS_API int TESS_CALL TessBaseAPIIsValidWord(TessBaseAPI *handle, const char *word)
Definition: capi.cpp:520
TESS_API TessPageIterator *TESS_CALL TessResultIteratorGetPageIterator(TessResultIterator *handle)
Definition: capi.cpp:721
TESS_API void TESS_CALL TessChoiceIteratorDelete(TessChoiceIterator *handle)
Definition: capi.cpp:803
TESS_API int TESS_CALL TessResultRendererImageNum(TessResultRenderer *renderer)
Definition: capi.cpp:125
TessWritingDirection
Definition: capi.h:104
TESS_API void TESS_CALL TessBaseAPISetMinOrientationMargin(TessBaseAPI *handle, double margin)
Definition: capi.cpp:616
TESS_API size_t TESS_CALL TessBaseAPIGetOpenCLDevice(TessBaseAPI *handle, void **device)
Definition: capi.cpp:140
TESS_API void TESS_CALL TessBaseAPISetThresholder(TessBaseAPI *handle, TessImageThresholder *thresholder)
Definition: capi.cpp:369
TESS_API void TESS_CALL TessPageIteratorBegin(TessPageIterator *handle)
Definition: capi.cpp:643
TESS_API BOOL TESS_CALL TessBaseAPIDetectOrientationScript(TessBaseAPI *handle, int *orient_deg, float *orient_conf, const char **script_name, float *script_conf)
Definition: capi.cpp:547
int size() const
Definition: genericvector.h:71
TESS_API char **TESS_CALL TessBaseAPIGetLoadedLanguagesAsVector(const TessBaseAPI *handle)
Definition: capi.cpp:280
TESS_API int TESS_CALL TessBaseAPIGetThresholdedImageScaleFactor(const TessBaseAPI *handle)
Definition: capi.cpp:423
TESS_API void TESS_CALL TessDeleteText(char *text)
Definition: capi.cpp:30
TESS_API BOOL TESS_CALL TessPageIteratorBaseline(const TessPageIterator *handle, TessPageIteratorLevel level, int *x1, int *y1, int *x2, int *y2)
Definition: capi.cpp:686
TESS_API TessResultRenderer *TESS_CALL TessPDFRendererCreate(const char *outputbase, const char *datadir, BOOL textonly)
Definition: capi.cpp:69
TessParagraphJustification
Definition: capi.h:103
struct TessUnlvRenderer TessUnlvRenderer
Definition: capi.h:87
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetRegions(TessBaseAPI *handle, struct Pixa **pixa)
Definition: capi.cpp:379
#define TRUE
Definition: capi.h:51
TessPageSegMode
Definition: capi.h:95
TESS_API const char *TESS_CALL TessBaseAPIGetUnichar(TessBaseAPI *handle, int unichar_id)
Definition: capi.cpp:574
#define TESS_API
Definition: platform.h:74
struct TessPDFRenderer TessPDFRenderer
Definition: capi.h:86
TESS_API void TESS_CALL TessBaseAPIClearPersistentCache(TessBaseAPI *handle)
Definition: capi.cpp:535
TESS_API BOOL TESS_CALL TessBaseAPIPrintVariablesToFile(const TessBaseAPI *handle, const char *filename)
Definition: capi.cpp:224
TESS_API const char *TESS_CALL TessResultIteratorWordFontAttributes(const TessResultIterator *handle, BOOL *is_bold, BOOL *is_italic, BOOL *is_underlined, BOOL *is_monospace, BOOL *is_serif, BOOL *is_smallcaps, int *pointsize, int *font_id)
Definition: capi.cpp:756
TESS_API void TESS_CALL TessBaseAPISetDictFunc(TessBaseAPI *handle, TessDictFunc f)
Definition: capi.cpp:530
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetComponentImages1(TessBaseAPI *handle, const TessPageIteratorLevel level, const BOOL text_only, const BOOL raw_image, const int raw_padding, struct Pixa **pixa, int **blockids, int **paraids)
Definition: capi.cpp:416
void * cancel_this
monitor-aware progress callback
Definition: ocrclass.h:132
TESS_API int TESS_CALL TessMonitorGetProgress(ETEXT_DESC *monitor)
Definition: capi.cpp:853
TESS_API void TESS_CALL TessMonitorDelete(ETEXT_DESC *monitor)
Definition: capi.cpp:828
struct TessBaseAPI TessBaseAPI
Definition: capi.h:89
TESS_API const char *TESS_CALL TessBaseAPIGetInputName(TessBaseAPI *handle)
Definition: capi.cpp:150
TESS_API BOOL TESS_CALL TessBaseAPIGetVariableAsString(TessBaseAPI *handle, const char *name, STRING *val)
Definition: capi.cpp:236
TESS_API void TESS_CALL TessBaseAPIClear(TessBaseAPI *handle)
Definition: capi.cpp:510
TESS_API char *TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI *handle, int page_number)
Definition: capi.cpp:478
TESS_API BOOL TESS_CALL TessChoiceIteratorNext(TessChoiceIterator *handle)
Definition: capi.cpp:808
struct TessTextRenderer TessTextRenderer
Definition: capi.h:84
TESS_API void TESS_CALL TessMonitorSetDeadlineMSecs(ETEXT_DESC *monitor, int deadline)
Definition: capi.cpp:858
TessPolyBlockType
Definition: capi.h:99
TESS_API char *TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI *handle)
Definition: capi.cpp:473
TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable(const TessBaseAPI *handle, const char *name, BOOL *value)
Definition: capi.cpp:195
TESS_API void TESS_CALL TessBaseAPISetSourceResolution(TessBaseAPI *handle, int ppi)
Definition: capi.cpp:359
TESS_API const char *TESS_CALL TessChoiceIteratorGetUTF8Text(const TessChoiceIterator *handle)
Definition: capi.cpp:813
TESS_API void TESS_CALL TessDeleteTextArray(char **arr)
Definition: capi.cpp:35
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetComponentImages(TessBaseAPI *handle, TessPageIteratorLevel level, BOOL text_only, struct Pixa **pixa, int **blockids)
Definition: capi.cpp:410
TESS_API BOOL TESS_CALL TessPageIteratorIsAtFinalElement(const TessPageIterator *handle, TessPageIteratorLevel level, TessPageIteratorLevel element)
Definition: capi.cpp:658
TESS_API void TESS_CALL TessBaseAPIRunAdaptiveClassifier(TessBaseAPI *handle, TBLOB *blob, int num_max_matches, int *unichar_ids, float *ratings, int *num_matches_returned)
Definition: capi.cpp:566
TESS_API float TESS_CALL TessChoiceIteratorConfidence(const TessChoiceIterator *handle)
Definition: capi.cpp:818
TESS_API const TessDawg *TESS_CALL TessBaseAPIGetDawg(const TessBaseAPI *handle, int i)
Definition: capi.cpp:579
TESS_API BOOL TESS_CALL TessBaseAPIAdaptToWordStr(TessBaseAPI *handle, TessPageSegMode mode, const char *wordstr)
Definition: capi.cpp:504
TESS_API void TESS_CALL TessBaseAPISetRectangle(TessBaseAPI *handle, int left, int top, int width, int height)
Definition: capi.cpp:364
TESS_API char *TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI *handle, int page_number)
Definition: capi.cpp:483
TESS_API BOOL TESS_CALL TessBaseAPISetVariable(TessBaseAPI *handle, const char *name, const char *value)
Definition: capi.cpp:180
TESS_API TessResultRenderer *TESS_CALL TessUnlvRendererCreate(const char *outputbase)
Definition: capi.cpp:75
TessPageIteratorLevel
Definition: capi.h:98
TESS_API BOOL TESS_CALL TessBaseAPISetDebugVariable(TessBaseAPI *handle, const char *name, const char *value)
Definition: capi.cpp:185
TESS_API char *TESS_CALL TessResultIteratorGetUTF8Text(const TessResultIterator *handle, TessPageIteratorLevel level)
Definition: capi.cpp:741
TESS_API TessPolyBlockType TESS_CALL TessPageIteratorBlockType(const TessPageIterator *handle)
Definition: capi.cpp:670
bool(* TessProgressFunc)(ETEXT_DESC *ths, int left, int right, int top, int bottom)
Definition: capi.h:110
TESS_API void TESS_CALL TessNormalizeTBLOB(TBLOB *tblob, ROW *row, BOOL numeric_mode)
Definition: capi.cpp:600
TESS_API Pix *TESS_CALL TessBaseAPIGetInputImage(TessBaseAPI *handle)
Definition: capi.cpp:160
TESS_API void TESS_CALL TessPageIteratorDelete(TessPageIterator *handle)
Definition: capi.cpp:633
#define BOOL
Definition: capi.h:50
TESS_API TessResultRenderer *TESS_CALL TessBoxTextRendererCreate(const char *outputbase)
Definition: capi.cpp:80
TESS_API TessResultRenderer *TESS_CALL TessTextRendererCreate(const char *outputbase)
Definition: capi.cpp:54
TESS_API TessChoiceIterator *TESS_CALL TessResultIteratorGetChoiceIterator(const TessResultIterator *handle)
Definition: capi.cpp:731
TESS_API void TESS_CALL TessBaseAPIInitForAnalysePage(TessBaseAPI *handle)
Definition: capi.cpp:309
TESS_API int TESS_CALL TessBaseAPIInit4(TessBaseAPI *handle, const char *datapath, const char *language, TessOcrEngineMode mode, char **configs, int configs_size, char **vars_vec, char **vars_values, size_t vars_vec_size, BOOL set_only_non_debug_params)
Definition: capi.cpp:241
struct ETEXT_DESC ETEXT_DESC
Definition: capi.h:106
TESS_API BOOL TESS_CALL TessPageIteratorIsAtBeginningOf(const TessPageIterator *handle, TessPageIteratorLevel level)
Definition: capi.cpp:653
TESS_API void TESS_CALL TessBaseAPISetImage2(TessBaseAPI *handle, struct Pix *pix)
Definition: capi.cpp:354
TESS_API int TESS_CALL TessBaseAPIInit3(TessBaseAPI *handle, const char *datapath, const char *language)
Definition: capi.cpp:270
TESS_API void TESS_CALL TessBaseAPISetOutputName(TessBaseAPI *handle, const char *name)
Definition: capi.cpp:175
TESS_API BOOL TESS_CALL TessPageIteratorBoundingBox(const TessPageIterator *handle, TessPageIteratorLevel level, int *left, int *top, int *right, int *bottom)
Definition: capi.cpp:664
TESS_API TessOcrEngineMode TESS_CALL TessBaseAPIOem(const TessBaseAPI *handle)
Definition: capi.cpp:606
TESS_API void TESS_CALL TessBaseAPIReadConfigFile(TessBaseAPI *handle, const char *filename)
Definition: capi.cpp:314
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetConnectedComponents(TessBaseAPI *handle, struct Pixa **cc)
Definition: capi.cpp:405
TessOrientation
Definition: capi.h:102
TESS_API TBLOB *TESS_CALL TessMakeTBLOB(struct Pix *pix)
Definition: capi.cpp:595
TessOcrEngineMode
Definition: capi.h:94
TESS_API struct Pix *TESS_CALL TessPageIteratorGetBinaryImage(const TessPageIterator *handle, TessPageIteratorLevel level)
Definition: capi.cpp:675
TESS_API BOOL TESS_CALL TessResultRendererBeginDocument(TessResultRenderer *renderer, const char *title)
Definition: capi.cpp:100
TESS_API void TESS_CALL TessBaseAPISetImage(TessBaseAPI *handle, const unsigned char *imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line)
Definition: capi.cpp:348
struct TessHOcrRenderer TessHOcrRenderer
Definition: capi.h:85
TESS_API void TESS_CALL TessBaseAPISetProbabilityInContextFunc(TessBaseAPI *handle, TessProbabilityInContextFunc f)
Definition: capi.cpp:540
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetWords(TessBaseAPI *handle, struct Pixa **pixa)
Definition: capi.cpp:400
TESS_API TessResultRenderer *TESS_CALL TessResultRendererNext(TessResultRenderer *renderer)
Definition: capi.cpp:95
TESS_API void TESS_CALL TessDeleteBlockList(BLOCK_LIST *block_list)
Definition: capi.cpp:48
TESS_API const char *TESS_CALL TessResultIteratorWordRecognitionLanguage(const TessResultIterator *handle)
Definition: capi.cpp:751
#define FALSE
Definition: capi.h:52
TESS_API int TESS_CALL TessBaseAPIGetSourceYResolution(TessBaseAPI *handle)
Definition: capi.cpp:165
TESS_API void TESS_CALL TessBaseAPIEnd(TessBaseAPI *handle)
Definition: capi.cpp:515
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetTextlines1(TessBaseAPI *handle, const BOOL raw_image, const int raw_padding, struct Pixa **pixa, int **blockids, int **paraids)
Definition: capi.cpp:389
TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable(const TessBaseAPI *handle, const char *name, int *value)
Definition: capi.cpp:190
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsSuperscript(const TessResultIterator *handle)
Definition: capi.cpp:788
TESS_API ETEXT_DESC *TESS_CALL TessMonitorCreate()
Definition: capi.cpp:823
TESS_API int TESS_CALL TessBaseAPIInitLangMod(TessBaseAPI *handle, const char *datapath, const char *language)
Definition: capi.cpp:303
TESS_API ROW *TESS_CALL TessFindRowForBox(BLOCK_LIST *blocks, int left, int top, int right, int bottom)
Definition: capi.cpp:561
TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI *handle, const char *filename, const char *retry_config, int timeout_millisec, TessResultRenderer *renderer)
Definition: capi.cpp:445
TESS_API void TESS_CALL TessBaseAPIPrintVariables(const TessBaseAPI *handle, FILE *fp)
Definition: capi.cpp:219
TESS_API const char *TESS_CALL TessBaseAPIGetDatapath(TessBaseAPI *handle)
Definition: capi.cpp:170
TESS_API int TESS_CALL TessBaseAPIInit2(TessBaseAPI *handle, const char *datapath, const char *language, TessOcrEngineMode oem)
Definition: capi.cpp:265
TESS_API BOOL TESS_CALL TessResultRendererAddImage(TessResultRenderer *renderer, TessBaseAPI *api)
Definition: capi.cpp:105
Definition: ocrrow.h:36
TESS_API void TESS_CALL TessBaseGetBlockTextOrientations(TessBaseAPI *handle, int **block_orientation, bool **vertical_writing)
Definition: capi.cpp:621
TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI *handle, TessTruthCallback *cb)
Definition: capi.cpp:611
TESS_API void TESS_CALL TessPageIteratorParagraphInfo(TessPageIterator *handle, TessParagraphJustification *justification, BOOL *is_list_item, BOOL *is_crown, int *first_line_indent)
Definition: capi.cpp:699
TESS_API BOOL TESS_CALL TessPageIteratorNext(TessPageIterator *handle, TessPageIteratorLevel level)
Definition: capi.cpp:648
TESS_API int *TESS_CALL TessBaseAPIAllWordConfidences(TessBaseAPI *handle)
Definition: capi.cpp:498
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetStrips(TessBaseAPI *handle, struct Pixa **pixa, int **blockids)
Definition: capi.cpp:395
TESS_API const char *TESS_CALL TessResultRendererTitle(TessResultRenderer *renderer)
Definition: capi.cpp:120
TESS_API BOOL TESS_CALL TessResultRendererEndDocument(TessResultRenderer *renderer)
Definition: capi.cpp:110
int push_back(T object)
TESS_API void *TESS_CALL TessMonitorGetCancelThis(ETEXT_DESC *monitor)
Definition: capi.cpp:843
TESS_API void TESS_CALL TessBaseAPISetPageSegMode(TessBaseAPI *handle, TessPageSegMode mode)
Definition: capi.cpp:324
TESS_API char *TESS_CALL TessBaseAPIGetUNLVText(TessBaseAPI *handle)
Definition: capi.cpp:488
TESS_API void TESS_CALL TessMonitorSetCancelFunc(ETEXT_DESC *monitor, TessCancelFunc cancelFunc)
Definition: capi.cpp:833
TESS_API struct Pix *TESS_CALL TessPageIteratorGetImage(const TessPageIterator *handle, TessPageIteratorLevel level, int padding, struct Pix *original_image, int *left, int *top)
Definition: capi.cpp:680
TESS_API TessResultIterator *TESS_CALL TessResultIteratorCopy(const TessResultIterator *handle)
Definition: capi.cpp:716
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsSubscript(const TessResultIterator *handle)
Definition: capi.cpp:793
TESS_API const TessPageIterator *TESS_CALL TessResultIteratorGetPageIteratorConst(const TessResultIterator *handle)
Definition: capi.cpp:726
TessTextlineOrder
Definition: capi.h:105
Definition: strngs.h:45
struct TessResultIterator TessResultIterator
Definition: capi.h:91
TESS_API void TESS_CALL TessBaseAPIGetFeaturesForBlob(TessBaseAPI *handle, TBLOB *blob, INT_FEATURE_STRUCT *int_features, int *num_features, int *FeatureOutlineIndex)
Definition: capi.cpp:555
TESS_API void TESS_CALL TessResultRendererInsert(TessResultRenderer *renderer, TessResultRenderer *next)
Definition: capi.cpp:90
TESS_API ROW *TESS_CALL TessMakeTessOCRRow(float baseline, float xheight, float descender, float ascender)
Definition: capi.cpp:590
TESS_API char *TESS_CALL TessBaseAPIRect(TessBaseAPI *handle, const unsigned char *imagedata, int bytes_per_pixel, int bytes_per_line, int left, int top, int width, int height)
Definition: capi.cpp:334
TESS_API const char *TESS_CALL TessResultRendererExtention(TessResultRenderer *renderer)
Definition: capi.cpp:115
TESS_API void TESS_CALL TessMonitorSetProgressFunc(ETEXT_DESC *monitor, TessProgressFunc progressFunc)
Definition: capi.cpp:848
CANCEL_FUNC cancel
for errcode use
Definition: ocrclass.h:129
TESS_API const char *TESS_CALL TessVersion()
Definition: capi.cpp:25
TESS_API TessResultRenderer *TESS_CALL TessHOcrRendererCreate(const char *outputbase)
Definition: capi.cpp:59
struct TessResultRenderer TessResultRenderer
Definition: capi.h:83
TESS_API TessMutableIterator *TESS_CALL TessBaseAPIGetMutableIterator(TessBaseAPI *handle)
Definition: capi.cpp:468
PROGRESS_FUNC2 progress_callback2
called whenever progress increases
Definition: ocrclass.h:131
struct TessMutableIterator TessMutableIterator
Definition: capi.h:92
TESS_API void TESS_CALL TessDeleteResultRenderer(TessResultRenderer *renderer)
Definition: capi.cpp:85
TESS_API BOOL TESS_CALL TessBaseAPIProcessPage(TessBaseAPI *handle, struct Pix *pix, int page_index, const char *filename, const char *retry_config, int timeout_millisec, TessResultRenderer *renderer)
Definition: capi.cpp:454
TESS_API void TESS_CALL TessBaseAPIDelete(TessBaseAPI *handle)
Definition: capi.cpp:135
TESS_API void TESS_CALL TessBaseAPIReadDebugConfigFile(TessBaseAPI *handle, const char *filename)
Definition: capi.cpp:319
TESS_API void TESS_CALL TessDeleteIntArray(int *arr)
Definition: capi.cpp:42
TESS_API BOOL TESS_CALL TessResultIteratorWordIsFromDictionary(const TessResultIterator *handle)
Definition: capi.cpp:778
TESS_API void TESS_CALL TessBaseAPISetInputImage(TessBaseAPI *handle, Pix *pix)
Definition: capi.cpp:155
TESS_API TessPageIterator *TESS_CALL TessBaseAPIAnalyseLayout(TessBaseAPI *handle)
Definition: capi.cpp:428
TESS_API BOOL TESS_CALL TessBaseAPIGetTextDirection(TessBaseAPI *handle, int *out_offset, float *out_slope)
Definition: capi.cpp:525
TESS_API int TESS_CALL TessBaseAPIInit1(TessBaseAPI *handle, const char *datapath, const char *language, TessOcrEngineMode oem, char **configs, int configs_size)
Definition: capi.cpp:259
Definition: blobs.h:268
TESS_API float TESS_CALL TessResultIteratorConfidence(const TessResultIterator *handle, TessPageIteratorLevel level)
Definition: capi.cpp:746
TESS_API const char *TESS_CALL TessBaseAPIGetInitLanguagesAsString(const TessBaseAPI *handle)
Definition: capi.cpp:275
TESS_API TessPageIterator *TESS_CALL TessPageIteratorCopy(const TessPageIterator *handle)
Definition: capi.cpp:638
TESS_API int TESS_CALL TessBaseAPINumDawgs(const TessBaseAPI *handle)
Definition: capi.cpp:584
TESS_API int TESS_CALL TessBaseAPIRecognize(TessBaseAPI *handle, ETEXT_DESC *monitor)
Definition: capi.cpp:433
TESS_API BOOL TESS_CALL TessBaseAPIGetDoubleVariable(const TessBaseAPI *handle, const char *name, double *value)
Definition: capi.cpp:209
TESS_API void TESS_CALL TessMonitorSetCancelThis(ETEXT_DESC *monitor, void *cancelThis)
Definition: capi.cpp:838
int16_t progress
chars in this buffer(0)
Definition: ocrclass.h:122
void set_deadline_msecs(int32_t deadline_msecs)
Definition: ocrclass.h:152
TESS_API TessBaseAPI *TESS_CALL TessBaseAPICreate()
Definition: capi.cpp:130
TESS_API BLOCK_LIST *TESS_CALL TessBaseAPIFindLinesCreateBlockList(TessBaseAPI *handle)
Definition: capi.cpp:627
struct TessBoxTextRenderer TessBoxTextRenderer
Definition: capi.h:88
TESS_API BOOL TESS_CALL TessResultIteratorWordIsNumeric(const TessResultIterator *handle)
Definition: capi.cpp:783
TESS_API void TESS_CALL TessPageIteratorOrientation(TessPageIterator *handle, TessOrientation *orientation, TessWritingDirection *writing_direction, TessTextlineOrder *textline_order, float *deskew_angle)
Definition: capi.cpp:692
TESS_API TessResultIterator *TESS_CALL TessBaseAPIGetIterator(TessBaseAPI *handle)
Definition: capi.cpp:463
TESS_API int TESS_CALL TessBaseAPIMeanTextConf(TessBaseAPI *handle)
Definition: capi.cpp:493
struct TessPageIterator TessPageIterator
Definition: capi.h:90
TESS_API TessResultRenderer *TESS_CALL TessHOcrRendererCreate2(const char *outputbase, BOOL font_info)
Definition: capi.cpp:64
TESS_API TessPageSegMode TESS_CALL TessBaseAPIGetPageSegMode(const TessBaseAPI *handle)
Definition: capi.cpp:329
TESS_API void TESS_CALL TessBaseAPIClearAdaptiveClassifier(TessBaseAPI *handle)
Definition: capi.cpp:342
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsDropcap(const TessResultIterator *handle)
Definition: capi.cpp:798
TESS_API char **TESS_CALL TessBaseAPIGetAvailableLanguagesAsVector(const TessBaseAPI *handle)
Definition: capi.cpp:291
TESS_API BOOL TESS_CALL TessResultIteratorNext(TessResultIterator *handle, TessPageIteratorLevel level)
Definition: capi.cpp:736
TESS_API void TESS_CALL TessResultIteratorDelete(TessResultIterator *handle)
Definition: capi.cpp:711
TESS_API const char *TESS_CALL TessBaseAPIGetStringVariable(const TessBaseAPI *handle, const char *name)
Definition: capi.cpp:214
TESS_API struct Boxa *TESS_CALL TessBaseAPIGetTextlines(TessBaseAPI *handle, struct Pixa **pixa, int **blockids)
Definition: capi.cpp:384
TESS_API int TESS_CALL TessBaseAPIRecognizeForChopTest(TessBaseAPI *handle, ETEXT_DESC *monitor)
Definition: capi.cpp:439