mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
RAII: *::GetTSVText()
This commit is contained in:
parent
a1fff874b4
commit
b7b68a65dd
@ -1577,6 +1577,7 @@ char* TessBaseAPI::GetHOCRText(ETEXT_DESC* monitor, int page_number) {
|
||||
/**
|
||||
* Make a TSV-formatted string 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* TessBaseAPI::GetTSVText(int page_number) {
|
||||
if (tesseract_ == NULL || (page_res_ == NULL && Recognize(NULL) < 0))
|
||||
|
@ -606,6 +606,7 @@ class TESS_API TessBaseAPI {
|
||||
/**
|
||||
* Make a TSV-formatted string 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* GetTSVText(int page_number);
|
||||
|
||||
|
@ -218,11 +218,10 @@ bool TessTsvRenderer::BeginDocumentHandler() {
|
||||
bool TessTsvRenderer::EndDocumentHandler() { return true; }
|
||||
|
||||
bool TessTsvRenderer::AddImageHandler(TessBaseAPI* api) {
|
||||
char* tsv = api->GetTSVText(imagenum());
|
||||
const std::unique_ptr<const char[]> tsv(api->GetTSVText(imagenum()));
|
||||
if (tsv == NULL) return false;
|
||||
|
||||
AppendString(tsv);
|
||||
delete[] tsv;
|
||||
AppendString(tsv.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user