diff --git a/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.cpp b/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.cpp index ecf1d830e..737e8ad54 100644 --- a/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.cpp +++ b/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.cpp @@ -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(); } /** @@ -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(); @@ -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; @@ -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); } diff --git a/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.h b/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.h index 4bbbdd5e2..882d7e49a 100644 --- a/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.h +++ b/tess-two/jni/com_googlecode_tesseract_android/src/api/baseapi.h @@ -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 diff --git a/tess-two/jni/com_googlecode_tesseract_android/src/api/capi.cpp b/tess-two/jni/com_googlecode_tesseract_android/src/api/capi.cpp index 2dbbf1e38..74f9474e4 100644 --- a/tess-two/jni/com_googlecode_tesseract_android/src/api/capi.cpp +++ b/tess-two/jni/com_googlecode_tesseract_android/src/api/capi.cpp @@ -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) diff --git a/tess-two/jni/com_googlecode_tesseract_android/src/api/renderer.cpp b/tess-two/jni/com_googlecode_tesseract_android/src/api/renderer.cpp index e05c9823e..688365b50 100644 --- a/tess-two/jni/com_googlecode_tesseract_android/src/api/renderer.cpp +++ b/tess-two/jni/com_googlecode_tesseract_android/src/api/renderer.cpp @@ -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; } @@ -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); diff --git a/tess-two/jni/com_googlecode_tesseract_android/tessbaseapi.cpp b/tess-two/jni/com_googlecode_tesseract_android/tessbaseapi.cpp index 9c0d4ab13..c8f321ec0 100644 --- a/tess-two/jni/com_googlecode_tesseract_android/tessbaseapi.cpp +++ b/tess-two/jni/com_googlecode_tesseract_android/tessbaseapi.cpp @@ -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); @@ -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); diff --git a/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java b/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java index 505c9366f..0471b567e 100644 --- a/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java +++ b/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java @@ -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);