2018-04-26 01:04:50 +08:00
|
|
|
/******************************************************************************
|
2018-07-02 18:24:35 +08:00
|
|
|
** Filename: MergeNF.c
|
|
|
|
** Purpose: Program for merging similar nano-feature protos
|
|
|
|
** Author: Dan Johnson
|
|
|
|
** History: Wed Nov 21 09:55:23 1990, DSJ, Created.
|
|
|
|
**
|
|
|
|
** (c) Copyright Hewlett-Packard Company, 1988.
|
2018-04-26 01:04:50 +08:00
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
2018-07-02 18:24:35 +08:00
|
|
|
*****************************************************************************/
|
2018-04-26 01:04:50 +08:00
|
|
|
|
|
|
|
#ifndef TESSERACT_TRAINING_MERGENF_H_
|
|
|
|
#define TESSERACT_TRAINING_MERGENF_H_
|
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
2018-07-02 18:24:35 +08:00
|
|
|
Include Files and Type Defines
|
2018-04-26 01:04:50 +08:00
|
|
|
----------------------------------------------------------------------------**/
|
2018-07-02 18:24:35 +08:00
|
|
|
#include "callcpp.h"
|
2018-04-26 01:04:50 +08:00
|
|
|
#include "cluster.h"
|
|
|
|
#include "ocrfeatures.h"
|
|
|
|
#include "picofeat.h"
|
2018-07-02 18:24:35 +08:00
|
|
|
#include "protos.h"
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
#define WORST_MATCH_ALLOWED (0.9)
|
2018-04-26 01:04:50 +08:00
|
|
|
#define WORST_EVIDENCE (1.0)
|
2018-07-02 18:24:35 +08:00
|
|
|
#define MAX_LENGTH_MISMATCH (2.0 * GetPicoFeatureLength())
|
|
|
|
|
|
|
|
#define PROTO_SUFFIX ".mf.p"
|
|
|
|
#define CONFIG_SUFFIX ".cl"
|
|
|
|
#define NO_PROTO (-1)
|
|
|
|
#define XPOSITION 0
|
|
|
|
#define YPOSITION 1
|
|
|
|
#define MFLENGTH 2
|
|
|
|
#define ORIENTATION 3
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float MinX, MaxX, MinY, MaxY;
|
2018-04-26 01:04:50 +08:00
|
|
|
} FRECT;
|
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
2018-07-02 18:24:35 +08:00
|
|
|
Public Macros
|
2018-04-26 01:04:50 +08:00
|
|
|
----------------------------------------------------------------------------**/
|
2018-07-02 18:24:35 +08:00
|
|
|
#define CenterX(M) ((M)[XPOSITION])
|
|
|
|
#define CenterY(M) ((M)[YPOSITION])
|
|
|
|
#define LengthOf(M) ((M)[MFLENGTH])
|
|
|
|
#define OrientationOf(M) ((M)[ORIENTATION])
|
2018-04-26 01:04:50 +08:00
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
2018-07-02 18:24:35 +08:00
|
|
|
Public Function Prototypes
|
2018-04-26 01:04:50 +08:00
|
|
|
----------------------------------------------------------------------------**/
|
2018-07-02 18:24:35 +08:00
|
|
|
float CompareProtos(PROTO p1, PROTO p2);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
void ComputeMergedProto(PROTO p1, PROTO p2, float w1, float w2,
|
|
|
|
PROTO MergedProto);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
int FindClosestExistingProto(CLASS_TYPE Class, int NumMerged[],
|
|
|
|
PROTOTYPE* Prototype);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
void MakeNewFromOld(PROTO New, PROTOTYPE* Old);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
float SubfeatureEvidence(FEATURE Feature, PROTO Proto);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
double EvidenceOf(double Similarity);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-06-04 03:13:40 +08:00
|
|
|
bool DummyFastMatch(FEATURE Feature, PROTO Proto);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
void ComputePaddedBoundingBox(PROTO Proto, float TangentPad,
|
|
|
|
float OrthogonalPad, FRECT* BoundingBox);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
2018-07-02 18:24:35 +08:00
|
|
|
bool PointInside(FRECT* Rectangle, float X, float Y);
|
2018-04-26 01:04:50 +08:00
|
|
|
|
|
|
|
#endif // TESSERACT_TRAINING_MERGENF_H_
|