mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-19 06:53:36 +08:00
Format new code with clang-format
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
5de2a21b3f
commit
38fac625cd
@ -23,9 +23,9 @@
|
||||
namespace tesseract {
|
||||
|
||||
/**
|
||||
* Create a UTF8 box file with WordStr strings from the internal data structures.
|
||||
* page_number is a 0-base page index that will appear in the box file.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
* Create a UTF8 box file with WordStr strings from the internal data
|
||||
* structures. 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::GetWordStrBoxText(int page_number) {
|
||||
@ -44,31 +44,32 @@ char* TessBaseAPI::GetWordStrBoxText(int page_number) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (res_it->IsAtBeginningOf(RIL_TEXTLINE)) {
|
||||
if (!first_line) {
|
||||
if (res_it->IsAtBeginningOf(RIL_TEXTLINE)) {
|
||||
if (!first_line) {
|
||||
wordstr_box_str.add_str_int("\n\t ", right + 1);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - bottom);
|
||||
wordstr_box_str.add_str_int(" ", right + 5);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - top);
|
||||
wordstr_box_str.add_str_int(" ", page_num); // row for tab for EOL
|
||||
wordstr_box_str += "\n";
|
||||
} else {
|
||||
} else {
|
||||
first_line = false;
|
||||
}
|
||||
// Use bounding box for whole line for WordStr
|
||||
res_it->BoundingBox(RIL_TEXTLINE, &left, &top, &right, &bottom);
|
||||
wordstr_box_str.add_str_int("WordStr ", left);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - bottom);
|
||||
wordstr_box_str.add_str_int(" ", right);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - top);
|
||||
wordstr_box_str.add_str_int(" ", page_num); // word
|
||||
wordstr_box_str += " #";
|
||||
}
|
||||
// Use bounding box for whole line for WordStr
|
||||
res_it->BoundingBox(RIL_TEXTLINE, &left, &top, &right, &bottom);
|
||||
wordstr_box_str.add_str_int("WordStr ", left);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - bottom);
|
||||
wordstr_box_str.add_str_int(" ", right);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - top);
|
||||
wordstr_box_str.add_str_int(" ", page_num); // word
|
||||
wordstr_box_str += " #";
|
||||
}
|
||||
do { wordstr_box_str +=
|
||||
std::unique_ptr<const char[]>(res_it->GetUTF8Text(RIL_WORD)).get();
|
||||
wordstr_box_str += " ";
|
||||
res_it->Next(RIL_WORD);
|
||||
} while (!res_it->Empty(RIL_BLOCK) && !res_it->IsAtBeginningOf(RIL_WORD));
|
||||
do {
|
||||
wordstr_box_str +=
|
||||
std::unique_ptr<const char[]>(res_it->GetUTF8Text(RIL_WORD)).get();
|
||||
wordstr_box_str += " ";
|
||||
res_it->Next(RIL_WORD);
|
||||
} while (!res_it->Empty(RIL_BLOCK) && !res_it->IsAtBeginningOf(RIL_WORD));
|
||||
}
|
||||
wordstr_box_str.add_str_int("\n\t ", right + 1);
|
||||
wordstr_box_str.add_str_int(" ", image_height_ - bottom);
|
||||
@ -85,12 +86,12 @@ char* TessBaseAPI::GetWordStrBoxText(int page_number) {
|
||||
/**********************************************************************
|
||||
* WordStrBox Renderer interface implementation
|
||||
**********************************************************************/
|
||||
TessWordStrBoxRenderer::TessWordStrBoxRenderer(const char *outputbase)
|
||||
: TessResultRenderer(outputbase, "box") {
|
||||
}
|
||||
TessWordStrBoxRenderer::TessWordStrBoxRenderer(const char* outputbase)
|
||||
: TessResultRenderer(outputbase, "box") {}
|
||||
|
||||
bool TessWordStrBoxRenderer::AddImageHandler(TessBaseAPI* api) {
|
||||
const std::unique_ptr<const char[]> wordstrbox(api->GetWordStrBoxText(imagenum()));
|
||||
const std::unique_ptr<const char[]> wordstrbox(
|
||||
api->GetWordStrBoxText(imagenum()));
|
||||
if (wordstrbox == nullptr) return false;
|
||||
|
||||
AppendString(wordstrbox.get());
|
||||
|
Loading…
Reference in New Issue
Block a user