tesseract  4.0.0-1-g2a2b
mf.cpp File Reference
#include "mf.h"
#include "featdefs.h"
#include "mfdefs.h"
#include "mfx.h"
#include <cmath>

Go to the source code of this file.

Functions

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

Function Documentation

◆ ExtractMicros()

FEATURE_SET ExtractMicros ( TBLOB Blob,
const DENORM cn_denorm 
)

Call the old micro-feature extractor and then copy the features into the new format. Then deallocate the old micro-features.

Parameters
Blobblob to extract micro-features from
cn_denormcontrol parameter to feature extractor.
Returns
Micro-features for Blob.

Definition at line 43 of file mf.cpp.

43  {
44  int NumFeatures;
45  MICROFEATURES Features, OldFeatures;
46  FEATURE_SET FeatureSet;
47  FEATURE Feature;
48  MICROFEATURE OldFeature;
49 
50  OldFeatures = BlobMicroFeatures(Blob, cn_denorm);
51  if (OldFeatures == nullptr)
52  return nullptr;
53  NumFeatures = count (OldFeatures);
54  FeatureSet = NewFeatureSet (NumFeatures);
55 
56  Features = OldFeatures;
57  iterate(Features) {
58  OldFeature = (MICROFEATURE) first_node (Features);
59  Feature = NewFeature (&MicroFeatureDesc);
60  Feature->Params[MFDirection] = OldFeature[ORIENTATION];
61  Feature->Params[MFXPosition] = OldFeature[XPOSITION];
62  Feature->Params[MFYPosition] = OldFeature[YPOSITION];
63  Feature->Params[MFLength] = OldFeature[MFLENGTH];
64 
65  // Bulge features are deprecated and should not be used. Set to 0.
66  Feature->Params[MFBulge1] = 0.0f;
67  Feature->Params[MFBulge2] = 0.0f;
68 
69 #ifndef _WIN32
70  // Assert that feature parameters are well defined.
71  int i;
72  for (i = 0; i < Feature->Type->NumParams; i++) {
73  ASSERT_HOST(!std::isnan(Feature->Params[i]));
74  }
75 #endif
76 
77  AddFeature(FeatureSet, Feature);
78  }
79  FreeMicroFeatures(OldFeatures);
80  return FeatureSet;
81 } /* ExtractMicros */
#define MFLENGTH
Definition: mfdefs.h:38
const FEATURE_DESC_STRUCT MicroFeatureDesc
void FreeMicroFeatures(MICROFEATURES MicroFeatures)
Definition: mfdefs.cpp:46
FEATURE_SET NewFeatureSet(int NumFeatures)
Definition: ocrfeatures.cpp:97
int count(LIST var_list)
Definition: oldlist.cpp:98
float Params[1]
Definition: ocrfeatures.h:62
MICROFEATURES BlobMicroFeatures(TBLOB *Blob, const DENORM &cn_denorm)
Definition: mfx.cpp:69
Definition: mf.h:29
Definition: mf.h:28
Definition: mf.h:28
#define first_node(l)
Definition: oldlist.h:141
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:81
float * MICROFEATURE
Definition: mfdefs.h:33
#define iterate(l)
Definition: oldlist.h:161
#define ORIENTATION
Definition: mfdefs.h:39
Definition: mf.h:29
bool AddFeature(FEATURE_SET FeatureSet, FEATURE Feature)
Definition: ocrfeatures.cpp:41
Definition: mf.h:29
#define YPOSITION
Definition: mfdefs.h:37
#define XPOSITION
Definition: mfdefs.h:36
Definition: mf.h:29
#define ASSERT_HOST(x)
Definition: errcode.h:84
const FEATURE_DESC_STRUCT * Type
Definition: ocrfeatures.h:61