float CHAR_SAMPLE::match_sample( // Update match scores CHAR_SAMPLE *test_sample, BOOL8 updating) { float score1; float score2; IMAGE *image = test_sample->image (); if (sample_blob != NULL && test_sample->blob () != NULL) { PBLOB *blob = test_sample->blob (); DENORM *denorm = test_sample->denorm (); score1 = compare_bln_blobs (sample_blob, sample_denorm, blob, denorm); score2 = compare_bln_blobs (blob, denorm, sample_blob, sample_denorm); score1 = (score1 > score2) ? score1 : score2; } else if (sample_image != NULL && image != NULL) { CHAR_PROTO *sample = new CHAR_PROTO (this); score1 = matrix_match (sample_image, image); delete sample; } else return BAD_SCORE; if ((tessedit_use_best_sample || tessedit_cluster_debug) && updating) { n_samples_matched++; total_match_scores += score1; sumsq_match_scores += score1 * score1; } return score1; }
float Tesseract::compare_blobs( //match 2 blobs PBLOB *blob1, //first blob ROW *row1, //row it came from PBLOB *blob2, //other blob ROW *row2) { PBLOB *bn_blob1; //baseline norm PBLOB *bn_blob2; DENORM denorm1, denorm2; float rating; //match result bn_blob1 = blob1->baseline_normalise (row1, &denorm1); bn_blob2 = blob2->baseline_normalise (row2, &denorm2); rating = compare_bln_blobs (bn_blob1, &denorm1, bn_blob2, &denorm2); delete bn_blob1; delete bn_blob2; return rating; }