#include "mfcpch.h"
#include <stdlib.h>
#include "blckerr.h"
#include "ocrblock.h"
#include "stepblob.h"
#include "tprintf.h"
Go to the source code of this file.
| #define BLOCK_LABEL_HEIGHT 150 |
| int decreasing_top_order |
( |
const void * |
row1, |
|
|
const void * |
row2 |
|
) |
| |
decreasing_top_order
Sort Comparator: Return <0 if row1 top < row2 top
Definition at line 72 of file ocrblock.cpp.
75 return (*(
ROW **) row2)->bounding_box ().top () -
76 (*(
ROW **) row1)->bounding_box ().top ();
| void ExtractBlobsFromSegmentation |
( |
BLOCK_LIST * |
blocks, |
|
|
C_BLOB_LIST * |
output_blob_list |
|
) |
| |
Definition at line 433 of file ocrblock.cpp.
435 C_BLOB_IT return_list_it(output_blob_list);
436 BLOCK_IT block_it(blocks);
437 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
438 BLOCK* block = block_it.data();
440 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
441 ROW* row = row_it.data();
444 for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
445 WERD* werd = werd_it.data();
446 return_list_it.move_to_last();
447 return_list_it.add_list_after(werd->
cblob_list());
448 return_list_it.move_to_last();
C_BLOB_LIST * cblob_list()
C_BLOB_LIST * rej_cblob_list()
ROW_LIST * row_list()
get rows
| bool LeftMargin |
( |
ICOORDELT_LIST * |
segments, |
|
|
int |
x, |
|
|
int * |
margin |
|
) |
| |
Definition at line 244 of file ocrblock.cpp.
247 if (segments->empty())
249 ICOORDELT_IT seg_it(segments);
250 for (seg_it.mark_cycle_pt(); !seg_it.cycled_list(); seg_it.forward()) {
251 int cur_margin = x - seg_it.data()->x();
252 if (cur_margin >= 0) {
254 *margin = cur_margin;
255 }
else if (cur_margin < *margin) {
256 *margin = cur_margin;
| void PrintSegmentationStats |
( |
BLOCK_LIST * |
block_list | ) |
|
Definition at line 400 of file ocrblock.cpp.
405 BLOCK_IT block_it(block_list);
406 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
407 BLOCK* block = block_it.data();
410 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
412 ROW* row = row_it.data();
415 for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
416 WERD* werd = werd_it.data();
422 tprintf(
"Block list stats:\nBlocks = %d\nRows = %d\nWords = %d\nBlobs = %d\n",
423 num_blocks, num_rows, num_words, num_blobs);
C_BLOB_LIST * cblob_list()
ROW_LIST * row_list()
get rows
DLLSYM void tprintf(const char *format,...)
| void RefreshWordBlobsFromNewBlobs |
( |
BLOCK_LIST * |
block_list, |
|
|
C_BLOB_LIST * |
new_blobs, |
|
|
C_BLOB_LIST * |
not_found_blobs |
|
) |
| |
Definition at line 468 of file ocrblock.cpp.
473 BLOCK_IT block_it(block_list);
474 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
475 BLOCK* block = block_it.data();
478 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
479 ROW* row = row_it.data();
483 WERD_IT new_words_it(&new_words);
484 for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
485 WERD* werd = werd_it.extract();
491 new_words_it.add_after_then_move(new_werd);
497 new_words_it.add_after_then_move(werd);
502 werd_it.move_to_first();
503 werd_it.add_list_after(&new_words);
WERD * ConstructWerdWithNewBlobs(C_BLOB_LIST *all_blobs, C_BLOB_LIST *orphan_blobs)
ROW_LIST * row_list()
get rows
| bool RightMargin |
( |
ICOORDELT_LIST * |
segments, |
|
|
int |
x, |
|
|
int * |
margin |
|
) |
| |
Definition at line 274 of file ocrblock.cpp.
277 if (segments->empty())
279 ICOORDELT_IT seg_it(segments);
280 for (seg_it.mark_cycle_pt(); !seg_it.cycled_list(); seg_it.forward()) {
281 int cur_margin = seg_it.data()->x() + seg_it.data()->y() - x;
282 if (cur_margin >= 0) {
284 *margin = cur_margin;
285 }
else if (cur_margin < *margin) {
286 *margin = cur_margin;