mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
RAII: TessBaseAPI::GetUTF8Text()
This commit is contained in:
parent
4840c65bf0
commit
f75665c34f
@ -1980,9 +1980,9 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char* wordstr) {
|
||||
PageSegMode current_psm = GetPageSegMode();
|
||||
SetPageSegMode(mode);
|
||||
SetVariable("classify_enable_learning", "0");
|
||||
char* text = GetUTF8Text();
|
||||
const std::unique_ptr<const char[]> text(GetUTF8Text());
|
||||
if (debug) {
|
||||
tprintf("Trying to adapt \"%s\" to \"%s\"\n", text, wordstr);
|
||||
tprintf("Trying to adapt \"%s\" to \"%s\"\n", text.get(), wordstr);
|
||||
}
|
||||
if (text != NULL) {
|
||||
PAGE_RES_IT it(page_res_);
|
||||
@ -2022,7 +2022,6 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char* wordstr) {
|
||||
tesseract_->EnableLearning = true;
|
||||
tesseract_->LearnWord(NULL, word_res);
|
||||
}
|
||||
delete [] text;
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "config_auto.h"
|
||||
#endif
|
||||
|
||||
#include <memory> // std::unique_ptr
|
||||
#include <string.h>
|
||||
#include "baseapi.h"
|
||||
#include "genericvector.h"
|
||||
@ -122,13 +123,12 @@ TessTextRenderer::TessTextRenderer(const char *outputbase)
|
||||
}
|
||||
|
||||
bool TessTextRenderer::AddImageHandler(TessBaseAPI* api) {
|
||||
char* utf8 = api->GetUTF8Text();
|
||||
const std::unique_ptr<const char[]> utf8(api->GetUTF8Text());
|
||||
if (utf8 == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AppendString(utf8);
|
||||
delete[] utf8;
|
||||
AppendString(utf8.get());
|
||||
|
||||
bool pageBreak = false;
|
||||
api->GetBoolVariable("include_page_breaks", &pageBreak);
|
||||
|
Loading…
Reference in New Issue
Block a user