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

Function make_single_row

deps/tesseract/textord/makerow.cpp:164–194  ·  view source on GitHub ↗

* @name make_single_row * * Arrange the blobs into a single row... well actually, if there is * only a single blob, it makes 2 rows, in case the top-level blob * is a container of the real blobs to recognize. */

Source from the content-addressed store, hash-verified

162 * is a container of the real blobs to recognize.
163 */
164float make_single_row(ICOORD page_tr, bool allow_sub_blobs,
165 TO_BLOCK* block, TO_BLOCK_LIST* blocks) {
166 BLOBNBOX_IT blob_it = &block->blobs;
167 TO_ROW_IT row_it = block->get_rows();
168
169 // Include all the small blobs and large blobs.
170 blob_it.add_list_after(&block->small_blobs);
171 blob_it.add_list_after(&block->noise_blobs);
172 blob_it.add_list_after(&block->large_blobs);
173 if (block->blobs.singleton() && allow_sub_blobs) {
174 blob_it.move_to_first();
175 float size = MakeRowFromSubBlobs(block, blob_it.data()->cblob(), &row_it);
176 if (size > block->line_size)
177 block->line_size = size;
178 } else if (block->blobs.empty()) {
179 // Make a fake blob.
180 C_BLOB* blob = C_BLOB::FakeBlob(block->block->bounding_box());
181 // The blobnbox owns the blob.
182 BLOBNBOX* bblob = new BLOBNBOX(blob);
183 blob_it.add_after_then_move(bblob);
184 }
185 MakeRowFromBlobs(block->line_size, &blob_it, &row_it);
186 // Fit an LMS line to the rows.
187 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward())
188 fit_lms_line(row_it.data());
189 float gradient;
190 float fit_error;
191 // Compute the skew based on the fitted line.
192 compute_page_skew(blocks, gradient, fit_error);
193 return gradient;
194}
195
196/**
197 * @name make_rows

Callers 1

TextordPageMethod · 0.85

Calls 15

MakeRowFromSubBlobsFunction · 0.85
MakeRowFromBlobsFunction · 0.85
fit_lms_lineFunction · 0.85
compute_page_skewFunction · 0.85
get_rowsMethod · 0.80
cblobMethod · 0.80
dataMethod · 0.80
add_list_afterMethod · 0.45
move_to_firstMethod · 0.45
emptyMethod · 0.45
bounding_boxMethod · 0.45
add_after_then_moveMethod · 0.45

Tested by

no test coverage detected