Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
float2int.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  ** Filename: float2int.c
3  ** Purpose: Routines for converting float features to int features
4  ** Author: Dan Johnson
5  ** History: Wed Mar 13 07:47:48 1991, DSJ, Created.
6  **
7  ** (c) Copyright Hewlett-Packard Company, 1988.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  ******************************************************************************/
18 /*-----------------------------------------------------------------------------
19  Include Files and Type Defines
20 -----------------------------------------------------------------------------*/
21 #include "float2int.h"
22 #include "normmatch.h"
23 #include "mfoutline.h"
24 #include "classify.h"
25 #include "helpers.h"
26 #include "picofeat.h"
27 
28 #define MAX_INT_CHAR_NORM (INT_CHAR_NORM_RANGE - 1)
29 
30 /*-----------------------------------------------------------------------------
31  Public Code
32 -----------------------------------------------------------------------------*/
33 /*---------------------------------------------------------------------------*/
34 namespace tesseract {
35 
48 void Classify::ClearCharNormArray(uinT8* char_norm_array) {
49  memset(char_norm_array, 0, sizeof(*char_norm_array) * unicharset.size());
50 } /* ClearCharNormArray */
51 
52 
53 /*---------------------------------------------------------------------------*/
70  uinT8* char_norm_array) {
71  for (int i = 0; i < unicharset.size(); i++) {
72  int norm_adjust = static_cast<int>(INT_CHAR_NORM_RANGE *
73  ComputeNormMatch(i, norm_feature, FALSE));
74  char_norm_array[i] = ClipToRange(norm_adjust, 0, MAX_INT_CHAR_NORM);
75  }
76 } /* ComputeIntCharNormArray */
77 
78 
79 /*---------------------------------------------------------------------------*/
95  INT_FEATURE_ARRAY IntFeatures) {
96  int Fid;
97  FEATURE Feature;
98  FLOAT32 YShift;
99 
101  YShift = BASELINE_Y_SHIFT;
102  else
103  YShift = Y_SHIFT;
104 
105  for (Fid = 0; Fid < Features->NumFeatures; Fid++) {
106  Feature = Features->Features[Fid];
107 
108  IntFeatures[Fid].X = BucketFor (Feature->Params[PicoFeatX],
110  IntFeatures[Fid].Y = BucketFor (Feature->Params[PicoFeatY],
111  YShift, INT_FEAT_RANGE);
112  IntFeatures[Fid].Theta = CircBucketFor (Feature->Params[PicoFeatDir],
114  IntFeatures[Fid].CP_misses = 0;
115  }
116 } /* ComputeIntFeatures */
117 } // namespace tesseract
#define INT_CHAR_NORM_RANGE
Definition: intproto.h:131
void ComputeIntCharNormArray(const FEATURE_STRUCT &norm_feature, uinT8 *char_norm_array)
Definition: float2int.cpp:69
int size() const
Definition: unicharset.h:264
#define BASELINE_Y_SHIFT
Definition: float2int.h:28
#define MAX_INT_CHAR_NORM
Definition: float2int.cpp:28
void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures)
Definition: float2int.cpp:94
#define FALSE
Definition: capi.h:28
float FLOAT32
Definition: host.h:111
#define X_SHIFT
Definition: intproto.h:38
int BucketFor(FLOAT32 Param, FLOAT32 Offset, int NumBuckets)
Definition: intproto.cpp:425
#define ANGLE_SHIFT
Definition: intproto.h:37
void ClearCharNormArray(uinT8 *char_norm_array)
Definition: float2int.cpp:48
FEATURE Features[1]
Definition: ocrfeatures.h:71
FLOAT32 Params[1]
Definition: ocrfeatures.h:64
#define Y_SHIFT
Definition: intproto.h:39
UNICHARSET unicharset
Definition: ccutil.h:72
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
Definition: baseapi.h:66
unsigned char uinT8
Definition: host.h:99
FLOAT32 ComputeNormMatch(CLASS_ID ClassId, const FEATURE_STRUCT &feature, BOOL8 DebugMatch)
Definition: normmatch.cpp:73
#define INT_FEAT_RANGE
Definition: float2int.h:27
int CircBucketFor(FLOAT32 Param, FLOAT32 Offset, int NumBuckets)
Definition: intproto.cpp:447
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:64