Skip to content

Commit 4ce797b

Browse files
committed
Fix hocr character box info to use new hocr renderer correctly
1 parent c43e450 commit 4ce797b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/api/hocrrenderer.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ char* TessBaseAPI::GetHOCRText(ETEXT_DESC* monitor, int page_number) {
135135
bool para_is_ltr = true; // Default direction is LTR
136136
const char* paragraph_lang = nullptr;
137137
bool font_info = false;
138+
bool hocr_boxes = false;
138139
GetBoolVariable("hocr_font_info", &font_info);
139140
GetBoolVariable("hocr_char_boxes", &hocr_boxes);
140141

@@ -267,18 +268,13 @@ char* TessBaseAPI::GetHOCRText(ETEXT_DESC* monitor, int page_number) {
267268
if (grapheme && grapheme[0] != 0) {
268269
if (hocr_boxes) {
269270
res_it->BoundingBox(RIL_SYMBOL, &left, &top, &right, &bottom);
270-
hocr_str += "<span class='ocrx_cinfo' title='x_bboxes";
271-
hocr_str.add_str_int(" ", left);
272-
hocr_str.add_str_int(" ", top);
273-
hocr_str.add_str_int(" ", right);
274-
hocr_str.add_str_int(" ", bottom);
275-
hocr_str += "; x_conf";
276-
hocr_str.add_str_int(" ", res_it->Confidence(RIL_SYMBOL));
277-
hocr_str += "'>";
271+
hocr_str << "<span class='ocrx_cinfo' title='x_bboxes' "
272+
<< left << " " << top << " " << right << " " << bottom
273+
<< "; x_conf " << res_it->Confidence(RIL_SYMBOL) << "'>";
278274
}
279275
hocr_str << HOcrEscape(grapheme.get()).c_str();
280276
if (hocr_boxes) {
281-
hocr_str += "</span>";
277+
hocr_str << "</span>";
282278
}
283279
}
284280
res_it->Next(RIL_SYMBOL);

0 commit comments

Comments
 (0)