Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flexfx.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Filename: flexfx.c
3 ** Purpose: Interface to flexible feature extractor.
4 ** Author: Dan Johnson
5 ** History: Wed May 23 13:45:10 1990, DSJ, Created.
6 **
7 ** (c) Copyright Hewlett-Packard Company, 1988.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 ******************************************************************************/
21 #include "flexfx.h"
22 #include "featdefs.h"
23 #include "emalloc.h"
24 #include <string.h>
25 #include <stdio.h>
26
30 /*---------------------------------------------------------------------------*/
31 CHAR_DESC ExtractFlexFeatures(const FEATURE_DEFS_STRUCT &FeatureDefs,
32 TBLOB *Blob, const DENORM& denorm) {
33 /*
34 ** Parameters:
35 ** Blob blob to extract features from
36 ** denorm control parameter for feature extractor
37 ** Globals: none
38 ** Operation: Allocate a new character descriptor and fill it in by
39 ** calling all feature extractors which are enabled.
40 ** Return: Structure containing features extracted from Blob.
41 ** Exceptions: none
42 ** History: Wed May 23 13:46:22 1990, DSJ, Created.
43 */
44 int Type;
45 CHAR_DESC CharDesc;
46
47 CharDesc = NewCharDescription(FeatureDefs);
48
49 for (Type = 0; Type < CharDesc->NumFeatureSets; Type++)
50 if (FeatureDefs.FeatureExtractors[Type] != NULL &&
51 FeatureDefs.FeatureExtractors[Type]->Extractor != NULL) {
52 CharDesc->FeatureSets[Type] =
53 (FeatureDefs.FeatureExtractors[Type])->Extractor(Blob, denorm);
54 if (CharDesc->FeatureSets[Type] == NULL) {
55 FreeCharDescription(CharDesc);
56 return NULL;
57 }
58 }
59
60 return (CharDesc);
61
62 } /* ExtractFlexFeatures */