@@ -459,16 +459,16 @@ bool Textord::clean_noise_from_row( //remove empties
459
459
ROW* row // row to clean
460
460
) {
461
461
bool testing_on;
462
- TBOX blob_box; // bounding box
462
+ TBOX blob_box; // bounding box
463
463
C_BLOB *blob; // current blob
464
464
C_OUTLINE *outline ; // current outline
465
465
WERD *word; // current word
466
- int32_t blob_size; // biggest size
467
- int32_t trans_count = 0 ; // no of transitions
468
- int32_t trans_threshold; // noise tolerance
469
- int32_t dot_count; // small objects
470
- int32_t norm_count; // normal objects
471
- int32_t super_norm_count; // real char-like
466
+ int32_t blob_size; // biggest size
467
+ int32_t trans_count = 0 ; // no of transitions
468
+ int32_t trans_threshold; // noise tolerance
469
+ int32_t dot_count; // small objects
470
+ int32_t norm_count; // normal objects
471
+ int32_t super_norm_count; // real char-like
472
472
// words of row
473
473
WERD_IT word_it = row->word_list ();
474
474
C_BLOB_IT blob_it; // blob iterator
@@ -559,19 +559,18 @@ bool Textord::clean_noise_from_row( //remove empties
559
559
void Textord::clean_noise_from_words ( // remove empties
560
560
ROW *row // row to clean
561
561
) {
562
- TBOX blob_box; // bounding box
563
- int8_t *word_dud; // was it chucked
562
+ TBOX blob_box; // bounding box
564
563
C_BLOB *blob; // current blob
565
564
C_OUTLINE *outline ; // current outline
566
565
WERD *word; // current word
567
- int32_t blob_size; // biggest size
568
- int32_t trans_count; // no of transitions
569
- int32_t trans_threshold; // noise tolerance
570
- int32_t dot_count; // small objects
571
- int32_t norm_count; // normal objects
572
- int32_t dud_words; // number discarded
573
- int32_t ok_words; // number remaining
574
- int32_t word_index; // current word
566
+ int32_t blob_size; // biggest size
567
+ int32_t trans_count; // no of transitions
568
+ int32_t trans_threshold; // noise tolerance
569
+ int32_t dot_count; // small objects
570
+ int32_t norm_count; // normal objects
571
+ int32_t dud_words; // number discarded
572
+ int32_t ok_words; // number remaining
573
+ int32_t word_index; // current word
575
574
// words of row
576
575
WERD_IT word_it = row->word_list ();
577
576
C_BLOB_IT blob_it; // blob iterator
@@ -580,7 +579,8 @@ void Textord::clean_noise_from_words( //remove empties
580
579
ok_words = word_it.length ();
581
580
if (ok_words == 0 || textord_no_rejects)
582
581
return ;
583
- word_dud = (int8_t *) alloc_mem (ok_words * sizeof (int8_t ));
582
+ // was it chucked
583
+ std::vector<int8_t > word_dud (ok_words);
584
584
dud_words = 0 ;
585
585
ok_words = 0 ;
586
586
word_index = 0 ;
@@ -664,7 +664,6 @@ void Textord::clean_noise_from_words( //remove empties
664
664
}
665
665
word_index++;
666
666
}
667
- free_mem (word_dud);
668
667
}
669
668
670
669
// Remove outlines that are a tiny fraction in either width or height
@@ -885,8 +884,6 @@ void tweak_row_baseline(ROW *row,
885
884
int32_t blob_count; // no of blobs
886
885
int32_t src_index; // source segment
887
886
int32_t dest_index; // destination segment
888
- int32_t *xstarts; // spline segments
889
- double *coeffs; // spline coeffs
890
887
float ydiff; // baseline error
891
888
float x_centre; // centre of blob
892
889
// words of row
@@ -901,12 +898,10 @@ void tweak_row_baseline(ROW *row,
901
898
}
902
899
if (blob_count == 0 )
903
900
return ;
904
- xstarts =
905
- (int32_t *) alloc_mem ((blob_count + row->baseline .segments + 1 ) *
906
- sizeof (int32_t ));
907
- coeffs =
908
- (double *) alloc_mem ((blob_count + row->baseline .segments ) * 3 *
909
- sizeof (double ));
901
+ // spline segments
902
+ std::vector<int32_t > xstarts (blob_count + row->baseline .segments + 1 );
903
+ // spline coeffs
904
+ std::vector<double > coeffs ((blob_count + row->baseline .segments ) * 3 );
910
905
911
906
src_index = 0 ;
912
907
dest_index = 0 ;
@@ -978,7 +973,5 @@ void tweak_row_baseline(ROW *row,
978
973
xstarts[dest_index] = row->baseline .xcoords [src_index];
979
974
}
980
975
// turn to spline
981
- row->baseline = QSPLINE (dest_index, xstarts, coeffs);
982
- free_mem (xstarts);
983
- free_mem (coeffs);
976
+ row->baseline = QSPLINE (dest_index, &xstarts[0 ], &coeffs[0 ]);
984
977
}
0 commit comments