ccmain/blobcmp.cpp File Reference

#include "mfcpch.h"
#include "fxdefs.h"
#include "ocrfeatures.h"
#include "intmatcher.h"
#include "intproto.h"
#include "adaptive.h"
#include "adaptmatch.h"
#include "const.h"
#include "tessvars.h"

Go to the source code of this file.

Defines

Functions


Define Documentation

#define CMP_CLASS   'x'

Note:
File: blobcmp.cpp (Formerly blobcmp.c)
Code to compare blobs using the adaptive matcher.
Author:
Ray Smith
Date:
Wed Apr 21 09:28:51 BST 1993
 * (C) Copyright 1993, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 29 of file blobcmp.cpp.

Referenced by compare_tess_blobs().


Function Documentation

float compare_tess_blobs ( TBLOB blob1,
TEXTROW row1,
TBLOB blob2,
TEXTROW row2 
)

Match 2 blobs using the adaptive classifier.

Not called during normal recognition in v1.02

Definition at line 36 of file blobcmp.cpp.

References AllConfigsOn, AllProtosOn, ClassForClassId, CMP_CLASS, EnterClassifyMode, free_adapted_templates(), FreeBitVector(), FreeFeatureSet(), GetAdaptiveFeatures(), GetLineStatsFromRow(), IntegerMatcher(), MakeNewAdaptedClass(), MAX_FLOAT32, MAX_NUM_CONFIGS, MAX_NUM_PROTOS, NewAdaptedTemplates(), NewBitVector(), INT_RESULT_STRUCT::Rating, set_all_bits, SetBaseLineMatch(), ADAPT_TEMPLATES_STRUCT::Templates, and WordsInVectorOfSize.

Referenced by compare_bln_blobs().

00039                                         {
00040   int fcount;                    /*number of features */
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;  /*output */
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                                  /*copy baseline stuff */
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 }


Generated on Wed Feb 28 19:49:13 2007 for Tesseract by  doxygen 1.5.1