tesseract
3.03
|
00001 /****************************************************************************** 00002 ** Filename: flexfx.c 00003 ** Purpose: Interface to flexible feature extractor. 00004 ** Author: Dan Johnson 00005 ** History: Wed May 23 13:45:10 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 ******************************************************************************/ 00021 #include "flexfx.h" 00022 #include "featdefs.h" 00023 #include "emalloc.h" 00024 #include <string.h> 00025 #include <stdio.h> 00026 00030 /*---------------------------------------------------------------------------*/ 00031 // Deprecated! Will be deleted soon! 00032 // In the meantime, as all TBLOBs, Blob is in baseline normalized coords. 00033 // See SetupBLCNDenorms in intfx.cpp for other args. 00034 CHAR_DESC ExtractFlexFeatures(const FEATURE_DEFS_STRUCT &FeatureDefs, 00035 TBLOB *Blob, const DENORM& bl_denorm, 00036 const DENORM& cn_denorm, 00037 const INT_FX_RESULT_STRUCT& fx_info) { 00038 /* 00039 ** Parameters: 00040 ** Blob blob to extract features from 00041 ** denorm control parameter for feature extractor 00042 ** Globals: none 00043 ** Operation: Allocate a new character descriptor and fill it in by 00044 ** calling all feature extractors which are enabled. 00045 ** Return: Structure containing features extracted from Blob. 00046 ** Exceptions: none 00047 ** History: Wed May 23 13:46:22 1990, DSJ, Created. 00048 */ 00049 int Type; 00050 CHAR_DESC CharDesc; 00051 00052 CharDesc = NewCharDescription(FeatureDefs); 00053 00054 for (Type = 0; Type < CharDesc->NumFeatureSets; Type++) 00055 if (FeatureDefs.FeatureExtractors[Type] != NULL && 00056 FeatureDefs.FeatureExtractors[Type]->Extractor != NULL) { 00057 CharDesc->FeatureSets[Type] = 00058 (FeatureDefs.FeatureExtractors[Type])->Extractor(Blob, 00059 bl_denorm, 00060 cn_denorm, 00061 fx_info); 00062 if (CharDesc->FeatureSets[Type] == NULL) { 00063 tprintf("Feature extractor for type %d = %s returned NULL!\n", 00064 Type, FeatureDefs.FeatureDesc[Type]->ShortName); 00065 FreeCharDescription(CharDesc); 00066 return NULL; 00067 } 00068 } 00069 00070 return (CharDesc); 00071 00072 } /* ExtractFlexFeatures */