tesseract v5.3.3.20231005
featdefs.h
Go to the documentation of this file.
1/******************************************************************************
2 ** Filename: featdefs.h
3 ** Purpose: Definitions of currently defined feature types.
4 ** Author: Dan Johnson
5 **
6 ** (c) Copyright Hewlett-Packard Company, 1988.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 ******************************************************************************/
17
18#ifndef FEATDEFS_H
19#define FEATDEFS_H
20
21#include "ocrfeatures.h"
22
23#include <array> // for std::array
24#include <string> // for std::string
25
26namespace tesseract {
27
28/* Enumerate the different types of features currently defined. */
29#define NUM_FEATURE_TYPES 4
30extern TESS_API const char *const kMicroFeatureType;
31extern TESS_API const char *const kCNFeatureType;
32extern TESS_API const char *const kIntFeatureType;
33extern TESS_API const char *const kGeoFeatureType;
34
35/* A character is described by multiple sets of extracted features. Each
36 set contains a number of features of a particular type, for example, a
37 set of bays, or a set of closures, or a set of microfeatures. Each
38 feature consists of a number of parameters. All features within a
39 feature set contain the same number of parameters.*/
40
44};
46
51 NumFeatureSets = FeatureDefs.NumFeatureTypes;
52 }
53
57 for (size_t i = 0; i < NumFeatureSets; i++) {
58 delete FeatureSets[i];
59 }
60 }
61
63 std::array<FEATURE_SET_STRUCT *, NUM_FEATURE_TYPES> FeatureSets;
64};
65
66/*----------------------------------------------------------------------
67 Generic functions for manipulating character descriptions
68----------------------------------------------------------------------*/
70void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs);
71
72bool ValidCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, CHAR_DESC_STRUCT *CharDesc);
73
74void WriteCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, CHAR_DESC_STRUCT *CharDesc, std::string &str);
75
78
80uint32_t ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, const char *ShortName);
81
91
92} // namespace tesseract
93
94#endif
#define NUM_FEATURE_TYPES
Definition: featdefs.h:29
const char *const kCNFeatureType
Definition: featdefs.cpp:34
uint32_t ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, const char *ShortName)
Definition: featdefs.cpp:203
CHAR_DESC_STRUCT * ReadCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, FILE *File)
Definition: featdefs.cpp:172
bool ValidCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, CHAR_DESC_STRUCT *CharDesc)
Definition: featdefs.cpp:131
const FEATURE_DESC_STRUCT GeoFeatDesc
TESS_API const FEATURE_DESC_STRUCT PicoFeatDesc
const char *const kGeoFeatureType
Definition: featdefs.cpp:36
void WriteCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, CHAR_DESC_STRUCT *CharDesc, std::string &str)
Definition: featdefs.cpp:109
const FEATURE_DESC_STRUCT IntFeatDesc
const char *const kIntFeatureType
Definition: featdefs.cpp:35
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
Definition: featdefs.cpp:87
const FEATURE_DESC_STRUCT CharNormDesc
const char *const kMicroFeatureType
Definition: featdefs.cpp:33
const FEATURE_DESC_STRUCT OutlineFeatDesc
const FEATURE_DESC_STRUCT MicroFeatureDesc
const FEATURE_DESC_STRUCT * FeatureDesc[NUM_FEATURE_TYPES]
Definition: featdefs.h:43
CHAR_DESC_STRUCT(const FEATURE_DEFS_STRUCT &FeatureDefs)
Definition: featdefs.h:50
std::array< FEATURE_SET_STRUCT *, NUM_FEATURE_TYPES > FeatureSets
Definition: featdefs.h:63
#define TESS_API
Definition: export.h:32