Skip to content

Commit ed6ae9b

Browse files
committed
Add monitor to GetHOCRText
1 parent 59bcbc7 commit ed6ae9b

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

api/baseapi.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -1397,8 +1397,20 @@ static void AddBoxTohOCR(const PageIterator *it,
13971397
* STL removed from original patch submission and refactored by rays.
13981398
*/
13991399
char* TessBaseAPI::GetHOCRText(int page_number) {
1400+
return GetHOCRText(NULL,page_number);
1401+
}
1402+
1403+
/**
1404+
* Make a HTML-formatted string with hOCR markup from the internal
1405+
* data structures.
1406+
* page_number is 0-based but will appear in the output as 1-based.
1407+
* Image name/input_file_ can be set by SetInputName before calling
1408+
* GetHOCRText
1409+
* STL removed from original patch submission and refactored by rays.
1410+
*/
1411+
char* TessBaseAPI::GetHOCRText(struct ETEXT_DESC* monitor, int page_number) {
14001412
if (tesseract_ == NULL ||
1401-
(page_res_ == NULL && Recognize(NULL) < 0))
1413+
(page_res_ == NULL && Recognize(monitor) < 0))
14021414
return NULL;
14031415

14041416
int lcnt = 1, bcnt = 1, pcnt = 1, wcnt = 1;

api/baseapi.h

+10
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,16 @@ class TESS_API TessBaseAPI {
583583
*/
584584
char* GetUTF8Text();
585585

586+
/**
587+
* Make a HTML-formatted string with hOCR markup from the internal
588+
* data structures.
589+
* page_number is 0-based but will appear in the output as 1-based.
590+
* monitor can be used to
591+
* cancel the regocnition
592+
* receive progress callbacks
593+
*/
594+
char* GetHOCRText(struct ETEXT_DESC* monitor, int page_number);
595+
586596
/**
587597
* Make a HTML-formatted string with hOCR markup from the internal
588598
* data structures.

api/capi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ TESS_API int TESS_CALL TessBaseAPIRecognizeForChopTest(TessBaseAPI* handle, ETEX
424424
TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle, const char* filename, const char* retry_config,
425425
int timeout_millisec, TessResultRenderer* renderer)
426426
{
427-
if (handle->ProcessPages(filename, retry_config, timeout_millisec, renderer))
427+
if (handle->ProcessPages(filename, retry_config, timeout_millisec, renderer))
428428
return TRUE;
429429
else
430430
return FALSE;
@@ -456,7 +456,7 @@ TESS_API char* TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI* handle)
456456

457457
TESS_API char* TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI* handle, int page_number)
458458
{
459-
return handle->GetHOCRText(page_number);
459+
return handle->GetHOCRText(NULL, page_number);
460460
}
461461

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

0 commit comments

Comments
 (0)