Tesseract  3.02
tesseract-ocr/classify/featdefs.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  **     Filename:    featdefs.h
00003  **     Purpose:     Definitions of currently defined feature types.
00004  **     Author:      Dan Johnson
00005  **     History:     Mon May 21 08:28:01 1990, DSJ, Created.
00006  **
00007  **     (c) Copyright Hewlett-Packard Company, 1988.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  ******************************************************************************/
00018 #ifndef   FEATDEFS_H
00019 #define   FEATDEFS_H
00020 
00024 #include "ocrfeatures.h"
00025 
00026 /* Enumerate the different types of features currently defined. */
00027 #define NUM_FEATURE_TYPES 4
00028 extern const char* kMicroFeatureType;
00029 extern const char* kCNFeatureType;
00030 extern const char* kIntFeatureType;
00031 extern const char* kGeoFeatureType;
00032 
00033 /* define error traps which can be triggered by this module.*/
00034 #define ILLEGAL_SHORT_NAME  2000
00035 
00036 /* A character is described by multiple sets of extracted features.  Each
00037   set contains a number of features of a particular type, for example, a
00038   set of bays, or a set of closures, or a set of microfeatures.  Each
00039   feature consists of a number of parameters.  All features within a
00040   feature set contain the same number of parameters.*/
00041 
00042 struct CHAR_DESC_STRUCT {
00043   uinT32 NumFeatureSets;
00044   FEATURE_SET FeatureSets[NUM_FEATURE_TYPES];
00045 };
00046 typedef CHAR_DESC_STRUCT *CHAR_DESC;
00047 
00048 struct FEATURE_DEFS_STRUCT {
00049   uinT32 NumFeatureTypes;
00050   const FEATURE_DESC_STRUCT* FeatureDesc[NUM_FEATURE_TYPES];
00051   const FEATURE_EXT_STRUCT* FeatureExtractors[NUM_FEATURE_TYPES];
00052   int FeatureEnabled[NUM_FEATURE_TYPES];
00053 };
00054 typedef FEATURE_DEFS_STRUCT *FEATURE_DEFS;
00055 
00056 /*----------------------------------------------------------------------
00057     Generic functions for manipulating character descriptions
00058 ----------------------------------------------------------------------*/
00059 void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs);
00060 
00061 void FreeCharDescription(CHAR_DESC CharDesc);
00062 
00063 CHAR_DESC NewCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs);
00064 
00065 bool ValidCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs,
00066                           CHAR_DESC CharDesc);
00067 
00068 void WriteCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs,
00069                           FILE *File, CHAR_DESC CharDesc);
00070 
00071 CHAR_DESC ReadCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs,
00072                               FILE *File);
00073 
00074 int ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs,
00075                            const char *ShortName);
00076 
00080 extern const FEATURE_DESC_STRUCT MicroFeatureDesc;
00081 extern const FEATURE_DESC_STRUCT PicoFeatDesc;
00082 extern const FEATURE_DESC_STRUCT CharNormDesc;
00083 extern const FEATURE_DESC_STRUCT OutlineFeatDesc;
00084 extern const FEATURE_DESC_STRUCT IntFeatDesc;
00085 extern const FEATURE_DESC_STRUCT GeoFeatDesc;
00086 #endif