@@ -120,8 +120,8 @@ PAGE_RES* Tesseract::ApplyBoxes(const STRING& fname,
120
120
GenericVector<TBOX> boxes;
121
121
GenericVector<STRING> texts, full_texts;
122
122
if (!ReadAllBoxes (applybox_page, true , fname, &boxes, &texts, &full_texts,
123
- NULL )) {
124
- return NULL ; // Can't do it.
123
+ nullptr )) {
124
+ return nullptr ; // Can't do it.
125
125
}
126
126
127
127
int box_count = boxes.size ();
@@ -134,14 +134,14 @@ PAGE_RES* Tesseract::ApplyBoxes(const STRING& fname,
134
134
// In word mode, we use the boxes to make a word for each box, but
135
135
// in blob mode we use the existing words and maximally chop them first.
136
136
PAGE_RES* page_res = find_segmentation ?
137
- NULL : SetupApplyBoxes (boxes, block_list);
137
+ nullptr : SetupApplyBoxes (boxes, block_list);
138
138
clear_any_old_text (block_list);
139
139
140
140
for (int i = 0 ; i < boxes.size () - 1 ; i++) {
141
141
bool foundit = false ;
142
- if (page_res != NULL ) {
142
+ if (page_res != nullptr ) {
143
143
if (i == 0 ) {
144
- foundit = ResegmentCharBox (page_res, NULL , boxes[i], boxes[i + 1 ],
144
+ foundit = ResegmentCharBox (page_res, nullptr , boxes[i], boxes[i + 1 ],
145
145
full_texts[i].string ());
146
146
} else {
147
147
foundit = ResegmentCharBox (page_res, &boxes[i-1 ], boxes[i],
@@ -158,7 +158,7 @@ PAGE_RES* Tesseract::ApplyBoxes(const STRING& fname,
158
158
}
159
159
}
160
160
161
- if (page_res == NULL ) {
161
+ if (page_res == nullptr ) {
162
162
// In word/line mode, we now maximally chop all the words and resegment
163
163
// them with the classifier.
164
164
page_res = SetupApplyBoxes (boxes, block_list);
@@ -236,10 +236,10 @@ PAGE_RES* Tesseract::SetupApplyBoxes(const GenericVector<TBOX>& boxes,
236
236
}
237
237
}
238
238
}
239
- PAGE_RES* page_res = new PAGE_RES (false , block_list, NULL );
239
+ PAGE_RES* page_res = new PAGE_RES (false , block_list, nullptr );
240
240
PAGE_RES_IT pr_it (page_res);
241
241
WERD_RES* word_res;
242
- while ((word_res = pr_it.word ()) != NULL ) {
242
+ while ((word_res = pr_it.word ()) != nullptr ) {
243
243
MaximallyChopWord (boxes, pr_it.block ()->block ,
244
244
pr_it.row ()->row , word_res);
245
245
pr_it.forward ();
@@ -254,7 +254,7 @@ void Tesseract::MaximallyChopWord(const GenericVector<TBOX>& boxes,
254
254
BLOCK* block, ROW* row,
255
255
WERD_RES* word_res) {
256
256
if (!word_res->SetupForRecognition (unicharset, this , BestPix (),
257
- tessedit_ocr_engine_mode, NULL ,
257
+ tessedit_ocr_engine_mode, nullptr ,
258
258
classify_bln_numeric_mode,
259
259
textord_use_cjk_fp_model,
260
260
poly_allow_detailed_fx,
@@ -288,9 +288,9 @@ void Tesseract::MaximallyChopWord(const GenericVector<TBOX>& boxes,
288
288
int right_chop_index = 0 ;
289
289
if (!assume_fixed_pitch_char_segment) {
290
290
// We only chop if the language is not fixed pitch like CJK.
291
- SEAM* seam = NULL ;
291
+ SEAM* seam = nullptr ;
292
292
while ((seam = chop_one_blob (boxes, blob_choices, word_res,
293
- &blob_number)) != NULL ) {
293
+ &blob_number)) != nullptr ) {
294
294
word_res->InsertSeam (blob_number, seam);
295
295
BLOB_CHOICE* left_choice = blob_choices[blob_number];
296
296
rating = left_choice->rating () / e;
@@ -345,7 +345,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES* page_res, const TBOX *prev_box,
345
345
}
346
346
PAGE_RES_IT page_res_it (page_res);
347
347
WERD_RES* word_res;
348
- for (word_res = page_res_it.word (); word_res != NULL ;
348
+ for (word_res = page_res_it.word (); word_res != nullptr ;
349
349
word_res = page_res_it.forward ()) {
350
350
if (!word_res->box_word ->bounding_box ().major_overlap (box))
351
351
continue ;
@@ -381,7 +381,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES* page_res, const TBOX *prev_box,
381
381
}
382
382
if (!char_box.almost_equal (box, 3 ) &&
383
383
(box.x_gap (next_box) < -3 ||
384
- (prev_box != NULL && prev_box->x_gap (box) < -3 ))) {
384
+ (prev_box != nullptr && prev_box->x_gap (box) < -3 ))) {
385
385
return false ;
386
386
}
387
387
// We refine just the box_word, best_state and correct_text here.
@@ -441,7 +441,7 @@ bool Tesseract::ResegmentWordBox(BLOCK_LIST *block_list,
441
441
if (applybox_debug > 1 ) {
442
442
tprintf (" \n APPLY_BOX: in ResegmentWordBox() for %s\n " , correct_text);
443
443
}
444
- WERD* new_word = NULL ;
444
+ WERD* new_word = nullptr ;
445
445
BLOCK_IT b_it (block_list);
446
446
for (b_it.mark_cycle_pt (); !b_it.cycled_list (); b_it.forward ()) {
447
447
BLOCK* block = b_it.data ();
@@ -459,7 +459,7 @@ bool Tesseract::ResegmentWordBox(BLOCK_LIST *block_list,
459
459
tprintf (" Checking word:" );
460
460
word->bounding_box ().print ();
461
461
}
462
- if (word->text () != NULL && word->text ()[0 ] != ' \0 ' )
462
+ if (word->text () != nullptr && word->text ()[0 ] != ' \0 ' )
463
463
continue ; // Ignore words that are already done.
464
464
if (!box.major_overlap (word->bounding_box ()))
465
465
continue ;
@@ -488,7 +488,7 @@ bool Tesseract::ResegmentWordBox(BLOCK_LIST *block_list,
488
488
tprintf (" With next box:" );
489
489
next_box.print ();
490
490
}
491
- if (new_word == NULL ) {
491
+ if (new_word == nullptr ) {
492
492
// Make a new word with a single blob.
493
493
new_word = word->shallow_copy ();
494
494
new_word->set_text (correct_text);
@@ -500,18 +500,18 @@ bool Tesseract::ResegmentWordBox(BLOCK_LIST *block_list,
500
500
}
501
501
}
502
502
}
503
- if (new_word == NULL && applybox_debug > 0 ) tprintf (" FAIL!\n " );
504
- return new_word != NULL ;
503
+ if (new_word == nullptr && applybox_debug > 0 ) tprintf (" FAIL!\n " );
504
+ return new_word != nullptr ;
505
505
}
506
506
507
507
// / Resegments the words by running the classifier in an attempt to find the
508
508
// / correct segmentation that produces the required string.
509
509
void Tesseract::ReSegmentByClassification (PAGE_RES* page_res) {
510
510
PAGE_RES_IT pr_it (page_res);
511
511
WERD_RES* word_res;
512
- for (; (word_res = pr_it.word ()) != NULL ; pr_it.forward ()) {
512
+ for (; (word_res = pr_it.word ()) != nullptr ; pr_it.forward ()) {
513
513
WERD* word = word_res->word ;
514
- if (word->text () == NULL || word->text ()[0 ] == ' \0 ' )
514
+ if (word->text () == nullptr || word->text ()[0 ] == ' \0 ' )
515
515
continue ; // Ignore words that have no text.
516
516
// Convert the correct text to a vector of UNICHAR_ID
517
517
GenericVector<UNICHAR_ID> target_text;
@@ -536,7 +536,7 @@ bool Tesseract::ConvertStringToUnichars(const char* utf8,
536
536
GenericVector<UNICHAR_ID>* class_ids) {
537
537
for (int step = 0 ; *utf8 != ' \0 ' ; utf8 += step) {
538
538
const char * next_space = strchr (utf8, ' ' );
539
- if (next_space == NULL )
539
+ if (next_space == nullptr )
540
540
next_space = utf8 + strlen (utf8);
541
541
step = next_space - utf8;
542
542
UNICHAR_ID class_id = unicharset.unichar_to_id (utf8, step);
@@ -648,7 +648,7 @@ void Tesseract::SearchForText(const GenericVector<BLOB_CHOICE_LIST*>* choices,
648
648
break ;
649
649
}
650
650
// Search ambigs table.
651
- if (class_id < table.size () && table[class_id] != NULL ) {
651
+ if (class_id < table.size () && table[class_id] != nullptr ) {
652
652
AmbigSpec_IT spec_it (table[class_id]);
653
653
for (spec_it.mark_cycle_pt (); !spec_it.cycled_list ();
654
654
spec_it.forward ()) {
@@ -710,7 +710,7 @@ void Tesseract::TidyUp(PAGE_RES* page_res) {
710
710
int unlabelled_words = 0 ;
711
711
PAGE_RES_IT pr_it (page_res);
712
712
WERD_RES* word_res;
713
- for (; (word_res = pr_it.word ()) != NULL ; pr_it.forward ()) {
713
+ for (; (word_res = pr_it.word ()) != nullptr ; pr_it.forward ()) {
714
714
int ok_in_word = 0 ;
715
715
int blob_count = word_res->correct_text .size ();
716
716
WERD_CHOICE* word_choice = new WERD_CHOICE (word_res->uch_set , blob_count);
@@ -742,7 +742,7 @@ void Tesseract::TidyUp(PAGE_RES* page_res) {
742
742
}
743
743
}
744
744
pr_it.restart_page ();
745
- for (; (word_res = pr_it.word ()) != NULL ; pr_it.forward ()) {
745
+ for (; (word_res = pr_it.word ()) != nullptr ; pr_it.forward ()) {
746
746
// Denormalize back to a BoxWord.
747
747
word_res->RebuildBestState ();
748
748
word_res->SetupBoxWord ();
@@ -771,7 +771,7 @@ void Tesseract::ReportFailedBox(int boxfile_lineno, TBOX box,
771
771
/* * Creates a fake best_choice entry in each WERD_RES with the correct text.*/
772
772
void Tesseract::CorrectClassifyWords (PAGE_RES* page_res) {
773
773
PAGE_RES_IT pr_it (page_res);
774
- for (WERD_RES *word_res = pr_it.word (); word_res != NULL ;
774
+ for (WERD_RES *word_res = pr_it.word (); word_res != nullptr ;
775
775
word_res = pr_it.forward ()) {
776
776
WERD_CHOICE* choice = new WERD_CHOICE (word_res->uch_set ,
777
777
word_res->correct_text .size ());
@@ -796,7 +796,7 @@ void Tesseract::CorrectClassifyWords(PAGE_RES* page_res) {
796
796
void Tesseract::ApplyBoxTraining (const STRING& fontname, PAGE_RES* page_res) {
797
797
PAGE_RES_IT pr_it (page_res);
798
798
int word_count = 0 ;
799
- for (WERD_RES *word_res = pr_it.word (); word_res != NULL ;
799
+ for (WERD_RES *word_res = pr_it.word (); word_res != nullptr ;
800
800
word_res = pr_it.forward ()) {
801
801
LearnWord (fontname.string (), word_res);
802
802
++word_count;
0 commit comments