2007-03-08 04:03:40 +08:00
|
|
|
/******************************************************************************
|
|
|
|
** Filename: matchdefs.h
|
|
|
|
** Purpose: Generic interface definitions for feature matchers.
|
|
|
|
** Author: Dan Johnson
|
|
|
|
** History: Fri Jan 19 09:21:25 1990, DSJ, Created.
|
|
|
|
**
|
|
|
|
** (c) Copyright Hewlett-Packard Company, 1988.
|
|
|
|
** 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.
|
|
|
|
******************************************************************************/
|
|
|
|
#ifndef MATCHDEFS_H
|
|
|
|
#define MATCHDEFS_H
|
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
|
|
|
Include Files and Type Defines
|
|
|
|
----------------------------------------------------------------------------**/
|
2010-11-24 02:34:14 +08:00
|
|
|
#include "host.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
#include <stdio.h>
|
2007-07-18 09:15:07 +08:00
|
|
|
#include "unichar.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/* define the maximum number of classes defined for any matcher
|
2007-07-18 09:15:07 +08:00
|
|
|
and the maximum class id for any matcher. This must be changed
|
|
|
|
if more different classes need to be classified */
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
#define MAX_NUM_CLASSES INT16_MAX
|
2007-07-18 09:15:07 +08:00
|
|
|
#define MAX_CLASS_ID (MAX_NUM_CLASSES - 1)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** a CLASS_ID is the ascii character to be associated with a class */
|
2007-07-18 09:15:07 +08:00
|
|
|
typedef UNICHAR_ID CLASS_ID;
|
|
|
|
#define NO_CLASS (0)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** a PROTO_ID is the index of a prototype within it's class. Valid proto
|
2007-03-08 04:03:40 +08:00
|
|
|
id's are 0 to N-1 where N is the number of prototypes that make up the
|
|
|
|
class. */
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
typedef int16_t PROTO_ID;
|
2007-03-08 04:03:40 +08:00
|
|
|
#define NO_PROTO (-1)
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** FEATURE_ID is the index of a feature within a character description
|
2007-03-08 04:03:40 +08:00
|
|
|
The feature id ranges from 0 to N-1 where N is the number
|
|
|
|
of features in a character description. */
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
typedef uint8_t FEATURE_ID;
|
2007-03-08 04:03:40 +08:00
|
|
|
#define NO_FEATURE 255
|
|
|
|
#define NOISE_FEATURE 254
|
|
|
|
#define MISSING_PROTO 254
|
|
|
|
#define MAX_NUM_FEAT 40
|
|
|
|
#define MAX_FEATURE_ID 250
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** a RATING is the match rating returned by a classifier.
|
2007-03-08 04:03:40 +08:00
|
|
|
Higher is better. */
|
|
|
|
typedef FLOAT32 RATING;
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** a CERTAINTY is an indication of the degree of confidence of the
|
2007-03-08 04:03:40 +08:00
|
|
|
classifier. Higher is better. 0 means the match is as good as the
|
|
|
|
mean of the matches seen in training. -1 means the match was one
|
|
|
|
standard deviation worse than the training matches, etc. */
|
|
|
|
typedef FLOAT32 CERTAINTY;
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** define a data structure to hold a single match result */
|
2007-03-08 04:03:40 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
CLASS_ID Class;
|
|
|
|
RATING Rating;
|
|
|
|
CERTAINTY Certainty;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MATCH_RESULT;
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/** define a data structure for holding an array of match results */
|
2007-03-08 04:03:40 +08:00
|
|
|
typedef MATCH_RESULT SORTED_CLASSES[MAX_CLASS_ID + 1];
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
2007-03-08 04:03:40 +08:00
|
|
|
Public Function Prototypes
|
2010-07-27 21:23:23 +08:00
|
|
|
----------------------------------------------------------------------------*/
|
|
|
|
/**
|
2009-07-11 10:20:33 +08:00
|
|
|
all feature matchers that are to be used with the high level
|
2007-03-08 04:03:40 +08:00
|
|
|
classifier must support the following interface. The names will, of
|
|
|
|
course, be unique for each different matcher. Note also that
|
|
|
|
FEATURE_STRUCT is a data structure that is defined specifically for
|
|
|
|
each feature extractor/matcher pair.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* misc test functions for proto id's and feature id's */
|
|
|
|
#define IsValidFeature(Fid) ((Fid) < MAX_FEATURE_ID)
|
|
|
|
#define IsValidProto(Pid) ((Pid) >= 0)
|
|
|
|
|
|
|
|
#if defined(__STDC__) || defined(__cplusplus)
|
|
|
|
# define _ARGS(s) s
|
|
|
|
#else
|
|
|
|
# define _ARGS(s) ()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* matchdefs.c */
|
|
|
|
int CompareMatchResults
|
|
|
|
_ARGS ((MATCH_RESULT * Result1, MATCH_RESULT * Result2));
|
|
|
|
|
|
|
|
void PrintMatchResult _ARGS ((FILE * File, MATCH_RESULT * MatchResult));
|
|
|
|
|
|
|
|
void PrintMatchResults
|
|
|
|
_ARGS ((FILE * File, int N, MATCH_RESULT MatchResults[]));
|
|
|
|
|
|
|
|
#undef _ARGS
|
|
|
|
|
2010-07-27 21:23:23 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
2007-03-08 04:03:40 +08:00
|
|
|
Global Data Definitions and Declarations
|
2010-07-27 21:23:23 +08:00
|
|
|
----------------------------------------------------------------------------*/
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|