mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
RAII: *::GetHOCRText()
This commit is contained in:
parent
986970d6ca
commit
a1fff874b4
@ -1393,6 +1393,7 @@ static void AddBoxToTSV(const PageIterator* it, PageIteratorLevel level,
|
||||
* Image name/input_file_ can be set by SetInputName before calling
|
||||
* GetHOCRText
|
||||
* STL removed from original patch submission and refactored by rays.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* TessBaseAPI::GetHOCRText(int page_number) {
|
||||
return GetHOCRText(NULL, page_number);
|
||||
@ -1405,6 +1406,7 @@ char* TessBaseAPI::GetHOCRText(int page_number) {
|
||||
* Image name/input_file_ can be set by SetInputName before calling
|
||||
* GetHOCRText
|
||||
* STL removed from original patch submission and refactored by rays.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* TessBaseAPI::GetHOCRText(ETEXT_DESC* monitor, int page_number) {
|
||||
if (tesseract_ == NULL || (page_res_ == NULL && Recognize(monitor) < 0))
|
||||
|
@ -591,6 +591,7 @@ class TESS_API TessBaseAPI {
|
||||
* monitor can be used to
|
||||
* cancel the recognition
|
||||
* receive progress callbacks
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetHOCRText(ETEXT_DESC* monitor, int page_number);
|
||||
|
||||
@ -598,6 +599,7 @@ class TESS_API TessBaseAPI {
|
||||
* 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.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetHOCRText(int page_number);
|
||||
|
||||
|
@ -186,11 +186,10 @@ bool TessHOcrRenderer::EndDocumentHandler() {
|
||||
}
|
||||
|
||||
bool TessHOcrRenderer::AddImageHandler(TessBaseAPI* api) {
|
||||
char* hocr = api->GetHOCRText(imagenum());
|
||||
const std::unique_ptr<const char[]> hocr(api->GetHOCRText(imagenum()));
|
||||
if (hocr == NULL) return false;
|
||||
|
||||
AppendString(hocr);
|
||||
delete[] hocr;
|
||||
AppendString(hocr.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user