23
23
namespace tesseract {
24
24
25
25
/* *
26
- * Create a UTF8 box file with WordStr strings from the internal data structures.
27
- * page_number is a 0-base page index that will appear in the box file.
28
- * Returned string must be freed with the delete [] operator.
26
+ * Create a UTF8 box file with WordStr strings from the internal data
27
+ * structures. page_number is a 0-base page index that will appear in the box
28
+ * file. Returned string must be freed with the delete [] operator.
29
29
*/
30
30
31
31
char * TessBaseAPI::GetWordStrBoxText (int page_number) {
@@ -44,31 +44,32 @@ char* TessBaseAPI::GetWordStrBoxText(int page_number) {
44
44
continue ;
45
45
}
46
46
47
- if (res_it->IsAtBeginningOf (RIL_TEXTLINE)) {
48
- if (!first_line) {
47
+ if (res_it->IsAtBeginningOf (RIL_TEXTLINE)) {
48
+ if (!first_line) {
49
49
wordstr_box_str.add_str_int (" \n\t " , right + 1 );
50
50
wordstr_box_str.add_str_int (" " , image_height_ - bottom);
51
51
wordstr_box_str.add_str_int (" " , right + 5 );
52
52
wordstr_box_str.add_str_int (" " , image_height_ - top);
53
53
wordstr_box_str.add_str_int (" " , page_num); // row for tab for EOL
54
54
wordstr_box_str += " \n " ;
55
- } else {
55
+ } else {
56
56
first_line = false ;
57
+ }
58
+ // Use bounding box for whole line for WordStr
59
+ res_it->BoundingBox (RIL_TEXTLINE, &left, &top, &right, &bottom);
60
+ wordstr_box_str.add_str_int (" WordStr " , left);
61
+ wordstr_box_str.add_str_int (" " , image_height_ - bottom);
62
+ wordstr_box_str.add_str_int (" " , right);
63
+ wordstr_box_str.add_str_int (" " , image_height_ - top);
64
+ wordstr_box_str.add_str_int (" " , page_num); // word
65
+ wordstr_box_str += " #" ;
57
66
}
58
- // Use bounding box for whole line for WordStr
59
- res_it->BoundingBox (RIL_TEXTLINE, &left, &top, &right, &bottom);
60
- wordstr_box_str.add_str_int (" WordStr " , left);
61
- wordstr_box_str.add_str_int (" " , image_height_ - bottom);
62
- wordstr_box_str.add_str_int (" " , right);
63
- wordstr_box_str.add_str_int (" " , image_height_ - top);
64
- wordstr_box_str.add_str_int (" " , page_num); // word
65
- wordstr_box_str += " #" ;
66
- }
67
- do { wordstr_box_str +=
68
- std::unique_ptr<const char []>(res_it->GetUTF8Text (RIL_WORD)).get ();
69
- wordstr_box_str += " " ;
70
- res_it->Next (RIL_WORD);
71
- } while (!res_it->Empty (RIL_BLOCK) && !res_it->IsAtBeginningOf (RIL_WORD));
67
+ do {
68
+ wordstr_box_str +=
69
+ std::unique_ptr<const char []>(res_it->GetUTF8Text (RIL_WORD)).get ();
70
+ wordstr_box_str += " " ;
71
+ res_it->Next (RIL_WORD);
72
+ } while (!res_it->Empty (RIL_BLOCK) && !res_it->IsAtBeginningOf (RIL_WORD));
72
73
}
73
74
wordstr_box_str.add_str_int (" \n\t " , right + 1 );
74
75
wordstr_box_str.add_str_int (" " , image_height_ - bottom);
@@ -85,12 +86,12 @@ char* TessBaseAPI::GetWordStrBoxText(int page_number) {
85
86
/* *********************************************************************
86
87
* WordStrBox Renderer interface implementation
87
88
**********************************************************************/
88
- TessWordStrBoxRenderer::TessWordStrBoxRenderer (const char *outputbase)
89
- : TessResultRenderer(outputbase, " box" ) {
90
- }
89
+ TessWordStrBoxRenderer::TessWordStrBoxRenderer (const char * outputbase)
90
+ : TessResultRenderer(outputbase, " box" ) {}
91
91
92
92
bool TessWordStrBoxRenderer::AddImageHandler (TessBaseAPI* api) {
93
- const std::unique_ptr<const char []> wordstrbox (api->GetWordStrBoxText (imagenum ()));
93
+ const std::unique_ptr<const char []> wordstrbox (
94
+ api->GetWordStrBoxText (imagenum ()));
94
95
if (wordstrbox == nullptr ) return false ;
95
96
96
97
AppendString (wordstrbox.get ());
0 commit comments