Factored-out helper to build a single row from a list of blobs. Returns the mean blob size.
| 109 | // Factored-out helper to build a single row from a list of blobs. |
| 110 | // Returns the mean blob size. |
| 111 | static 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. |
no test coverage detected