classify/featdefs.h File Reference

#include "ocrfeatures.h"

Go to the source code of this file.

Classes

Defines

Typedefs

Functions

Variables


Define Documentation

#define DefinitionOf ( Type   )     (FeatureDefs.FeatureDesc[Type])

Definition at line 90 of file featdefs.h.

Referenced by ReadCharDescription(), SetUpForClustering(), ShortNameToFeatureType(), WriteCharDescription(), and WriteTrainingSamples().

#define ExtractorOf ( Type   )     (FeatureDefs.FeatureExtractors[Type])

Definition at line 91 of file featdefs.h.

Referenced by ExtractFlexFeatures(), InitFlexFXVars(), and SetupExtractors().

#define FeatureOn ( Type   )     (FeatureDefs.FeatureEnabled[Type])

Definition at line 92 of file featdefs.h.

#define FeaturesOfType ( Char,
Type   )     ((Char)->FeatureSets[Type])

Definition at line 98 of file featdefs.h.

Referenced by ExtractFlexFeatures(), FreeCharDescription(), NewCharDescription(), ReadCharDescription(), ReadTrainingSamples(), and WriteCharDescription().

#define ILLEGAL_SHORT_NAME   2000

define error traps which can be triggered by this module.

Definition at line 32 of file featdefs.h.

Referenced by ShortNameToFeatureType().

#define NUM_FEATURE_TYPES   4

Enumerate the different types of features currently defined.

Definition at line 29 of file featdefs.h.

Referenced by SetupExtractors().

 
#define NumFeaturesDefined (  )     (FeatureDefs.NumFeatureTypes)

Definition at line 89 of file featdefs.h.

Referenced by InitFlexFXVars(), NewCharDescription(), ReadCharDescription(), and ShortNameToFeatureType().

#define NumFeatureSetsIn ( Char   )     ((Char)->NumFeatureSets)

Definition at line 97 of file featdefs.h.

Referenced by ExtractFlexFeatures(), FreeCharDescription(), NewCharDescription(), ReadTrainingSamples(), and WriteCharDescription().


Typedef Documentation

CHAR_DESC

Pointer to CHAR_DESC_STRUCT, character description in terms of multiple sets of extracted features.

Definition at line 58 of file featdefs.h.

FEATURE_DEFS

Pointer to FEATURE_DEFS_STRUCT, info on activated types of features.

Definition at line 84 of file featdefs.h.


Function Documentation

void FreeCharDescription ( CHAR_DESC  CharDesc  ) 

Release the memory consumed by the specified character description and all of the features in that description.

Parameters:
CharDesc Character description to be deallocated
Returns:
none
Note:
Exceptions: none
Date:
Wed May 23 13:52:19 1990, DSJ, Created.

Definition at line 115 of file featdefs.cpp.

References Efree(), FeaturesOfType, FreeFeatureSet(), and NumFeatureSetsIn.

Referenced by LearnBlob().

00115                                              {
00116   int i;
00117 
00118   if (CharDesc) {
00119     for (i = 0; i < NumFeatureSetsIn (CharDesc); i++)
00120       FreeFeatureSet (FeaturesOfType (CharDesc, i));
00121     Efree(CharDesc);
00122   }
00123 }                                /* FreeCharDescription */

CHAR_DESC NewCharDescription (  ) 

Allocate a new character description, initialize its feature sets to be empty, and return it.

Parameters:
none 
Returns:
New character description structure.
Note:
Exceptions: none
Date:
Wed May 23 15:27:10 1990, DSJ, Created.

Definition at line 135 of file featdefs.cpp.

References Emalloc(), FeaturesOfType, NULL, NumFeaturesDefined, and NumFeatureSetsIn.

Referenced by ExtractFlexFeatures(), and ReadCharDescription().

00135                                {
00136   CHAR_DESC CharDesc;
00137   int i;
00138 
00139   CharDesc = (CHAR_DESC) Emalloc (sizeof (CHAR_DESC_STRUCT));
00140   NumFeatureSetsIn (CharDesc) = NumFeaturesDefined ();
00141 
00142   for (i = 0; i < NumFeatureSetsIn (CharDesc); i++)
00143     FeaturesOfType (CharDesc, i) = NULL;
00144 
00145   return (CharDesc);
00146 
00147 }                                /* NewCharDescription */

CHAR_DESC ReadCharDescription ( FILE *  File  ) 

