tesseract  5.0.0-alpha-619-ge9db
mergenf.h
Go to the documentation of this file.
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_
picofeat.h
MakeNewFromOld
void MakeNewFromOld(PROTO New, PROTOTYPE *Old)
Definition: mergenf.cpp:193
FRECT
Definition: mergenf.h:42
PROTO_STRUCT
Definition: protos.h:34
ComputeMergedProto
void ComputeMergedProto(PROTO p1, PROTO p2, float w1, float w2, PROTO MergedProto)
Definition: mergenf.cpp:123
ComputePaddedBoundingBox
void ComputePaddedBoundingBox(PROTO Proto, float TangentPad, float OrthogonalPad, FRECT *BoundingBox)
Definition: mergenf.cpp:293
FEATURE_STRUCT
Definition: ocrfeatures.h:58
EvidenceOf
double EvidenceOf(double Similarity)
Definition: mergenf.cpp:232
PROTOTYPE
Definition: cluster.h:62
FindClosestExistingProto
int FindClosestExistingProto(CLASS_TYPE Class, int NumMerged[], PROTOTYPE *Prototype)
Definition: mergenf.cpp:155
SubfeatureEvidence
float SubfeatureEvidence(FEATURE Feature, PROTO Proto)
Definition: mergenf.cpp:208
ocrfeatures.h
CLASS_STRUCT
Definition: protos.h:45
PointInside
bool PointInside(FRECT *Rectangle, float X, float Y)
Definition: mergenf.cpp:317
callcpp.h
cluster.h
CompareProtos
float CompareProtos(PROTO p1, PROTO p2)
Definition: mergenf.cpp:63
protos.h
DummyFastMatch
bool DummyFastMatch(FEATURE Feature, PROTO Proto)
Definition: mergenf.cpp:259