mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
RAII: *::GetBoxText()
This commit is contained in:
parent
b7b68a65dd
commit
1dab23916f
@ -1702,8 +1702,9 @@ const int kMaxBytesPerLine = kNumbersPerBlob * (kBytesPer64BitNumber + 1) + 1 +
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The recognized text is returned as a char* which is coded
|
* The recognized text is returned as a char* which is coded
|
||||||
* as a UTF8 box file and must be freed with the delete [] operator.
|
* as a UTF8 box file.
|
||||||
* page_number is a 0-base page index that will appear in the box file.
|
* page_number is a 0-base page index that will appear in the box file.
|
||||||
|
* Returned string must be freed with the delete [] operator.
|
||||||
*/
|
*/
|
||||||
char* TessBaseAPI::GetBoxText(int page_number) {
|
char* TessBaseAPI::GetBoxText(int page_number) {
|
||||||
if (tesseract_ == NULL ||
|
if (tesseract_ == NULL ||
|
||||||
|
@ -612,10 +612,10 @@ class TESS_API TessBaseAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The recognized text is returned as a char* which is coded in the same
|
* The recognized text is returned as a char* which is coded in the same
|
||||||
* format as a box file used in training. Returned string must be freed with
|
* format as a box file used in training.
|
||||||
* the delete [] operator.
|
|
||||||
* Constructs coordinates in the original image - not just the rectangle.
|
* Constructs coordinates in the original image - not just the rectangle.
|
||||||
* page_number is a 0-based page index that will appear in the box file.
|
* page_number is a 0-based page index that will appear in the box file.
|
||||||
|
* Returned string must be freed with the delete [] operator.
|
||||||
*/
|
*/
|
||||||
char* GetBoxText(int page_number);
|
char* GetBoxText(int page_number);
|
||||||
|
|
||||||
|
@ -251,11 +251,10 @@ TessBoxTextRenderer::TessBoxTextRenderer(const char *outputbase)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TessBoxTextRenderer::AddImageHandler(TessBaseAPI* api) {
|
bool TessBoxTextRenderer::AddImageHandler(TessBaseAPI* api) {
|
||||||
char* text = api->GetBoxText(imagenum());
|
const std::unique_ptr<const char[]> text(api->GetBoxText(imagenum()));
|
||||||
if (text == NULL) return false;
|
if (text == NULL) return false;
|
||||||
|
|
||||||
AppendString(text);
|
AppendString(text.get());
|
||||||
delete[] text;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user