MCPcopy Create free account
hub / github.com/creatale/node-dv / ReadMemBoxes

Function ReadMemBoxes

deps/tesseract/ccstruct/boxread.cpp:65–95  ·  view source on GitHub ↗

Reads all boxes from the string. Otherwise, as ReadAllBoxes.

Source from the content-addressed store, hash-verified

63
64// Reads all boxes from the string. Otherwise, as ReadAllBoxes.
65bool ReadMemBoxes(int target_page, bool skip_blanks, const char* box_data,
66 GenericVector<TBOX>* boxes,
67 GenericVector<STRING>* texts,
68 GenericVector<STRING>* box_texts,
69 GenericVector<int>* pages) {
70 STRING box_str(box_data);
71 GenericVector<STRING> lines;
72 box_str.split('\n', &lines);
73 if (lines.empty()) return false;
74 int num_boxes = 0;
75 for (int i = 0; i < lines.size(); ++i) {
76 int page = 0;
77 STRING utf8_str;
78 TBOX box;
79 if (!ParseBoxFileStr(lines[i].string(), &page, &utf8_str, &box)) {
80 continue;
81 }
82 if (skip_blanks && (utf8_str == " " || utf8_str == "\t")) continue;
83 if (target_page >= 0 && page != target_page) continue;
84 if (boxes != NULL) boxes->push_back(box);
85 if (texts != NULL) texts->push_back(utf8_str);
86 if (box_texts != NULL) {
87 STRING full_text;
88 MakeBoxFileStr(utf8_str.string(), box, target_page, &full_text);
89 box_texts->push_back(full_text);
90 }
91 if (pages != NULL) pages->push_back(page);
92 ++num_boxes;
93 }
94 return num_boxes > 0;
95}
96
97// Returns the box file name corresponding to the given image_filename.
98STRING BoxFileName(const STRING& image_filename) {

Callers 2

ReadAllBoxesFunction · 0.85
AddBoxesMethod · 0.85

Calls 7

ParseBoxFileStrFunction · 0.85
MakeBoxFileStrFunction · 0.85
splitMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
stringMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected