Skip to content

Commit

Permalink
Export GetBlockCount & GetBlockMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Sep 11, 2020
1 parent 5d2c8e1 commit 7696078
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int Tesseract_GetCount(tesseract::TessBaseAPI* tesseract_ptr, tesseract::PageIte
int hits = 0;

tesseract::ResultIterator* ri = tesseract_ptr->GetIterator();
if (ri != 0) {
if ((ri != 0) & (!ri->Empty(level))) {
do {
hits++;
} while (ri->Next(level));
Expand All @@ -82,10 +82,10 @@ int Tesseract_GetCount(tesseract::TessBaseAPI* tesseract_ptr, tesseract::PageIte

void Tesseract_GetMatch(tesseract::TessBaseAPI* tesseract_ptr, tesseract::PageIteratorLevel level, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2)
{
int hits = 0;

tesseract::ResultIterator* ri = tesseract_ptr->GetIterator();

if (ri != 0) {
int hits = 0;
if ((ri != 0) & (!ri->Empty(level))) {
do {
if (hits == index) {
text = ri->GetUTF8Text(level);
Expand Down Expand Up @@ -114,6 +114,11 @@ int Tesseract_GetCharacterCount(tesseract::TessBaseAPI* tesseract_ptr)
return Tesseract_GetCount(tesseract_ptr, tesseract::RIL_SYMBOL);
}

int Tesseract_GetBlockCount(tesseract::TessBaseAPI* tesseract_ptr)
{
return Tesseract_GetCount(tesseract_ptr, tesseract::RIL_BLOCK);
}

void Tesseract_GetLineMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2)
{
Tesseract_GetMatch(tesseract_ptr, tesseract::RIL_TEXTLINE, index, text, len, confidence, x1, y1, x2, y2);
Expand All @@ -129,6 +134,11 @@ void Tesseract_GetCharacterMatch(tesseract::TessBaseAPI* tesseract_ptr, int inde
Tesseract_GetMatch(tesseract_ptr, tesseract::RIL_SYMBOL, index, text, len, confidence, x1, y1, x2, y2);
}

void Tesseract_GetBlockMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2)
{
Tesseract_GetMatch(tesseract_ptr, tesseract::RIL_BLOCK, index, text, len, confidence, x1, y1, x2, y2);
}

int GetPluginABIVersion()
{
return 2;
Expand Down
4 changes: 4 additions & 0 deletions exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ static const char* PascalExports[] =
(char*)"Tesseract_FreeUTF8Text", (char*)"procedure Tesseract_FreeUTF8Text(var Text: PChar);",
(char*)"Tesseract_SetVariable", (char*)"function Tesseract_SetVariable(Tesseract: Pointer; name, value: String): Boolean;",
(char*)"Tesseract_Clear", (char*)"procedure Tesseract_Clear(Tesseract: Pointer);",
(char*)"Tesseract_GetBlockCount", (char*)"function Tesseract_GetBlockCount(Tesseract: Pointer): Int32;",
(char*)"Tesseract_GetLineCount", (char*)"function Tesseract_GetLineCount(Tesseract: Pointer): Int32;",
(char*)"Tesseract_GetWordCount", (char*)"function Tesseract_GetWordCount(Tesseract: Pointer): Int32;",
(char*)"Tesseract_GetCharacterCount", (char*)"function Tesseract_GetCharacterCount(Tesseract: Pointer): Int32;",
(char*)"Tesseract_GetBlockMatch", (char*)"procedure Tesseract_GetBlockMatch(Tesseract: Pointer; Index: Int32; var Text: PChar; var Len: Int32; var Confidence: Single; var X1, Y1, X2, Y2: Int32);",
(char*)"Tesseract_GetLineMatch", (char*)"procedure Tesseract_GetLineMatch(Tesseract: Pointer; Index: Int32; var Text: PChar; var Len: Int32; var Confidence: Single; var X1, Y1, X2, Y2: Int32);",
(char*)"Tesseract_GetWordMatch", (char*)"procedure Tesseract_GetWordMatch(Tesseract: Pointer; Index: Int32; var Text: PChar; var Len: Int32; var Confidence: Single; var X1, Y1, X2, Y2: Int32);",
(char*)"Tesseract_GetCharacterMatch", (char*)"procedure Tesseract_GetCharacterMatch(Tesseract: Pointer; Index: Int32; var Text: PChar; var Len: Int32; var Confidence: Single; var X1, Y1, X2, Y2: Int32);",
Expand All @@ -67,9 +69,11 @@ extern "C"
EXPORT void Tesseract_FreeUTF8Text(char* &utf8_text_ptr);
EXPORT bool Tesseract_SetVariable(tesseract::TessBaseAPI* tesseract_ptr, const char* name, const char* value);
EXPORT void Tesseract_Clear(tesseract::TessBaseAPI* tesseract_ptr);
EXPORT int Tesseract_GetBlockCount(tesseract::TessBaseAPI* tesseract_ptr);
EXPORT int Tesseract_GetLineCount(tesseract::TessBaseAPI* tesseract_ptr);
EXPORT int Tesseract_GetWordCount(tesseract::TessBaseAPI* tesseract_ptr);
EXPORT int Tesseract_GetCharacterCount(tesseract::TessBaseAPI* tesseract_ptr);
EXPORT void Tesseract_GetBlockMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
EXPORT void Tesseract_GetLineMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
EXPORT void Tesseract_GetWordMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
EXPORT void Tesseract_GetCharacterMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char* &text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
Expand Down

0 comments on commit 7696078

Please sign in to comment.