tesseract  4.0.0-1-g2a2b
intfx.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  ** Filename: intfx.c
3  ** Purpose: Integer character normalization & feature extraction
4  ** Author: Robert Moss, rays@google.com (Ray Smith)
5  ** History: Tue May 21 15:51:57 MDT 1991, RWM, Created.
6  ** Tue Feb 28 10:42:00 PST 2012, vastly rewritten to allow
7  greyscale fx and non-linear
8  normalization.
9  **
10  ** (c) Copyright Hewlett-Packard Company, 1988.
11  ** Licensed under the Apache License, Version 2.0 (the "License");
12  ** you may not use this file except in compliance with the License.
13  ** You may obtain a copy of the License at
14  ** http://www.apache.org/licenses/LICENSE-2.0
15  ** Unless required by applicable law or agreed to in writing, software
16  ** distributed under the License is distributed on an "AS IS" BASIS,
17  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  ** See the License for the specific language governing permissions and
19  ** limitations under the License.
20  *****************************************************************************/
24 #include "intfx.h"
25 #include "allheaders.h"
26 #include "ccutil.h"
27 #include "classify.h"
28 #include "helpers.h"
29 #include "intmatcher.h"
30 #include "linlsq.h"
31 #include "normalis.h"
32 #include "statistc.h"
33 #include "trainingsample.h"
34 
36 
40 // Look up table for cos and sin to turn the intfx feature angle to a vector.
41 // Protected by atan_table_mutex.
42 // The entries are in binary degrees where a full circle is 256 binary degrees.
43 static float cos_table[INT_CHAR_NORM_RANGE];
44 static float sin_table[INT_CHAR_NORM_RANGE];
45 // Guards write access to AtanTable so we don't create it more than once.
47 
48 
52 /*---------------------------------------------------------------------------*/
53 void InitIntegerFX() {
54  static bool atan_table_init = false;
56  if (!atan_table_init) {
57  for (int i = 0; i < INT_CHAR_NORM_RANGE; ++i) {
58  cos_table[i] = cos(i * 2 * M_PI / INT_CHAR_NORM_RANGE + M_PI);
59  sin_table[i] = sin(i * 2 * M_PI / INT_CHAR_NORM_RANGE + M_PI);
60  }
61  atan_table_init = true;
62  }
64 }
65 
66 // Returns a vector representing the direction of a feature with the given
67 // theta direction in an INT_FEATURE_STRUCT.
68 FCOORD FeatureDirection(uint8_t theta) {
69  return FCOORD(cos_table[theta], sin_table[theta]);
70 }
71 
72 namespace tesseract {
73 
74 // Generates a TrainingSample from a TBLOB. Extracts features and sets
75 // the bounding box, so classifiers that operate on the image can work.
76 // TODO(rays) Make BlobToTrainingSample a member of Classify now that
77 // the FlexFx and FeatureDescription code have been removed and LearnBlob
78 // is now a member of Classify.
80  const TBLOB& blob, bool nonlinear_norm, INT_FX_RESULT_STRUCT* fx_info,
81  GenericVector<INT_FEATURE_STRUCT>* bl_features) {
83  Classify::ExtractFeatures(blob, nonlinear_norm, bl_features,
84  &cn_features, fx_info, nullptr);
85  // TODO(rays) Use blob->PreciseBoundingBox() instead.
86  TBOX box = blob.bounding_box();
87  TrainingSample* sample = nullptr;
88  int num_features = fx_info->NumCN;
89  if (num_features > 0) {
90  sample = TrainingSample::CopyFromFeatures(*fx_info, box, &cn_features[0],
91  num_features);
92  }
93  if (sample != nullptr) {
94  // Set the bounding box (in original image coordinates) in the sample.
95  TPOINT topleft, botright;
96  topleft.x = box.left();
97  topleft.y = box.top();
98  botright.x = box.right();
99  botright.y = box.bottom();
100  TPOINT original_topleft, original_botright;
101  blob.denorm().DenormTransform(nullptr, topleft, &original_topleft);
102  blob.denorm().DenormTransform(nullptr, botright, &original_botright);
103  sample->set_bounding_box(TBOX(original_topleft.x, original_botright.y,
104  original_botright.x, original_topleft.y));
105  }
106  return sample;
107 }
108 
109 // Computes the DENORMS for bl(baseline) and cn(character) normalization
110 // during feature extraction. The input denorm describes the current state
111 // of the blob, which is usually a baseline-normalized word.
112 // The Transforms setup are as follows:
113 // Baseline Normalized (bl) Output:
114 // We center the grapheme by aligning the x-coordinate of its centroid with
115 // x=128 and leaving the already-baseline-normalized y as-is.
116 //
117 // Character Normalized (cn) Output:
118 // We align the grapheme's centroid at the origin and scale it
119 // asymmetrically in x and y so that the 2nd moments are a standard value
120 // (51.2) ie the result is vaguely square.
121 // If classify_nonlinear_norm is true:
122 // A non-linear normalization is setup that attempts to evenly distribute
123 // edges across x and y.
124 //
125 // Some of the fields of fx_info are also setup:
126 // Length: Total length of outline.
127 // Rx: Rounded y second moment. (Reversed by convention.)
128 // Ry: rounded x second moment.
129 // Xmean: Rounded x center of mass of the blob.
130 // Ymean: Rounded y center of mass of the blob.
131 void Classify::SetupBLCNDenorms(const TBLOB& blob, bool nonlinear_norm,
132  DENORM* bl_denorm, DENORM* cn_denorm,
133  INT_FX_RESULT_STRUCT* fx_info) {
134  // Compute 1st and 2nd moments of the original outline.
135  FCOORD center, second_moments;
136  int length = blob.ComputeMoments(&center, &second_moments);
137  if (fx_info != nullptr) {
138  fx_info->Length = length;
139  fx_info->Rx = IntCastRounded(second_moments.y());
140  fx_info->Ry = IntCastRounded(second_moments.x());
141 
142  fx_info->Xmean = IntCastRounded(center.x());
143  fx_info->Ymean = IntCastRounded(center.y());
144  }
145  // Setup the denorm for Baseline normalization.
146  bl_denorm->SetupNormalization(nullptr, nullptr, &blob.denorm(), center.x(), 128.0f,
147  1.0f, 1.0f, 128.0f, 128.0f);
148  // Setup the denorm for character normalization.
149  if (nonlinear_norm) {
152  TBOX box;
153  blob.GetPreciseBoundingBox(&box);
154  box.pad(1, 1);
155  blob.GetEdgeCoords(box, &x_coords, &y_coords);
156  cn_denorm->SetupNonLinear(&blob.denorm(), box, UINT8_MAX, UINT8_MAX,
157  0.0f, 0.0f, x_coords, y_coords);
158  } else {
159  cn_denorm->SetupNormalization(nullptr, nullptr, &blob.denorm(),
160  center.x(), center.y(),
161  51.2f / second_moments.x(),
162  51.2f / second_moments.y(),
163  128.0f, 128.0f);
164  }
165 }
166 
167 // Helper normalizes the direction, assuming that it is at the given
168 // unnormed_pos, using the given denorm, starting at the root_denorm.
169 static uint8_t NormalizeDirection(uint8_t dir, const FCOORD& unnormed_pos,
170  const DENORM& denorm,
171  const DENORM* root_denorm) {
172  // Convert direction to a vector.
173  FCOORD unnormed_end;
174  unnormed_end.from_direction(dir);
175  unnormed_end += unnormed_pos;
176  FCOORD normed_pos, normed_end;
177  denorm.NormTransform(root_denorm, unnormed_pos, &normed_pos);
178  denorm.NormTransform(root_denorm, unnormed_end, &normed_end);
179  normed_end -= normed_pos;
180  return normed_end.to_direction();
181 }
182 
183 // Helper returns the mean direction vector from the given stats. Use the
184 // mean direction from dirs if there is information available, otherwise, use
185 // the fit_vector from point_diffs.
186 static FCOORD MeanDirectionVector(const LLSQ& point_diffs, const LLSQ& dirs,
187  const FCOORD& start_pt,
188  const FCOORD& end_pt) {
189  FCOORD fit_vector;
190  if (dirs.count() > 0) {
191  // There were directions, so use them. To avoid wrap-around problems, we
192  // have 2 accumulators in dirs: x for normal directions and y for
193  // directions offset by 128. We will use the one with the least variance.
194  FCOORD mean_pt = dirs.mean_point();
195  double mean_dir = 0.0;
196  if (dirs.x_variance() <= dirs.y_variance()) {
197  mean_dir = mean_pt.x();
198  } else {
199  mean_dir = mean_pt.y() + 128;
200  }
201  fit_vector.from_direction(Modulo(IntCastRounded(mean_dir), 256));
202  } else {
203  // There were no directions, so we rely on the vector_fit to the points.
204  // Since the vector_fit is 180 degrees ambiguous, we align with the
205  // supplied feature_dir by making the scalar product non-negative.
206  FCOORD feature_dir(end_pt - start_pt);
207  fit_vector = point_diffs.vector_fit();
208  if (fit_vector.x() == 0.0f && fit_vector.y() == 0.0f) {
209  // There was only a single point. Use feature_dir directly.
210  fit_vector = feature_dir;
211  } else {
212  // Sometimes the least mean squares fit is wrong, due to the small sample
213  // of points and scaling. Use a 90 degree rotated vector if that matches
214  // feature_dir better.
215  FCOORD fit_vector2 = !fit_vector;
216  // The fit_vector is 180 degrees ambiguous, so resolve the ambiguity by
217  // insisting that the scalar product with the feature_dir should be +ve.
218  if (fit_vector % feature_dir < 0.0)
219  fit_vector = -fit_vector;
220  if (fit_vector2 % feature_dir < 0.0)
221  fit_vector2 = -fit_vector2;
222  // Even though fit_vector2 has a higher mean squared error, it might be
223  // a better fit, so use it if the dot product with feature_dir is bigger.
224  if (fit_vector2 % feature_dir > fit_vector % feature_dir)
225  fit_vector = fit_vector2;
226  }
227  }
228  return fit_vector;
229 }
230 
231 // Helper computes one or more features corresponding to the given points.
232 // Emitted features are on the line defined by:
233 // start_pt + lambda * (end_pt - start_pt) for scalar lambda.
234 // Features are spaced at feature_length intervals.
235 static int ComputeFeatures(const FCOORD& start_pt, const FCOORD& end_pt,
236  double feature_length,
238  FCOORD feature_vector(end_pt - start_pt);
239  if (feature_vector.x() == 0.0f && feature_vector.y() == 0.0f) return 0;
240  // Compute theta for the feature based on its direction.
241  uint8_t theta = feature_vector.to_direction();
242  // Compute the number of features and lambda_step.
243  double target_length = feature_vector.length();
244  int num_features = IntCastRounded(target_length / feature_length);
245  if (num_features == 0) return 0;
246  // Divide the length evenly into num_features pieces.
247  double lambda_step = 1.0 / num_features;
248  double lambda = lambda_step / 2.0;
249  for (int f = 0; f < num_features; ++f, lambda += lambda_step) {
250  FCOORD feature_pt(start_pt);
251  feature_pt += feature_vector * lambda;
252  INT_FEATURE_STRUCT feature(feature_pt, theta);
253  features->push_back(feature);
254  }
255  return num_features;
256 }
257 
258 // Gathers outline points and their directions from start_index into dirs by
259 // stepping along the outline and normalizing the coordinates until the
260 // required feature_length has been collected or end_index is reached.
261 // On input pos must point to the position corresponding to start_index and on
262 // return pos is updated to the current raw position, and pos_normed is set to
263 // the normed version of pos.
264 // Since directions wrap-around, they need special treatment to get the mean.
265 // Provided the cluster of directions doesn't straddle the wrap-around point,
266 // the simple mean works. If they do, then, unless the directions are wildly
267 // varying, the cluster rotated by 180 degrees will not straddle the wrap-
268 // around point, so mean(dir + 180 degrees) - 180 degrees will work. Since
269 // LLSQ conveniently stores the mean of 2 variables, we use it to store
270 // dir and dir+128 (128 is 180 degrees) and then use the resulting mean
271 // with the least variance.
272 static int GatherPoints(const C_OUTLINE* outline, double feature_length,
273  const DENORM& denorm, const DENORM* root_denorm,
274  int start_index, int end_index,
275  ICOORD* pos, FCOORD* pos_normed,
276  LLSQ* points, LLSQ* dirs) {
277  int step_length = outline->pathlength();
278  ICOORD step = outline->step(start_index % step_length);
279  // Prev_normed is the start point of this collection and will be set on the
280  // first iteration, and on later iterations used to determine the length
281  // that has been collected.
282  FCOORD prev_normed;
283  points->clear();
284  dirs->clear();
285  int num_points = 0;
286  int index;
287  for (index = start_index; index <= end_index; ++index, *pos += step) {
288  step = outline->step(index % step_length);
289  int edge_weight = outline->edge_strength_at_index(index % step_length);
290  if (edge_weight == 0) {
291  // This point has conflicting gradient and step direction, so ignore it.
292  continue;
293  }
294  // Get the sub-pixel precise location and normalize.
295  FCOORD f_pos = outline->sub_pixel_pos_at_index(*pos, index % step_length);
296  denorm.NormTransform(root_denorm, f_pos, pos_normed);
297  if (num_points == 0) {
298  // The start of this segment.
299  prev_normed = *pos_normed;
300  } else {
301  FCOORD offset = *pos_normed - prev_normed;
302  float length = offset.length();
303  if (length > feature_length) {
304  // We have gone far enough from the start. We will use this point in
305  // the next set so return what we have so far.
306  return index;
307  }
308  }
309  points->add(pos_normed->x(), pos_normed->y(), edge_weight);
310  int direction = outline->direction_at_index(index % step_length);
311  if (direction >= 0) {
312  direction = NormalizeDirection(direction, f_pos, denorm, root_denorm);
313  // Use both the direction and direction +128 so we are not trying to
314  // take the mean of something straddling the wrap-around point.
315  dirs->add(direction, Modulo(direction + 128, 256));
316  }
317  ++num_points;
318  }
319  return index;
320 }
321 
322 // Extracts Tesseract features and appends them to the features vector.
323 // Startpt to lastpt, inclusive, MUST have the same src_outline member,
324 // which may be nullptr. The vector from lastpt to its next is included in
325 // the feature extraction. Hidden edges should be excluded by the caller.
326 // If force_poly is true, the features will be extracted from the polygonal
327 // approximation even if more accurate data is available.
328 static void ExtractFeaturesFromRun(
329  const EDGEPT* startpt, const EDGEPT* lastpt,
330  const DENORM& denorm, double feature_length, bool force_poly,
332  const EDGEPT* endpt = lastpt->next;
333  const C_OUTLINE* outline = startpt->src_outline;
334  if (outline != nullptr && !force_poly) {
335  // Detailed information is available. We have to normalize only from
336  // the root_denorm to denorm.
337  const DENORM* root_denorm = denorm.RootDenorm();
338  int total_features = 0;
339  // Get the features from the outline.
340  int step_length = outline->pathlength();
341  int start_index = startpt->start_step;
342  // pos is the integer coordinates of the binary image steps.
343  ICOORD pos = outline->position_at_index(start_index);
344  // We use an end_index that allows us to use a positive increment, but that
345  // may be beyond the bounds of the outline steps/ due to wrap-around, to
346  // so we use % step_length everywhere, except for start_index.
347  int end_index = lastpt->start_step + lastpt->step_count;
348  if (end_index <= start_index)
349  end_index += step_length;
350  LLSQ prev_points;
351  LLSQ prev_dirs;
352  FCOORD prev_normed_pos = outline->sub_pixel_pos_at_index(pos, start_index);
353  denorm.NormTransform(root_denorm, prev_normed_pos, &prev_normed_pos);
354  LLSQ points;
355  LLSQ dirs;
356  FCOORD normed_pos(0.0f, 0.0f);
357  int index = GatherPoints(outline, feature_length, denorm, root_denorm,
358  start_index, end_index, &pos, &normed_pos,
359  &points, &dirs);
360  while (index <= end_index) {
361  // At each iteration we nominally have 3 accumulated sets of points and
362  // dirs: prev_points/dirs, points/dirs, next_points/dirs and sum them
363  // into sum_points/dirs, but we don't necessarily get any features out,
364  // so if that is the case, we keep accumulating instead of rotating the
365  // accumulators.
366  LLSQ next_points;
367  LLSQ next_dirs;
368  FCOORD next_normed_pos(0.0f, 0.0f);
369  index = GatherPoints(outline, feature_length, denorm, root_denorm,
370  index, end_index, &pos, &next_normed_pos,
371  &next_points, &next_dirs);
372  LLSQ sum_points(prev_points);
373  // TODO(rays) find out why it is better to use just dirs and next_dirs
374  // in sum_dirs, instead of using prev_dirs as well.
375  LLSQ sum_dirs(dirs);
376  sum_points.add(points);
377  sum_points.add(next_points);
378  sum_dirs.add(next_dirs);
379  bool made_features = false;
380  // If we have some points, we can try making some features.
381  if (sum_points.count() > 0) {
382  // We have gone far enough from the start. Make a feature and restart.
383  FCOORD fit_pt = sum_points.mean_point();
384  FCOORD fit_vector = MeanDirectionVector(sum_points, sum_dirs,
385  prev_normed_pos, normed_pos);
386  // The segment to which we fit features is the line passing through
387  // fit_pt in direction of fit_vector that starts nearest to
388  // prev_normed_pos and ends nearest to normed_pos.
389  FCOORD start_pos = prev_normed_pos.nearest_pt_on_line(fit_pt,
390  fit_vector);
391  FCOORD end_pos = normed_pos.nearest_pt_on_line(fit_pt, fit_vector);
392  // Possible correction to match the adjacent polygon segment.
393  if (total_features == 0 && startpt != endpt) {
394  FCOORD poly_pos(startpt->pos.x, startpt->pos.y);
395  denorm.LocalNormTransform(poly_pos, &start_pos);
396  }
397  if (index > end_index && startpt != endpt) {
398  FCOORD poly_pos(endpt->pos.x, endpt->pos.y);
399  denorm.LocalNormTransform(poly_pos, &end_pos);
400  }
401  int num_features = ComputeFeatures(start_pos, end_pos, feature_length,
402  features);
403  if (num_features > 0) {
404  // We made some features so shuffle the accumulators.
405  prev_points = points;
406  prev_dirs = dirs;
407  prev_normed_pos = normed_pos;
408  points = next_points;
409  dirs = next_dirs;
410  made_features = true;
411  total_features += num_features;
412  }
413  // The end of the next set becomes the end next time around.
414  normed_pos = next_normed_pos;
415  }
416  if (!made_features) {
417  // We didn't make any features, so keep the prev accumulators and
418  // add the next ones into the current.
419  points.add(next_points);
420  dirs.add(next_dirs);
421  }
422  }
423  } else {
424  // There is no outline, so we are forced to use the polygonal approximation.
425  const EDGEPT* pt = startpt;
426  do {
427  FCOORD start_pos(pt->pos.x, pt->pos.y);
428  FCOORD end_pos(pt->next->pos.x, pt->next->pos.y);
429  denorm.LocalNormTransform(start_pos, &start_pos);
430  denorm.LocalNormTransform(end_pos, &end_pos);
431  ComputeFeatures(start_pos, end_pos, feature_length, features);
432  } while ((pt = pt->next) != endpt);
433  }
434 }
435 
436 // Extracts sets of 3-D features of length kStandardFeatureLength (=12.8), as
437 // (x,y) position and angle as measured counterclockwise from the vector
438 // <-1, 0>, from blob using two normalizations defined by bl_denorm and
439 // cn_denorm. See SetpuBLCNDenorms for definitions.
440 // If outline_cn_counts is not nullptr, on return it contains the cumulative
441 // number of cn features generated for each outline in the blob (in order).
442 // Thus after the first outline, there were (*outline_cn_counts)[0] features,
443 // after the second outline, there were (*outline_cn_counts)[1] features etc.
445  bool nonlinear_norm,
448  INT_FX_RESULT_STRUCT* results,
449  GenericVector<int>* outline_cn_counts) {
450  DENORM bl_denorm, cn_denorm;
451  tesseract::Classify::SetupBLCNDenorms(blob, nonlinear_norm,
452  &bl_denorm, &cn_denorm, results);
453  if (outline_cn_counts != nullptr)
454  outline_cn_counts->truncate(0);
455  // Iterate the outlines.
456  for (TESSLINE* ol = blob.outlines; ol != nullptr; ol = ol->next) {
457  // Iterate the polygon.
458  EDGEPT* loop_pt = ol->FindBestStartPt();
459  EDGEPT* pt = loop_pt;
460  if (pt == nullptr) continue;
461  do {
462  if (pt->IsHidden()) continue;
463  // Find a run of equal src_outline.
464  EDGEPT* last_pt = pt;
465  do {
466  last_pt = last_pt->next;
467  } while (last_pt != loop_pt && !last_pt->IsHidden() &&
468  last_pt->src_outline == pt->src_outline);
469  last_pt = last_pt->prev;
470  // Until the adaptive classifier can be weaned off polygon segments,
471  // we have to force extraction from the polygon for the bl_features.
472  ExtractFeaturesFromRun(pt, last_pt, bl_denorm, kStandardFeatureLength,
473  true, bl_features);
474  ExtractFeaturesFromRun(pt, last_pt, cn_denorm, kStandardFeatureLength,
475  false, cn_features);
476  pt = last_pt;
477  } while ((pt = pt->next) != loop_pt);
478  if (outline_cn_counts != nullptr)
479  outline_cn_counts->push_back(cn_features->size());
480  }
481  results->NumBL = bl_features->size();
482  results->NumCN = cn_features->size();
483  results->YBottom = blob.bounding_box().bottom();
484  results->YTop = blob.bounding_box().top();
485  results->Width = blob.bounding_box().width();
486 }
487 
488 } // namespace tesseract
FCOORD FeatureDirection(uint8_t theta)
Definition: intfx.cpp:68
int direction_at_index(int index) const
Definition: coutln.h:178
int step_count
Definition: blobs.h:181
TrainingSample * BlobToTrainingSample(const TBLOB &blob, bool nonlinear_norm, INT_FX_RESULT_STRUCT *fx_info, GenericVector< INT_FEATURE_STRUCT > *bl_features)
Definition: intfx.cpp:79
int ComputeMoments(FCOORD *center, FCOORD *second_moments) const
Definition: blobs.cpp:532
void NormTransform(const DENORM *first_norm, const TPOINT &pt, TPOINT *transformed) const
Definition: normalis.cpp:335
static void SetupBLCNDenorms(const TBLOB &blob, bool nonlinear_norm, DENORM *bl_denorm, DENORM *cn_denorm, INT_FX_RESULT_STRUCT *fx_info)
Definition: intfx.cpp:131
TESSLINE * next
Definition: blobs.h:265
void SetupNormalization(const BLOCK *block, const FCOORD *rotation, const DENORM *predecessor, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift)
Definition: normalis.cpp:96
int16_t Width
Definition: intfx.h:40
int size() const
Definition: genericvector.h:71
const DENORM * RootDenorm() const
Definition: normalis.h:258
int16_t NumBL
Definition: intfx.h:39
static void ExtractFeatures(const TBLOB &blob, bool nonlinear_norm, GenericVector< INT_FEATURE_STRUCT > *bl_features, GenericVector< INT_FEATURE_STRUCT > *cn_features, INT_FX_RESULT_STRUCT *results, GenericVector< int > *outline_cn_counts)
Definition: intfx.cpp:444
TPOINT pos
Definition: blobs.h:170
FCOORD sub_pixel_pos_at_index(const ICOORD &pos, int index) const
Definition: coutln.h:163
Definition: cluster.h:32
tesseract::CCUtilMutex atan_table_mutex
Definition: intfx.cpp:46
void SetupNonLinear(const DENORM *predecessor, const TBOX &box, float target_width, float target_height, float final_xshift, float final_yshift, const GenericVector< GenericVector< int > > &x_coords, const GenericVector< GenericVector< int > > &y_coords)
Definition: normalis.cpp:268
void InitIntegerFX()
Definition: intfx.cpp:53
int32_t count() const
Definition: linlsq.h:43
Definition: rect.h:34
#define INT_CHAR_NORM_RANGE
Definition: intproto.h:130
static TrainingSample * CopyFromFeatures(const INT_FX_RESULT_STRUCT &fx_info, const TBOX &bounding_box, const INT_FEATURE_STRUCT *features, int num_features)
int Modulo(int a, int b)
Definition: helpers.h:153
int direction(EDGEPT *point)
Definition: vecfuncs.cpp:43
bool IsHidden() const
Definition: blobs.h:160
int16_t Xmean
Definition: intfx.h:37
int start_step
Definition: blobs.h:180
void from_direction(uint8_t direction)
Definition: points.cpp:114
int16_t width() const
Definition: rect.h:115
void add(double x, double y)
Definition: linlsq.cpp:48
FCOORD mean_point() const
Definition: linlsq.cpp:166
int16_t left() const
Definition: rect.h:72
void LocalNormTransform(const TPOINT &pt, TPOINT *transformed) const
Definition: normalis.cpp:306
void DenormTransform(const DENORM *last_denorm, const TPOINT &pt, TPOINT *original) const
Definition: normalis.cpp:390
int16_t top() const
Definition: rect.h:58
void clear()
Definition: linlsq.cpp:32
FCOORD vector_fit() const
Definition: linlsq.cpp:251
integer coordinate
Definition: points.h:32
ICOORD position_at_index(int index) const
Definition: coutln.h:153
int edge_strength_at_index(int index) const
Definition: coutln.h:187
int IntCastRounded(double x)
Definition: helpers.h:168
Definition: linlsq.h:28
Definition: blobs.h:83
int32_t pathlength() const
Definition: coutln.h:135
EDGEPT * prev
Definition: blobs.h:177
TBOX bounding_box() const
Definition: blobs.cpp:478
uint8_t YBottom
Definition: intfx.h:41
int push_back(T object)
int16_t x
Definition: blobs.h:78
void GetPreciseBoundingBox(TBOX *precise_box) const
Definition: blobs.cpp:551
double y_variance() const
Definition: linlsq.h:87
float length() const
find length
Definition: points.h:229
int32_t Length
Definition: intfx.h:36
uint8_t YTop
Definition: intfx.h:42
C_OUTLINE * src_outline
Definition: blobs.h:178
const DENORM & denorm() const
Definition: blobs.h:347
Definition: points.h:189
double x_variance() const
Definition: linlsq.h:81
const double kStandardFeatureLength
Definition: intfx.h:46
int16_t right() const
Definition: rect.h:79
float x() const
Definition: points.h:208
void truncate(int size)
int16_t Ymean
Definition: intfx.h:37
int16_t NumCN
Definition: intfx.h:39
uint8_t to_direction() const
Definition: points.cpp:110
Definition: blobs.h:268
Definition: blobs.h:57
void GetEdgeCoords(const TBOX &box, GenericVector< GenericVector< int > > *x_coords, GenericVector< GenericVector< int > > *y_coords) const
Definition: blobs.cpp:567
int16_t y
Definition: blobs.h:79
int16_t bottom() const
Definition: rect.h:65
TESSLINE * outlines
Definition: blobs.h:384
EDGEPT * next
Definition: blobs.h:176
ICOORD step(int index) const
Definition: coutln.h:144
void pad(int xpad, int ypad)
Definition: rect.h:131
float y() const
Definition: points.h:211
FCOORD nearest_pt_on_line(const FCOORD &line_point, const FCOORD &dir_vector) const
Definition: points.cpp:135