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
|
||||
* 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.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* TessBaseAPI::GetBoxText(int page_number) {
|
||||
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
|
||||
* format as a box file used in training. Returned string must be freed with
|
||||
* the delete [] operator.
|
||||
* format as a box file used in training.
|
||||
* 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.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetBoxText(int page_number);
|
||||
|
||||
|
@ -251,11 +251,10 @@ TessBoxTextRenderer::TessBoxTextRenderer(const char *outputbase)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
AppendString(text);
|
||||
delete[] text;
|
||||
AppendString(text.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user