00001 /****************************************************************************** 00002 ** Filename: fxdefs.h 00003 ** Purpose: Generic interface definitions for feature extractors 00004 ** Author: Dan Johnson 00005 ** History: Fri Jan 19 09:04:14 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 FXDEFS_H 00019 #define FXDEFS_H 00020 00024 #include "tessclas.h" 00025 #include "general.h" 00026 00027 /* define different modes for feature extractor - learning vs. classifying */ 00028 #define LEARN_MODE 0 00029 #define CLASSIFY_MODE 1 00030 00031 /* define a data structure to hold line statistics. These line statistics 00032 are used to normalize character outlines to a standard size and position 00033 relative to the baseline of the text. */ 00034 typedef struct 00035 { 00036 SPLINE_SPEC *Baseline; /* collection of splines describing baseline */ 00037 SPLINE_SPEC *XHeightLine; /* collection of splines describing x-height */ 00038 FLOAT32 xheight; /* avg. distance from x-height to baseline */ 00039 FLOAT32 AscRise; /* avg. distance from ascenders to x-height */ 00040 FLOAT32 DescDrop; /* avg. distance from baseline to descenders */ 00041 /* always a negative number */ 00042 TEXTROW *TextRow; /* kludge - only needed by fx for fast matcher */ 00043 /* should be removed later */ 00044 } 00045 00046 00047 LINE_STATS; 00048 00049 /* define a generic character description as a char pointer. In reality, 00050 it will be a pointer to some data structure. Paired feature 00051 extractors/matchers need to agree on the data structure to be used, 00052 however, the high level classifier does not need to know the details 00053 of this data structure. */ 00054 typedef char *CHAR_FEATURES; 00055 00059 /* macro to change and monitor the mode of the feature extractor. 00060 In general, learn mode smears features which would otherwise be discrete 00061 in nature; classify mode does not.*/ 00062 #define SetExtractMode(M) (ExtractMode = (M)) 00063 #define EnterLearnMode (SetExtractMode (LEARN_MODE)) 00064 #define EnterClassifyMode (SetExtractMode (CLASSIFY_MODE)) 00065 00066 /*---------------------------------------------------------------------------- 00067 Public Function Prototypes 00068 -----------------------------------------------------------------------------*/ 00069 void SetupExtractors(); 00070 00071 void GetLineStatsFromRow(TEXTROW *Row, LINE_STATS *LineStats); 00072 00073 /* 00074 #if defined(__STDC__) || defined(__cplusplus) 00075 # define _ARGS(s) s 00076 #else 00077 # define _ARGS(s) () 00078 #endif*/ 00079 00080 /* fxdefs.c 00081 void GetLineStatsFromRow 00082 _ARGS((TEXTROW *Row, 00083 LINE_STATS *LineStats)); 00084 00085 #undef _ARGS 00086 */ 00087 00091 /* flag to control learn mode vs. classify mode */ 00092 extern int ExtractMode; 00093 #endif