tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
mergenf.h
1 /******************************************************************************
2  ** Filename: MergeNF.c
3  ** Purpose: Program for merging similar nano-feature protos
4  ** Author: Dan Johnson
5  ** History: Wed Nov 21 09:55:23 1990, 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 #ifndef TESSERACT_TRAINING_MERGENF_H_
20 #define TESSERACT_TRAINING_MERGENF_H_
21 
25 #include "callcpp.h"
26 #include "cluster.h"
27 #include "ocrfeatures.h"
28 #include "picofeat.h"
29 #include "protos.h"
30 
31 #define WORST_MATCH_ALLOWED (0.9)
32 #define WORST_EVIDENCE (1.0)
33 #define MAX_LENGTH_MISMATCH (2.0 * GetPicoFeatureLength())
34 
35 #define PROTO_SUFFIX ".mf.p"
36 #define CONFIG_SUFFIX ".cl"
37 #define NO_PROTO (-1)
38 #define XPOSITION 0
39 #define YPOSITION 1
40 #define MFLENGTH 2
41 #define ORIENTATION 3
42 
43 typedef struct {
44  float MinX, MaxX, MinY, MaxY;
45 } FRECT;
46 
50 #define CenterX(M) ((M)[XPOSITION])
51 #define CenterY(M) ((M)[YPOSITION])
52 #define LengthOf(M) ((M)[MFLENGTH])
53 #define OrientationOf(M) ((M)[ORIENTATION])
54 
58 float CompareProtos(PROTO p1, PROTO p2);
59 
60 void ComputeMergedProto(PROTO p1, PROTO p2, float w1, float w2,
61  PROTO MergedProto);
62 
63 int FindClosestExistingProto(CLASS_TYPE Class, int NumMerged[],
64  PROTOTYPE* Prototype);
65 
66 void MakeNewFromOld(PROTO New, PROTOTYPE* Old);
67 
68 float SubfeatureEvidence(FEATURE Feature, PROTO Proto);
69 
70 double EvidenceOf(double Similarity);
71 
72 bool DummyFastMatch(FEATURE Feature, PROTO Proto);
73 
74 void ComputePaddedBoundingBox(PROTO Proto, float TangentPad,
75  float OrthogonalPad, FRECT* BoundingBox);
76 
77 bool PointInside(FRECT* Rectangle, float X, float Y);
78 
79 #endif // TESSERACT_TRAINING_MERGENF_H_
Definition: cluster.h:67
Definition: mergenf.h:43
Definition: ocrfeatures.h:60
Definition: protos.h:42
Definition: protos.h:53
float MinY
Definition: mergenf.h:44