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

Function MakeRowFromBlobs

deps/tesseract/textord/makerow.cpp:111–133  ·  view source on GitHub ↗

Factored-out helper to build a single row from a list of blobs. Returns the mean blob size.

Source from the content-addressed store, hash-verified

109// Factored-out helper to build a single row from a list of blobs.
110// Returns the mean blob size.
111static float MakeRowFromBlobs(float line_size,
112 BLOBNBOX_IT* blob_it, TO_ROW_IT* row_it) {
113 blob_it->sort(blob_x_order);
114 blob_it->move_to_first();
115 TO_ROW* row = NULL;
116 float total_size = 0.0f;
117 int blob_count = 0;
118 // Add all the blobs to a single TO_ROW.
119 for (; !blob_it->empty(); blob_it->forward()) {
120 BLOBNBOX* blob = blob_it->extract();
121 int top = blob->bounding_box().top();
122 int bottom = blob->bounding_box().bottom();
123 if (row == NULL) {
124 row = new TO_ROW(blob, top, bottom, line_size);
125 row_it->add_before_then_move(row);
126 } else {
127 row->add_blob(blob, top, bottom, line_size);
128 }
129 total_size += top - bottom;
130 ++blob_count;
131 }
132 return blob_count > 0 ? total_size / blob_count : total_size;
133}
134
135// Helper to make a row using the children of a single blob.
136// Returns the mean size of the blobs created.

Callers 2

MakeRowFromSubBlobsFunction · 0.85
make_single_rowFunction · 0.85

Calls 8

add_blobMethod · 0.80
sortMethod · 0.45
move_to_firstMethod · 0.45
emptyMethod · 0.45
forwardMethod · 0.45
extractMethod · 0.45
bounding_boxMethod · 0.45
add_before_then_moveMethod · 0.45

Tested by

no test coverage detected