#include "blobs.h"
#include <stdio.h>
Go to the source code of this file.
◆ DefineFeature
#define DefineFeature |
( |
|
Name, |
|
|
|
NL, |
|
|
|
NC, |
|
|
|
SN, |
|
|
|
PN |
|
) |
| |
◆ DefineParam
#define DefineParam |
( |
|
Circular, |
|
|
|
NonEssential, |
|
|
|
Min, |
|
|
|
Max |
|
) |
| |
Value:{Circular, NonEssential, Min, Max, \
(Max) - (Min), (((Max) - (Min))/2.0), (((Max) + (Min))/2.0)},
Definition at line 88 of file ocrfeatures.h.
◆ EndParamDesc
◆ FEAT_NAME_SIZE
#define FEAT_NAME_SIZE 80 |
◆ ILLEGAL_FEATURE_PARAM
#define ILLEGAL_FEATURE_PARAM 1000 |
◆ ILLEGAL_NUM_FEATURES
#define ILLEGAL_NUM_FEATURES 1001 |
◆ StartParamDesc
#define StartParamDesc |
( |
|
Name | ) |
const PARAM_DESC Name[] = { |
◆ CHAR_FEATURES
◆ FEATURE
◆ FEATURE_DESC
◆ FEATURE_SET
◆ AddFeature()
Add a feature to a feature set. If the feature set is already full, FALSE is returned to indicate that the feature could not be added to the set; otherwise, TRUE is returned.
- Parameters
-
FeatureSet | set of features to add Feature to |
Feature | feature to be added to FeatureSet |
- Returns
- TRUE if feature added to set, FALSE if set is already full.
- Note
- History: Tue May 22 17:22:23 1990, DSJ, Created.
Definition at line 44 of file ocrfeatures.cpp.
void FreeFeature(FEATURE Feature)
◆ FreeFeature()
void FreeFeature |
( |
FEATURE |
Feature | ) |
|
Release the memory consumed by the specified feature.
- Parameters
-
Feature | feature to be deallocated. |
- Returns
- none
- Note
- History: Mon May 21 13:33:27 1990, DSJ, Created.
Definition at line 60 of file ocrfeatures.cpp.
64 "sizeof(FEATURE_STRUCT)+sizeof(FLOAT32)*(NumParamsIn(Feature)-1)");
void free_struct(void *deadstruct, inT32, const char *)
const FEATURE_DESC_STRUCT * Type
◆ FreeFeatureSet()
Release the memory consumed by the specified feature set. This routine also frees the memory consumed by the features contained in the set.
- Parameters
-
FeatureSet | set of features to be freed |
- Returns
- none
- Note
- History: Mon May 21 13:59:46 1990, DSJ, Created.
Definition at line 77 of file ocrfeatures.cpp.
void FreeFeature(FEATURE Feature)
void memfree(void *element)
◆ NewFeature()
Allocate and return a new feature of the specified type.
- Parameters
-
FeatureDesc | description of feature to be created. |
- Returns
- New FEATURE.
- Note
- History: Mon May 21 14:06:42 1990, DSJ, Created.
Definition at line 94 of file ocrfeatures.cpp.
100 "sizeof(FEATURE_STRUCT)+sizeof(FLOAT32)*(NumParamsIn(Feature)-1)");
101 Feature->
Type = FeatureDesc;
const FEATURE_DESC_STRUCT * Type
void * alloc_struct(inT32 count, const char *)
◆ NewFeatureSet()
Allocate and return a new feature set large enough to hold the specified number of features.
- Parameters
-
NumFeatures | maximum # of features to be put in feature set |
- Returns
- New FEATURE_SET.
- Note
- History: Mon May 21 14:22:40 1990, DSJ, Created.
Definition at line 113 of file ocrfeatures.cpp.
117 (NumFeatures - 1) *
sizeof (
FEATURE));
FEATURE_SET_STRUCT * FEATURE_SET
◆ ReadFeature()
Create a new feature of the specified type and read in the value of its parameters from File. The extra penalty for the feature is also computed by calling the appropriate function for the specified feature type. The correct text representation for a feature is a list of N floats where N is the number of parameters in the feature.
- Parameters
-
File | open text file to read feature from |
FeatureDesc | specifies type of feature to read from File |
- Returns
- New FEATURE read from File.
- Note
- Exceptions: ILLEGAL_FEATURE_PARAM if text file doesn't match expected format
-
History: Wed May 23 08:53:16 1990, DSJ, Created.
Definition at line 138 of file ocrfeatures.cpp.
147 assert (!isnan(Feature->
Params[i]));
int tfscanf(FILE *stream, const char *format,...)
void DoError(int Error, const char *Message)
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
const FEATURE_DESC_STRUCT * Type
#define ILLEGAL_FEATURE_PARAM
◆ ReadFeatureSet()
Create a new feature set of the specified type and read in the features from File. The correct text representation for a feature set is an integer which specifies the number (N) of features in a set followed by a list of N feature descriptions.
- Parameters
-
File | open text file to read new feature set from |
FeatureDesc | specifies type of feature to read from File |
- Returns
- New feature set read from File.
- Note
- History: Wed May 23 09:17:31 1990, DSJ, Created.
Definition at line 164 of file ocrfeatures.cpp.
169 if (
tfscanf(File,
"%d", &NumFeatures) != 1 || NumFeatures < 0)
173 for (i = 0; i < NumFeatures; i++)
int tfscanf(FILE *stream, const char *format,...)
#define ILLEGAL_NUM_FEATURES
BOOL8 AddFeature(FEATURE_SET FeatureSet, FEATURE Feature)
void DoError(int Error, const char *Message)
FEATURE ReadFeature(FILE *File, const FEATURE_DESC_STRUCT *FeatureDesc)
FEATURE_SET NewFeatureSet(int NumFeatures)
◆ WriteFeature()
Appends a textual representation of Feature to str. This representation is simply a list of the N parameters of the feature, terminated with a newline. It is assumed that the ExtraPenalty field can be reconstructed from the parameters of the feature. It is also assumed that the feature type information is specified or assumed elsewhere.
- Parameters
-
Feature | feature to write out to str |
str | string to write Feature to |
- Returns
- none
- Note
- History: Wed May 23 09:28:18 1990, DSJ, Created.
Definition at line 191 of file ocrfeatures.cpp.
194 assert(!isnan(Feature->
Params[i]));
void add_str_double(const char *str, double number)
const FEATURE_DESC_STRUCT * Type
◆ WriteFeatureSet()
Write a textual representation of FeatureSet to File. This representation is an integer specifying the number of features in the set, followed by a newline, followed by text representations for each feature in the set.
- Parameters
-
FeatureSet | feature set to write to File |
str | string to write Feature to |
- Returns
- none
- Note
- History: Wed May 23 10:06:03 1990, DSJ, Created.
Definition at line 211 of file ocrfeatures.cpp.
215 for (
int i = 0; i < FeatureSet->
NumFeatures; i++) {
void WriteFeature(FEATURE Feature, STRING *str)
void add_str_int(const char *str, int number)