Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Change method signatures. Closes #116.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtheis committed Jan 31, 2016
1 parent 918f7f1 commit 9c87b17
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ char* TessBaseAPI::TesseractRect(const unsigned char* imagedata,
bytes_per_pixel, bytes_per_line);
SetRectangle(left, top, width, height);

return GetUTF8Text(NULL);
return GetUTF8Text();
}

/**
Expand Down Expand Up @@ -1300,9 +1300,9 @@ MutableIterator* TessBaseAPI::GetMutableIterator() {
}

/** Make a text string from the internal data structures. */
char* TessBaseAPI::GetUTF8Text(struct ETEXT_DESC* monitor) {
char* TessBaseAPI::GetUTF8Text() {
if (tesseract_ == NULL ||
(!recognition_done_ && Recognize(monitor) < 0))
(!recognition_done_ && Recognize(NULL) < 0))
return NULL;
STRING text("");
ResultIterator *it = GetIterator();
Expand Down Expand Up @@ -1401,7 +1401,7 @@ static void AddBoxTohOCR(const PageIterator *it,
* GetHOCRText
* STL removed from original patch submission and refactored by rays.
*/
char* TessBaseAPI::GetHOCRText(int page_number, struct ETEXT_DESC* monitor) {
char* TessBaseAPI::GetHOCRText(struct ETEXT_DESC* monitor, int page_number) {
if (tesseract_ == NULL ||
(page_res_ == NULL && Recognize(monitor) < 0))
return NULL;
Expand Down Expand Up @@ -1834,7 +1834,7 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char* wordstr) {
PageSegMode current_psm = GetPageSegMode();
SetPageSegMode(mode);
SetVariable("classify_enable_learning", "0");
char* text = GetUTF8Text(NULL);
char* text = GetUTF8Text();
if (debug) {
tprintf("Trying to adapt \"%s\" to \"%s\"\n", text, wordstr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,16 @@ class TESS_API TessBaseAPI {
* The recognized text is returned as a char* which is coded
* as UTF8 and must be freed with the delete [] operator.
*/
char* GetUTF8Text(ETEXT_DESC* monitor);
char* GetUTF8Text();

/**
* Make a HTML-formatted string with hOCR markup from the internal
* data structures.
* page_number is 0-based but will appear in the output as 1-based.
*/
char* GetHOCRText(int page_number, ETEXT_DESC* monitor);
char* GetHOCRText(int page_number);

char* GetHOCRText(struct ETEXT_DESC* monitor, int page_number);

/**
* The recognized text is returned as a char* which is coded in the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,12 @@ TESS_API TessMutableIterator* TESS_CALL TessBaseAPIGetMutableIterator(TessBaseAP

TESS_API char* TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI* handle)
{
return handle->GetUTF8Text(NULL);
return handle->GetUTF8Text();
}

TESS_API char* TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI* handle, int page_number)
{
return handle->GetHOCRText(page_number, NULL);
return handle->GetHOCRText(NULL, page_number);
}

TESS_API char* TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI* handle, int page_number)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TessTextRenderer::TessTextRenderer(const char *outputbase)
}

bool TessTextRenderer::AddImageHandler(TessBaseAPI* api) {
char* utf8 = api->GetUTF8Text(NULL);
char* utf8 = api->GetUTF8Text();
if (utf8 == NULL) {
return false;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ bool TessHOcrRenderer::EndDocumentHandler() {
}

bool TessHOcrRenderer::AddImageHandler(TessBaseAPI* api) {
char* hocr = api->GetHOCRText(imagenum(), NULL);
char* hocr = api->GetHOCRText(NULL, imagenum());
if (hocr == NULL) return false;

AppendString(hocr);
Expand Down
4 changes: 2 additions & 2 deletions tess-two/jni/com_googlecode_tesseract_android/tessbaseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ jstring Java_com_googlecode_tesseract_android_TessBaseAPI_nativeGetUTF8Text(JNIE
monitor.cancel_this = nat;
monitor.progress_this = nat;

char *text = nat->api.GetUTF8Text(&monitor);
char *text = nat->api.GetUTF8Text();

jstring result = env->NewStringUTF(text);

Expand Down Expand Up @@ -538,7 +538,7 @@ jstring Java_com_googlecode_tesseract_android_TessBaseAPI_nativeGetHOCRText(JNIE
monitor.cancel_this = nat;
monitor.progress_this = nat;

char *text = nat->api.GetHOCRText(page, &monitor);
char *text = nat->api.GetHOCRText(&monitor, page);

jstring result = env->NewStringUTF(text);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public static final class PageIteratorLevel {
/**
* Interface that may be implemented by calling object in order to receive
* progress callbacks during OCR.
*
* Progress callbacks are available when {@link #getHOCRText(int)} is used.
*/
public interface ProgressNotifier {
void onProgressValues(ProgressValues progressValues);
Expand Down

0 comments on commit 9c87b17

Please sign in to comment.