Skip to content

Commit

Permalink
Fixed name collision with jpeg library
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@155 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
theraysmith committed Apr 22, 2008
1 parent fa30c09 commit 9cd87f0
Show file tree
Hide file tree
Showing 22 changed files with 573 additions and 566 deletions.
20 changes: 10 additions & 10 deletions classify/adaptive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ ADAPT_CLASS ReadAdaptedClass(FILE *File) {
/* then read in the definitions of the permanent protos and configs */
Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
fread ((char *) Class->PermProtos, sizeof (UINT32),
fread ((char *) Class->PermProtos, sizeof (uinT32),
WordsInVectorOfSize (MAX_NUM_PROTOS), File);
fread ((char *) Class->PermConfigs, sizeof (UINT32),
fread ((char *) Class->PermConfigs, sizeof (uinT32),
WordsInVectorOfSize (MAX_NUM_CONFIGS), File);

/* then read in the list of temporary protos */
Expand Down Expand Up @@ -371,9 +371,9 @@ PERM_CONFIG ReadPermConfig(FILE *File) {
** History: Tue Mar 19 14:25:26 1991, DSJ, Created.
*/
PERM_CONFIG Config;
UINT8 NumAmbigs;
uinT8 NumAmbigs;

fread ((char *) &NumAmbigs, sizeof (UINT8), 1, File);
fread ((char *) &NumAmbigs, sizeof (uinT8), 1, File);
Config = (PERM_CONFIG) Emalloc (sizeof (char) * (NumAmbigs + 1));
fread (Config, sizeof (UNICHAR_ID), NumAmbigs, File);
Config[NumAmbigs] = -1;
Expand Down Expand Up @@ -403,7 +403,7 @@ TEMP_CONFIG ReadTempConfig(FILE *File) {
fread ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);

Config->Protos = NewBitVector (Config->ProtoVectorSize * BITSINLONG);
fread ((char *) Config->Protos, sizeof (UINT32),
fread ((char *) Config->Protos, sizeof (uinT32),
Config->ProtoVectorSize, File);

return (Config);
Expand Down Expand Up @@ -433,9 +433,9 @@ void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) {
fwrite ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);

/* then write out the definitions of the permanent protos and configs */
fwrite ((char *) Class->PermProtos, sizeof (UINT32),
fwrite ((char *) Class->PermProtos, sizeof (uinT32),
WordsInVectorOfSize (MAX_NUM_PROTOS), File);
fwrite ((char *) Class->PermConfigs, sizeof (UINT32),
fwrite ((char *) Class->PermConfigs, sizeof (uinT32),
WordsInVectorOfSize (MAX_NUM_CONFIGS), File);

/* then write out the list of temporary protos */
Expand Down Expand Up @@ -500,13 +500,13 @@ void WritePermConfig(FILE *File, PERM_CONFIG Config) {
** Exceptions: none
** History: Tue Mar 19 13:55:44 1991, DSJ, Created.
*/
UINT8 NumAmbigs = 0;
uinT8 NumAmbigs = 0;

assert (Config != NULL);
while (Config[NumAmbigs] > 0)
++NumAmbigs;

fwrite ((char *) &NumAmbigs, sizeof (UINT8), 1, File);
fwrite ((char *) &NumAmbigs, sizeof (uinT8), 1, File);
fwrite (Config, sizeof (UNICHAR_ID), NumAmbigs, File);

} /* WritePermConfig */
Expand All @@ -530,7 +530,7 @@ void WriteTempConfig(FILE *File, TEMP_CONFIG Config) {
assert (Config->ContextsSeen == NULL);

fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);
fwrite ((char *) Config->Protos, sizeof (UINT32),
fwrite ((char *) Config->Protos, sizeof (uinT32),
Config->ProtoVectorSize, File);

} /* WriteTempConfig */
16 changes: 8 additions & 8 deletions classify/adaptive.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

typedef struct
{
UINT16 ProtoId;
UINT16 dummy;
uinT16 ProtoId;
uinT16 dummy;
PROTO_STRUCT Proto;
}

Expand All @@ -38,8 +38,8 @@ typedef TEMP_PROTO_STRUCT *TEMP_PROTO;

typedef struct
{
UINT8 NumTimesSeen;
UINT8 ProtoVectorSize;
uinT8 NumTimesSeen;
uinT8 ProtoVectorSize;
PROTO_ID MaxProtoId;
LIST ContextsSeen;
BIT_VECTOR Protos;
Expand All @@ -56,8 +56,8 @@ typedef union

typedef struct
{
UINT8 NumPermConfigs;
UINT8 dummy[3];
uinT8 NumPermConfigs;
uinT8 dummy[3];
BIT_VECTOR PermProtos;
BIT_VECTOR PermConfigs;
LIST TempProtos;
Expand All @@ -68,8 +68,8 @@ typedef ADAPT_CLASS_STRUCT *ADAPT_CLASS;
typedef struct
{
INT_TEMPLATES Templates;
UINT8 NumPermClasses;
UINT8 dummy[3];
uinT8 NumPermClasses;
uinT8 dummy[3];
ADAPT_CLASS Class[MAX_NUM_CLASSES];
} ADAPT_TEMPLATES_STRUCT;
typedef ADAPT_TEMPLATES_STRUCT *ADAPT_TEMPLATES;
Expand Down
70 changes: 32 additions & 38 deletions classify/adaptmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@

typedef struct
{
INT32 BlobLength;
inT32 BlobLength;
int NumMatches;
CLASS_ID Classes[MAX_NUM_CLASSES];
FLOAT32 Ratings[MAX_CLASS_ID + 1];
UINT8 Configs[MAX_CLASS_ID + 1];
uinT8 Configs[MAX_CLASS_ID + 1];
FLOAT32 BestRating;
CLASS_ID BestClass;
UINT8 BestConfig;
uinT8 BestConfig;
CLASS_PRUNER_RESULTS CPResults;
}

Expand Down Expand Up @@ -171,7 +171,7 @@ int GetBaselineFeatures(TBLOB *Blob,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength);
inT32 *BlobLength);

FLOAT32 GetBestRatingFor(TBLOB *Blob, LINE_STATS *LineStats, CLASS_ID ClassId);

Expand All @@ -180,21 +180,21 @@ int GetCharNormFeatures(TBLOB *Blob,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength);
inT32 *BlobLength);

int GetIntBaselineFeatures(TBLOB *Blob,
LINE_STATS *LineStats,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength);
inT32 *BlobLength);

int GetIntCharNormFeatures(TBLOB *Blob,
LINE_STATS *LineStats,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength);
inT32 *BlobLength);

void InitMatcherRatings(register FLOAT32 *Rating);

Expand Down Expand Up @@ -1383,7 +1383,7 @@ void AdaptToChar(TBLOB *Blob,
cprintf ("Best match to temp config %d = %4.1f%%.\n",
IntResult.Config, (1.0 - IntResult.Rating) * 100.0);
if (LearningDebugLevel >= 2) {
UINT32 ConfigMask;
uinT32 ConfigMask;
ConfigMask = 1 << IntResult.Config;
ShowMatchDisplay();
IntegerMatcher (IClass, AllProtosOn, (BIT_VECTOR)&ConfigMask,
Expand Down Expand Up @@ -1593,7 +1593,7 @@ void AmbigClassifier(TBLOB *Blob,
// Factored-out calls to IntegerMatcher based on class pruner results.
// Returns integer matcher results inside CLASS_PRUNER_RESULTS structure.
void MasterMatcher(INT_TEMPLATES templates,
INT16 num_features,
inT16 num_features,
INT_FEATURE_ARRAY features,
CLASS_NORMALIZATION_ARRAY norm_factors,
ADAPT_CLASS* classes,
Expand All @@ -1613,7 +1613,7 @@ void MasterMatcher(INT_TEMPLATES templates,
IntegerMatcher(ClassForClassId(templates, class_id),
protos, configs, final_results->BlobLength,
num_features, features, norm_factors[class_index],
&int_result, debug);
&int_result, NO_DEBUG);
// Compute class feature corrections.
double miss_penalty = tessedit_class_miss_scale *
int_result.FeatureMisses;
Expand Down Expand Up @@ -1877,7 +1877,8 @@ LIST ConvertMatchesToChoices(ADAPT_RESULTS *Results) {
NextMatch_unichar,
choice_lengths,
Rating, Certainty,
Results->Configs[NextMatch]);
Results->Configs[NextMatch],
unicharset.get_script(NextMatch));
}
return (Choices);

Expand All @@ -1904,7 +1905,7 @@ void DebugAdaptiveClassifier(TBLOB *Blob,
** History: Wed Mar 13 16:44:41 1991, DSJ, Created.
*/
const char *Prompt =
"\nType class id (or CTRL-A,B,C) in IntegerMatch Window ...";
"Left-click in IntegerMatch Window to continue or right click to debug...";
const char *DebugMode = "All Templates";
CLASS_ID LastClass = Results->BestClass;
CLASS_ID ClassId;
Expand Down Expand Up @@ -1946,8 +1947,8 @@ void DebugAdaptiveClassifier(TBLOB *Blob,
LastClass = ClassId;

ShowMatchDisplay();
cprintf ("\nDebugging class = %s (%s) ...\n",
unicharset.id_to_unichar(LastClass), DebugMode);
cprintf ("\nDebugging class = %d = %s (%s) ...\n",
LastClass, unicharset.id_to_unichar(LastClass), DebugMode);
ShowBestMatchFor(Blob, LineStats, LastClass, AdaptiveOn, PreTrainedOn);
UpdateMatchDisplay();
}
Expand Down Expand Up @@ -2158,7 +2159,7 @@ void DoAdaptiveMatch(TBLOB *Blob,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength) {
inT32 *BlobLength) {
/*
** Parameters:
** Blob
Expand Down Expand Up @@ -2244,7 +2245,7 @@ void DoAdaptiveMatch(TBLOB *Blob,
INT_RESULT_STRUCT CNResult, BLResult;
CLASS_NORMALIZATION_ARRAY CNAdjust, BLAdjust;
CLASS_INDEX ClassIndex;
INT32 BlobLength;
inT32 BlobLength;

CNResult.Rating = BLResult.Rating = 1.0;

Expand Down Expand Up @@ -2293,7 +2294,7 @@ void DoAdaptiveMatch(TBLOB *Blob,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength) {
inT32 *BlobLength) {
/*
** Parameters:
** Blob
Expand Down Expand Up @@ -2331,7 +2332,7 @@ void DoAdaptiveMatch(TBLOB *Blob,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength) {
inT32 *BlobLength) {
/*
** Parameters:
** Blob
Expand Down Expand Up @@ -2394,7 +2395,7 @@ void DoAdaptiveMatch(TBLOB *Blob,
INT_TEMPLATES Templates,
INT_FEATURE_ARRAY IntFeatures,
CLASS_NORMALIZATION_ARRAY CharNormArray,
INT32 *BlobLength) {
inT32 *BlobLength) {
/*
** Parameters:
** Blob
Expand Down Expand Up @@ -2853,20 +2854,11 @@ void DoAdaptiveMatch(TBLOB *Blob,
** Exceptions: none
** History: Mon Mar 18 09:24:53 1991, DSJ, Created.
*/
int i;

if (Results->NumMatches > 0) {
cprintf ("%s(%d) %4.1f ",
unicharset.id_to_unichar(Results->Classes[0]),
Results->Classes[0],
Results->Ratings[Results->Classes[0]] * 100.0);

for (i = 1; i < Results->NumMatches; i++) {
cprintf ("%s(%d) %4.1f ",
unicharset.id_to_unichar(Results->Classes[i]),
Results->Classes[i],
Results->Ratings[Results->Classes[i]] * 100.0);
}
for (int i = 0; i < Results->NumMatches; ++i) {
cprintf("%s(%d) %.2f ",
unicharset.debug_str(Results->Classes[i]).string(),
Results->Classes[i],
Results->Ratings[Results->Classes[i]] * 100.0);
}
} /* PrintAdaptiveMatchResults */

Expand Down Expand Up @@ -3046,22 +3038,23 @@ void DoAdaptiveMatch(TBLOB *Blob,
INT_RESULT_STRUCT CNResult, BLResult;
CLASS_NORMALIZATION_ARRAY CNAdjust, BLAdjust;
CLASS_INDEX ClassIndex;
INT32 BlobLength;
UINT32 ConfigMask;
inT32 BlobLength;
uinT32 ConfigMask;
static int next_config = -1;

if (PreTrainedOn) next_config = -1;

CNResult.Rating = BLResult.Rating = 2.0;

if (!LegalClassId (ClassId)) {
cprintf ("%c is not a legal class!!\n", ClassId);
cprintf ("%d is not a legal class id!!\n", ClassId);
return;
}

if (PreTrainedOn) {
if (UnusedClassIdIn (PreTrainedTemplates, ClassId))
cprintf ("No built-in templates for class '%c'\n", ClassId);
cprintf ("No built-in templates for class %d = %s\n",
ClassId, unicharset.id_to_unichar(ClassId));
else {
NumCNFeatures = GetCharNormFeatures (Blob, LineStats,
PreTrainedTemplates,
Expand All @@ -3086,7 +3079,8 @@ void DoAdaptiveMatch(TBLOB *Blob,

if (AdaptiveOn) {
if (UnusedClassIdIn (AdaptedTemplates->Templates, ClassId))
cprintf ("No AD templates for class '%c'\n", ClassId);
cprintf ("No AD templates for class %d = %s\n",
ClassId, unicharset.id_to_unichar(ClassId));
else {
NumBLFeatures = GetBaselineFeatures (Blob, LineStats,
AdaptedTemplates->Templates,
Expand Down
6 changes: 3 additions & 3 deletions classify/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef TPOINT SCALE;
/*----------------------------------------------------------------------
V a r i a b l e s
----------------------------------------------------------------------*/
INT8 baseline_normalized = TRUE;
inT8 baseline_normalized = TRUE;

make_int_var (baseline_enable, 1, make_baseline_enable,
4, 3, set_baseline_enable, "Baseline Enable");
Expand All @@ -51,8 +51,8 @@ make_int_var (baseline_enable, 1, make_baseline_enable,
*
* Initialize the needed baseline variables.
**********************************************************************/
void init_baseline() {
make_baseline_enable();
void init_baseline() {
make_baseline_enable();

baseline_normalized = baseline_enable;
}
4 changes: 2 additions & 2 deletions classify/baseline.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/*----------------------------------------------------------------------
V a r i a b l e s
----------------------------------------------------------------------*/
extern INT8 baseline_normalized;
extern inT8 baseline_normalized;
extern int baseline_enable;

/*----------------------------------------------------------------------
Expand Down Expand Up @@ -73,7 +73,7 @@ extern int baseline_enable;
/*----------------------------------------------------------------------
F u n c t i o n s
----------------------------------------------------------------------*/
void init_baseline();
void init_baseline();

/*
#if defined(__STDC__) || defined(__cplusplus)
Expand Down
Loading

0 comments on commit 9cd87f0

Please sign in to comment.