#include "featdefs.h"
#include "emalloc.h"
#include "danerror.h"
#include "scanutils.h"
#include "variables.h"
#include "sigmenu.h"
#include <string.h>
#include <stdio.h>
Go to the source code of this file.
#define ILLEGAL_NUM_SETS 3001 |
** (c) Copyright Hewlett-Packard Company, 1988. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.
Definition at line 34 of file featdefs.cpp.
Referenced by ReadCharDescription().
#define MAX_OUTLINE_FEATURES 100 |
#define PICO_FEATURE_LENGTH 0.05 |
EndParamDesc DefineFeature | ( | PicoFeatDesc | , | |
2 | , | |||
1 | , | |||
1 | , | |||
MAX_UINT8 | , | |||
"Pico" | , | |||
"pf" | , | |||
PicoFeatParams | ||||
) |
EndParamDesc DefineParam | ( | 0 | , | |
0 | , | |||
0. | 0, | |||
1. | 0 | |||
) |
DefineParam | ( | 0 | , | |
1 | , | |||
-0. | 5, | |||
0. | 5 | |||
) |
EndParamDesc CharNormParams DefineParam | ( | 1 | , | |
0 | , | |||
0. | 0, | |||
1. | 0 | |||
) |
EndParamDesc CharNormParams DefineParam | ( | 0 | , | |
0 | , | |||
-0. | 25, | |||
0. | 75 | |||
) |
void FreeCharDescription | ( | CHAR_DESC | CharDesc | ) |
Release the memory consumed by the specified character description and all of the features in that description.
CharDesc | Character description to be deallocated |
Definition at line 115 of file featdefs.cpp.
References Efree(), FeaturesOfType, FreeFeatureSet(), and NumFeatureSetsIn.
Referenced by LearnBlob().
00115 { 00116 int i; 00117 00118 if (CharDesc) { 00119 for (i = 0; i < NumFeatureSetsIn (CharDesc); i++) 00120 FreeFeatureSet (FeaturesOfType (CharDesc, i)); 00121 Efree(CharDesc); 00122 } 00123 } /* FreeCharDescription */
CHAR_DESC NewCharDescription | ( | ) |
Allocate a new character description, initialize its feature sets to be empty, and return it.
none |
Definition at line 135 of file featdefs.cpp.
References Emalloc(), FeaturesOfType, NULL, NumFeaturesDefined, and NumFeatureSetsIn.
Referenced by ExtractFlexFeatures(), and ReadCharDescription().
00135 { 00136 CHAR_DESC CharDesc; 00137 int i; 00138 00139 CharDesc = (CHAR_DESC) Emalloc (sizeof (CHAR_DESC_STRUCT)); 00140 NumFeatureSetsIn (CharDesc) = NumFeaturesDefined (); 00141 00142 for (i = 0; i < NumFeatureSetsIn (CharDesc); i++) 00143 FeaturesOfType (CharDesc, i) = NULL; 00144 00145 return (CharDesc); 00146 00147 } /* NewCharDescription */
CHAR_DESC ReadCharDescription | ( | FILE * | File | ) |
Read a character description from File, and return a data structure containing this information.
File | Open text file to read character description from |
NumberOfSets ShortNameForSet1 Set1 ShortNameForSet2 Set2 ...
Definition at line 201 of file featdefs.cpp.
References DefinitionOf, DoError(), FEAT_NAME_SIZE, FeaturesOfType, fscanf(), ILLEGAL_NUM_SETS, NewCharDescription(), NumFeaturesDefined, ReadFeatureSet(), and ShortNameToFeatureType().
Referenced by ReadTrainingSamples().
00201 { 00202 int NumSetsToRead; 00203 char ShortName[FEAT_NAME_SIZE]; 00204 CHAR_DESC CharDesc; 00205 int Type; 00206 00207 if (fscanf (File, "%d", &NumSetsToRead) != 1 || 00208 NumSetsToRead < 0 || NumSetsToRead > NumFeaturesDefined ()) 00209 DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets"); 00210 00211 CharDesc = NewCharDescription (); 00212 for (; NumSetsToRead > 0; NumSetsToRead--) { 00213 fscanf (File, "%s", ShortName); 00214 Type = ShortNameToFeatureType (ShortName); 00215 FeaturesOfType (CharDesc, Type) = 00216 ReadFeatureSet (File, DefinitionOf (Type)); 00217 } 00218 return (CharDesc); 00219 00220 } // ReadCharDescription
int ShortNameToFeatureType | ( | const char * | ShortName | ) |
Search thru all features currently defined and return the feature type for the feature with the specified short name.
ShortName | Short name of a feature type |
Definition at line 236 of file featdefs.cpp.
References DefinitionOf, DoError(), ILLEGAL_SHORT_NAME, NumFeaturesDefined, and ShortNameOf.
Referenced by ReadCharDescription(), ReadTrainingSamples(), SetUpForClustering(), and WriteTrainingSamples().
00236 { 00237 int i; 00238 00239 for (i = 0; i < NumFeaturesDefined (); i++) 00240 if (!strcmp (ShortNameOf (DefinitionOf (i)), ShortName)) 00241 return (i); 00242 DoError (ILLEGAL_SHORT_NAME, "Illegal short name for a feature"); 00243 return 0; 00244 00245 } // ShortNameToFeatureType
EndParamDesc CharNormParams StartParamDesc | ( | OutlineFeatParams | ) |
StartParamDesc | ( | PicoFeatParams | ) |
StartParamDesc | ( | MicroFeatureParams | ) |
---------------------------------------------------------------------------- Global Data Definitions and Declarations ----------------------------------------------------------------------------
void WriteCharDescription | ( | FILE * | File, | |
CHAR_DESC | CharDesc | |||
) |
Write a textual representation of CharDesc to File.
File | Open text file to write CharDesc to | |
CharDesc | Character description to write to File |
Each set starts with the short name for that feature followed by a description of the feature set. Feature sets which are not present are not written.
Definition at line 167 of file featdefs.cpp.
References DefinitionOf, FeaturesOfType, NumFeatureSetsIn, ShortNameOf, and WriteFeatureSet().
Referenced by LearnBlob().
00167 { 00168 int Type; 00169 int NumSetsToWrite = 0; 00170 00171 for (Type = 0; Type < NumFeatureSetsIn (CharDesc); Type++) 00172 if (FeaturesOfType (CharDesc, Type)) 00173 NumSetsToWrite++; 00174 00175 fprintf (File, " %d\n", NumSetsToWrite); 00176 for (Type = 0; Type < NumFeatureSetsIn (CharDesc); Type++) 00177 if (FeaturesOfType (CharDesc, Type)) { 00178 fprintf (File, "%s ", ShortNameOf (DefinitionOf (Type))); 00179 WriteFeatureSet (File, FeaturesOfType (CharDesc, Type)); 00180 } 00181 } /* WriteCharDescription */
EndParamDesc CharNorm |
Definition at line 76 of file featdefs.cpp.
EndParamDesc cn |
Definition at line 76 of file featdefs.cpp.
EndParamDesc CharNormParams OutlineFeatParams FEATURE_DEFS_STRUCT FeatureDefs |
Initial value:
{ NUM_FEATURE_TYPES, { &MicroFeatureDesc, &PicoFeatDesc, &OutlineFeatDesc, &CharNormDesc } }
Definition at line 93 of file featdefs.cpp.
EndParamDesc CharNormParams MAX_OUTLINE_FEATURES |
Definition at line 87 of file featdefs.cpp.
Definition at line 53 of file featdefs.cpp.
Definition at line 53 of file featdefs.cpp.
EndParamDesc CharNormParams of |
Definition at line 87 of file featdefs.cpp.
EndParamDesc CharNormParams Outline |
Definition at line 87 of file featdefs.cpp.
Referenced by BlobMicroFeatures(), ComputeOutlineStats(), ConvertOutline(), ConvertOutlines(), ExtractOutlineFeatures(), ExtractPicoFeatures(), FreeMFOutline(), NormalizeOutlines(), and NumOutlinesInBlob().
MicroFeatureParams FLOAT32 PicoFeatureLength = PICO_FEATURE_LENGTH |
Definition at line 57 of file featdefs.cpp.
Referenced by ConvertSegmentToPicoFeat(), and InitPicoFXVars().