Read a character description from File, and return a data structure containing this information.

Parameters:
File Open text file to read character description from
Returns:
Character description read from File.
The data is formatted as follows:
    NumberOfSets
   	    ShortNameForSet1 Set1
        ShortNameForSet2 Set2
        ...
Note:
Exceptions: ILLEGAL_NUM_SETS
Date:
Wed May 23 17:32:48 1990, DSJ, Created.

Definition at line 201 of file featdefs.cpp.

References DefinitionOf, DoError(), FEAT_NAME_SIZE, FeaturesOfType, fscanf(), ILLEGAL_NUM_SETS, NewCharDescription(), NumFeaturesDefined, ReadFeatureSet(), and ShortNameToFeatureType().

Referenced by ReadTrainingSamples().

00201                                           {
00202   int NumSetsToRead;
00203   char ShortName[FEAT_NAME_SIZE];
00204   CHAR_DESC CharDesc;
00205   int Type;
00206 
00207   if (fscanf (File, "%d", &NumSetsToRead) != 1 ||
00208     NumSetsToRead < 0 || NumSetsToRead > NumFeaturesDefined ())
00209     DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets");
00210 
00211   CharDesc = NewCharDescription ();
00212   for (; NumSetsToRead > 0; NumSetsToRead--) {
00213     fscanf (File, "%s", ShortName);
00214     Type = ShortNameToFeatureType (ShortName);
00215     FeaturesOfType (CharDesc, Type) =
00216       ReadFeatureSet (File, DefinitionOf (Type));
00217   }
00218   return (CharDesc);
00219 
00220 }                                // ReadCharDescription

int ShortNameToFeatureType ( const char *  ShortName  ) 

Search thru all features currently defined and return the feature type for the feature with the specified short name.

Parameters:
ShortName Short name of a feature type
Returns:
Feature type which corresponds to ShortName.
Trap an error if the specified name is not found.
Note:
Exceptions: ILLEGAL_SHORT_NAME
Date:
Wed May 23 15:36:05 1990, DSJ, Created.
Note:
param was made const for v1.03

Definition at line 236 of file featdefs.cpp.

References DefinitionOf, DoError(), ILLEGAL_SHORT_NAME, NumFeaturesDefined, and ShortNameOf.

Referenced by ReadCharDescription(), ReadTrainingSamples(), SetUpForClustering(), and WriteTrainingSamples().

00236                                                   {
00237   int i;
00238 
00239   for (i = 0; i < NumFeaturesDefined (); i++)
00240     if (!strcmp (ShortNameOf (DefinitionOf (i)), ShortName))
00241       return (i);
00242   DoError (ILLEGAL_SHORT_NAME, "Illegal short name for a feature");
00243   return 0;
00244 
00245 }                                // ShortNameToFeatureType

void WriteCharDescription ( FILE *  File,
CHAR_DESC  CharDesc 
)

Write a textual representation of CharDesc to File.

Parameters:
File Open text file to write CharDesc to
CharDesc Character description to write to File
Returns:
none
The format used is to write out the number of feature sets which will be written followed by a representation of each feature set.

Each set starts with the short name for that feature followed by a description of the feature set. Feature sets which are not present are not written.

Note:
Exceptions: none
Date:
Wed May 23 17:21:18 1990, DSJ, Created.

Definition at line 167 of file featdefs.cpp.

References DefinitionOf, FeaturesOfType, NumFeatureSetsIn, ShortNameOf, and WriteFeatureSet().

Referenced by LearnBlob().

00167                                                           {
00168   int Type;
00169   int NumSetsToWrite = 0;
00170 
00171   for (Type = 0; Type < NumFeatureSetsIn (CharDesc); Type++)
00172     if (FeaturesOfType (CharDesc, Type))
00173       NumSetsToWrite++;
00174 
00175   fprintf (File, " %d\n", NumSetsToWrite);
00176   for (Type = 0; Type < NumFeatureSetsIn (CharDesc); Type++)
00177   if (FeaturesOfType (CharDesc, Type)) {
00178     fprintf (File, "%s ", ShortNameOf (DefinitionOf (Type)));
00179     WriteFeatureSet (File, FeaturesOfType (CharDesc, Type));
00180   }
00181 }                                /* WriteCharDescription */


Variable Documentation

FEATURE_DEFS_STRUCT FeatureDefs

Definition at line 93 of file featdefs.cpp.


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