2007-03-08 04:03:40 +08:00
|
|
|
/******************************************************************************
|
|
|
|
** Filename: intmatcher.h
|
|
|
|
** Purpose: Interface to high level generic classifier routines.
|
|
|
|
** Author: Robert Moss
|
|
|
|
** History: Wed Feb 13 15:24:15 MST 1991, RWM, 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 INTMATCHER_H
|
|
|
|
#define INTMATCHER_H
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
#include "varable.h"
|
|
|
|
|
|
|
|
// Character fragments could be present in the trained templaes
|
|
|
|
// but turned on/off on the language-by-language basis or depending
|
|
|
|
// on particular properties of the corpus (e.g. when we expect the
|
|
|
|
// images to have low exposure).
|
|
|
|
extern BOOL_VAR_H(disable_character_fragments, FALSE,
|
|
|
|
"Do not include character fragments in the"
|
|
|
|
" results of the classifier");
|
|
|
|
|
|
|
|
extern INT_VAR_H(classify_integer_matcher_multiplier, 14,
|
|
|
|
"Integer Matcher Multiplier 0-255: ");
|
|
|
|
|
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
/**----------------------------------------------------------------------------
|
|
|
|
Include Files and Type Defines
|
|
|
|
----------------------------------------------------------------------------**/
|
|
|
|
#include "intproto.h"
|
|
|
|
#include "cutoffs.h"
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FLOAT32 Rating;
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8 Config;
|
|
|
|
uinT8 Config2;
|
|
|
|
uinT16 FeatureMisses;
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT_RESULT_STRUCT, *INT_RESULT;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FLOAT32 Rating;
|
2008-02-01 08:07:59 +08:00
|
|
|
INT_RESULT_STRUCT IMResult;
|
2007-03-08 04:03:40 +08:00
|
|
|
CLASS_ID Class;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CP_RESULT_STRUCT;
|
|
|
|
|
|
|
|
/*typedef CLASS_ID CLASS_PRUNER_RESULTS [MAX_NUM_CLASSES]; */
|
|
|
|
typedef CP_RESULT_STRUCT CLASS_PRUNER_RESULTS[MAX_NUM_CLASSES];
|
|
|
|
|
2008-04-22 08:23:04 +08:00
|
|
|
typedef uinT8 CLASS_NORMALIZATION_ARRAY[MAX_NUM_CLASSES];
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
Variables
|
|
|
|
-----------------------------------------------------------------------------*/
|
2009-07-11 10:17:36 +08:00
|
|
|
|
|
|
|
extern INT_VAR_H(classify_adapt_proto_thresh, 230,
|
|
|
|
"Threshold for good protos during adaptive 0-255: ");
|
|
|
|
|
|
|
|
extern INT_VAR_H(classify_adapt_feature_thresh, 230,
|
|
|
|
"Threshold for good features during adaptive 0-255: ");
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
|
|
|
Public Function Prototypes
|
|
|
|
----------------------------------------------------------------------------**/
|
|
|
|
|
|
|
|
void IntegerMatcher(INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT16 BlobLength,
|
|
|
|
inT16 NumFeatures,
|
2007-03-08 04:03:40 +08:00
|
|
|
INT_FEATURE_ARRAY Features,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8 NormalizationFactor,
|
2007-03-08 04:03:40 +08:00
|
|
|
INT_RESULT Result,
|
|
|
|
int Debug);
|
|
|
|
|
|
|
|
int FindGoodProtos(INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT16 BlobLength,
|
|
|
|
inT16 NumFeatures,
|
2007-03-08 04:03:40 +08:00
|
|
|
INT_FEATURE_ARRAY Features,
|
|
|
|
PROTO_ID *ProtoArray,
|
|
|
|
int Debug);
|
|
|
|
|
|
|
|
int FindBadFeatures(INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT16 BlobLength,
|
|
|
|
inT16 NumFeatures,
|
2007-03-08 04:03:40 +08:00
|
|
|
INT_FEATURE_ARRAY Features,
|
|
|
|
FEATURE_ID *FeatureArray,
|
|
|
|
int Debug);
|
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void InitIntegerMatcher();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void PrintIntMatcherStats(FILE *f);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void SetProtoThresh(FLOAT32 Threshold);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void SetFeatureThresh(FLOAT32 Threshold);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void SetBaseLineMatch();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void SetCharNormMatch();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
|
|
|
Private Function Prototypes
|
|
|
|
----------------------------------------------------------------------------**/
|
|
|
|
void IMClearTables (INT_CLASS ClassTemplate,
|
|
|
|
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX]);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-04-22 08:23:04 +08:00
|
|
|
void IMClearFeatureEvidenceTable (uinT8 FeatureEvidence[MAX_NUM_CONFIGS],
|
2007-03-08 04:03:40 +08:00
|
|
|
int NumConfigs);
|
|
|
|
|
|
|
|
void IMDebugConfiguration(INT_FEATURE FeatureNum,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT16 ActualProtoNum,
|
|
|
|
uinT8 Evidence,
|
2007-03-08 04:03:40 +08:00
|
|
|
BIT_VECTOR ConfigMask,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT32 ConfigWord);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void IMDebugConfigurationSum(INT_FEATURE FeatureNum,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8 *FeatureEvidence,
|
|
|
|
inT32 ConfigCount);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
int IMUpdateTablesForFeature (INT_CLASS ClassTemplate,
|
2007-03-08 04:03:40 +08:00
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
|
|
|
int FeatureNum,
|
|
|
|
INT_FEATURE Feature,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8 FeatureEvidence[MAX_NUM_CONFIGS],
|
2007-03-08 04:03:40 +08:00
|
|
|
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8
|
2007-03-08 04:03:40 +08:00
|
|
|
ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
|
|
|
int Debug);
|
|
|
|
|
|
|
|
#ifndef GRAPHICS_DISABLED
|
|
|
|
void IMDebugFeatureProtoError (INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
|
|
|
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8
|
2007-03-08 04:03:40 +08:00
|
|
|
ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 NumFeatures, int Debug);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void IMDisplayProtoDebugInfo (INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8
|
2007-03-08 04:03:40 +08:00
|
|
|
ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
|
|
|
int Debug);
|
|
|
|
|
|
|
|
void IMDisplayFeatureDebugInfo(INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ProtoMask,
|
|
|
|
BIT_VECTOR ConfigMask,
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 NumFeatures,
|
2007-03-08 04:03:40 +08:00
|
|
|
INT_FEATURE_ARRAY Features,
|
|
|
|
int Debug);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void IMUpdateSumOfProtoEvidences (INT_CLASS ClassTemplate,
|
|
|
|
BIT_VECTOR ConfigMask,
|
|
|
|
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT8
|
2007-03-08 04:03:40 +08:00
|
|
|
ProtoEvidence[MAX_NUM_PROTOS]
|
2008-04-22 08:23:04 +08:00
|
|
|
[MAX_PROTO_INDEX], inT16 NumFeatures);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void IMNormalizeSumOfEvidences (INT_CLASS ClassTemplate,
|
|
|
|
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
2008-04-22 08:23:04 +08:00
|
|
|
inT16 NumFeatures, inT32 used_features);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
int IMFindBestMatch (INT_CLASS ClassTemplate,
|
|
|
|
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT16 BlobLength,
|
|
|
|
uinT8 NormalizationFactor, INT_RESULT Result);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
#ifndef GRAPHICS_DISABLED
|
|
|
|
void IMDebugBestMatch(int BestMatch,
|
|
|
|
INT_RESULT Result,
|
2008-04-22 08:23:04 +08:00
|
|
|
uinT16 BlobLength,
|
|
|
|
uinT8 NormalizationFactor);
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|
|
|
|
|
2008-02-01 08:07:59 +08:00
|
|
|
void HeapSort (int n, register int ra[], register int rb[]);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/**----------------------------------------------------------------------------
|
|
|
|
Global Data Definitions and Declarations
|
|
|
|
----------------------------------------------------------------------------**/
|
2008-04-22 08:23:04 +08:00
|
|
|
extern uinT32 EvidenceMultMask;
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|