Skip to content

Commit

Permalink
Add monitor to GetHOCRText
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed May 17, 2015
1 parent 59bcbc7 commit ed6ae9b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
14 changes: 13 additions & 1 deletion api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,20 @@ static void AddBoxTohOCR(const PageIterator *it,
* STL removed from original patch submission and refactored by rays.
*/
char* TessBaseAPI::GetHOCRText(int page_number) {
return GetHOCRText(NULL,page_number);
}

/**
* 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.
* Image name/input_file_ can be set by SetInputName before calling
* GetHOCRText
* STL removed from original patch submission and refactored by rays.
*/
char* TessBaseAPI::GetHOCRText(struct ETEXT_DESC* monitor, int page_number) {
if (tesseract_ == NULL ||
(page_res_ == NULL && Recognize(NULL) < 0))
(page_res_ == NULL && Recognize(monitor) < 0))
return NULL;

int lcnt = 1, bcnt = 1, pcnt = 1, wcnt = 1;
Expand Down
10 changes: 10 additions & 0 deletions api/baseapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,16 @@ class TESS_API TessBaseAPI {
*/
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.
* monitor can be used to
* cancel the regocnition
* receive progress callbacks
*/
char* GetHOCRText(struct ETEXT_DESC* monitor, int page_number);

/**
* Make a HTML-formatted string with hOCR markup from the internal
* data structures.
Expand Down
4 changes: 2 additions & 2 deletions api/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ TESS_API int TESS_CALL TessBaseAPIRecognizeForChopTest(TessBaseAPI* handle, ETEX
TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle, const char* filename, const char* retry_config,
int timeout_millisec, TessResultRenderer* renderer)
{
if (handle->ProcessPages(filename, retry_config, timeout_millisec, renderer))
if (handle->ProcessPages(filename, retry_config, timeout_millisec, renderer))
return TRUE;
else
return FALSE;
Expand Down Expand Up @@ -456,7 +456,7 @@ TESS_API char* TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI* handle)

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

TESS_API char* TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI* handle, int page_number)
Expand Down

0 comments on commit ed6ae9b

Please sign in to comment.