00001
00019 #include "mfcpch.h"
00020 #include "fxdefs.h"
00021 #include "ocrfeatures.h"
00022 #include "intmatcher.h"
00023 #include "intproto.h"
00024 #include "adaptive.h"
00025 #include "adaptmatch.h"
00026 #include "const.h"
00027 #include "tessvars.h"
00028
00029 #define CMP_CLASS 'x'
00030
00036 float compare_tess_blobs(TBLOB *blob1,
00037 TEXTROW *row1,
00038 TBLOB *blob2,
00039 TEXTROW *row2) {
00040 int fcount;
00041 ADAPT_TEMPLATES ad_templates;
00042 LINE_STATS line_stats1, line_stats2;
00043 INT_FEATURE_ARRAY int_features;
00044 FEATURE_SET float_features;
00045 INT_RESULT_STRUCT int_result;
00046
00047 BIT_VECTOR AllProtosOn = NewBitVector (MAX_NUM_PROTOS);
00048 BIT_VECTOR AllConfigsOn = NewBitVector (MAX_NUM_CONFIGS);
00049 set_all_bits (AllProtosOn, WordsInVectorOfSize (MAX_NUM_PROTOS));
00050 set_all_bits (AllConfigsOn, WordsInVectorOfSize (MAX_NUM_CONFIGS));
00051
00052 EnterClassifyMode;
00053 ad_templates = NewAdaptedTemplates ();
00054 GetLineStatsFromRow(row1, &line_stats1);
00055
00056 GetLineStatsFromRow(row2, &line_stats2);
00057 MakeNewAdaptedClass(blob1, &line_stats1, CMP_CLASS, ad_templates);
00058 fcount = GetAdaptiveFeatures (blob2, &line_stats2,
00059 int_features, &float_features);
00060 if (fcount > 0) {
00061 SetBaseLineMatch();
00062 IntegerMatcher (ClassForClassId (ad_templates->Templates, CMP_CLASS),
00063 AllProtosOn, AllConfigsOn, fcount, fcount,
00064 int_features, 0, 0, &int_result, testedit_match_debug);
00065 FreeFeatureSet(float_features);
00066 if (int_result.Rating < 0)
00067 int_result.Rating = MAX_FLOAT32;
00068 }
00069
00070 free_adapted_templates(ad_templates);
00071 FreeBitVector(AllConfigsOn);
00072 FreeBitVector(AllProtosOn);
00073
00074 return fcount > 0 ? int_result.Rating * fcount : MAX_FLOAT32;
00075 }