tesseract  3.04.00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mf.cpp File Reference
#include "mf.h"
#include "featdefs.h"
#include "mfdefs.h"
#include "mfx.h"
#include <math.h>

Go to the source code of this file.

Functions

FEATURE_SET ExtractMicros (TBLOB *Blob, const DENORM &cn_denorm)
 

Function Documentation

FEATURE_SET ExtractMicros ( TBLOB Blob,
const DENORM cn_denorm 
)

Include Files and Type Defines

Global Data Definitions and Declarations

Private Code

Definition at line 36 of file mf.cpp.

36  {
37 /*
38  ** Parameters:
39  ** Blob blob to extract micro-features from
40  ** denorm control parameter to feature extractor.
41  ** Globals: none
42  ** Operation: Call the old micro-feature extractor and then copy
43  ** the features into the new format. Then deallocate the
44  ** old micro-features.
45  ** Return: Micro-features for Blob.
46  ** Exceptions: none
47  ** History: Wed May 23 18:06:38 1990, DSJ, Created.
48  */
49  int NumFeatures;
50  MICROFEATURES Features, OldFeatures;
51  FEATURE_SET FeatureSet;
52  FEATURE Feature;
53  MICROFEATURE OldFeature;
54 
55  OldFeatures = BlobMicroFeatures(Blob, cn_denorm);
56  if (OldFeatures == NULL)
57  return NULL;
58  NumFeatures = count (OldFeatures);
59  FeatureSet = NewFeatureSet (NumFeatures);
60 
61  Features = OldFeatures;
62  iterate(Features) {
63  OldFeature = (MICROFEATURE) first_node (Features);
64  Feature = NewFeature (&MicroFeatureDesc);
65  Feature->Params[MFDirection] = OldFeature[ORIENTATION];
66  Feature->Params[MFXPosition] = OldFeature[XPOSITION];
67  Feature->Params[MFYPosition] = OldFeature[YPOSITION];
68  Feature->Params[MFLength] = OldFeature[MFLENGTH];
69 
70  // Bulge features are deprecated and should not be used. Set to 0.
71  Feature->Params[MFBulge1] = 0.0f;
72  Feature->Params[MFBulge2] = 0.0f;
73 
74 #ifndef _WIN32
75  // Assert that feature parameters are well defined.
76  int i;
77  for (i = 0; i < Feature->Type->NumParams; i++) {
78  ASSERT_HOST(!isnan(Feature->Params[i]));
79  }
80 #endif
81 
82  AddFeature(FeatureSet, Feature);
83  }
84  FreeMicroFeatures(OldFeatures);
85  return FeatureSet;
86 } /* ExtractMicros */
#define first_node(l)
Definition: oldlist.h:139
#define XPOSITION
Definition: mfdefs.h:36
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
FEATURE_SET NewFeatureSet(int NumFeatures)
#define YPOSITION
Definition: mfdefs.h:37
Definition: mf.h:29
Definition: mf.h:29
#define iterate(l)
Definition: oldlist.h:159
FLOAT32 * MICROFEATURE
Definition: mfdefs.h:33
const FEATURE_DESC_STRUCT * Type
Definition: ocrfeatures.h:64
int count(LIST var_list)
Definition: oldlist.cpp:108
void FreeMicroFeatures(MICROFEATURES MicroFeatures)
Definition: mfdefs.cpp:45
#define ASSERT_HOST(x)
Definition: errcode.h:84
Definition: mf.h:29
#define isnan(x)
Definition: mathfix.h:31
Definition: mf.h:28
MICROFEATURES BlobMicroFeatures(TBLOB *Blob, const DENORM &cn_denorm)
Definition: mfx.cpp:62
FLOAT32 Params[1]
Definition: ocrfeatures.h:65
Definition: mf.h:28
BOOL8 AddFeature(FEATURE_SET FeatureSet, FEATURE Feature)
Definition: ocrfeatures.cpp:35
Definition: mf.h:29
#define ORIENTATION
Definition: mfdefs.h:39
#define NULL
Definition: host.h:144
const FEATURE_DESC_STRUCT MicroFeatureDesc
#define MFLENGTH
Definition: mfdefs.h:38