Changes to training for 3.00

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@302 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
theraysmith 2009-07-11 02:44:07 +00:00
parent 0a9ad20d1c
commit 5b79487a8e
25 changed files with 2268 additions and 10038 deletions

View File

@ -7,48 +7,55 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/wordrec -I$(top_srcdir)/cutil \
-I$(top_srcdir)/textord
EXTRA_DIST = training.cpp unicharset_extractor.dsp wordlist2dawg.dsp \
cntraining.dsp mftraining.dsp \
unicharset_extractor.vcproj wordlist2dawg.vcproj \
EXTRA_DIST = unicharset_extractor.vcproj wordlist2dawg.vcproj \
cntraining.vcproj mftraining.vcproj
include_HEADERS = \
mergenf.h name2char.h training.h
commontraining.h mergenf.h name2char.h
lib_LIBRARIES = libtesseract_training.a
libtesseract_training_a_SOURCES = \
name2char.cpp
name2char.cpp commontraining.cpp
bin_PROGRAMS = cntraining mftraining unicharset_extractor wordlist2dawg
cntraining_SOURCES = cnTraining.cpp
bin_PROGRAMS = cntraining combine_tessdata mftraining unicharset_extractor wordlist2dawg
combine_tessdata_SOURCES = combine_tessdata.cpp
combine_tessdata_LDADD = \
../ccutil/libtesseract_ccutil.a
cntraining_SOURCES = cntraining.cpp
cntraining_LDADD = \
libtesseract_training.a \
../textord/libtesseract_textord.a \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../ccstruct/libtesseract_ccstruct.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
mftraining_SOURCES = mfTraining.cpp mergenf.cpp
mftraining_SOURCES = mftraining.cpp mergenf.cpp
mftraining_LDADD = \
libtesseract_training.a \
../textord/libtesseract_textord.a \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../ccstruct/libtesseract_ccstruct.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
unicharset_extractor_SOURCES = unicharset_extractor.cpp
unicharset_extractor_LDADD = \
../ccutil/libtesseract_ccutil.a
wordlist2dawg_SOURCES = wordlist2dawg.cpp
wordlist2dawg_LDADD = \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../cutil/libtesseract_cutil.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a

View File

@ -34,8 +34,9 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = cntraining$(EXEEXT) mftraining$(EXEEXT) \
unicharset_extractor$(EXEEXT) wordlist2dawg$(EXEEXT)
bin_PROGRAMS = cntraining$(EXEEXT) combine_tessdata$(EXEEXT) \
mftraining$(EXEEXT) unicharset_extractor$(EXEEXT) \
wordlist2dawg$(EXEEXT)
subdir = training
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
@ -61,29 +62,33 @@ AR = ar
ARFLAGS = cru
libtesseract_training_a_AR = $(AR) $(ARFLAGS)
libtesseract_training_a_LIBADD =
am_libtesseract_training_a_OBJECTS = name2char.$(OBJEXT)
am_libtesseract_training_a_OBJECTS = name2char.$(OBJEXT) \
commontraining.$(OBJEXT)
libtesseract_training_a_OBJECTS = \
$(am_libtesseract_training_a_OBJECTS)
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_cntraining_OBJECTS = cnTraining.$(OBJEXT)
am_cntraining_OBJECTS = cntraining.$(OBJEXT)
cntraining_OBJECTS = $(am_cntraining_OBJECTS)
cntraining_DEPENDENCIES = libtesseract_training.a \
../textord/libtesseract_textord.a \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a ../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a ../cutil/libtesseract_cutil.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
am_mftraining_OBJECTS = mfTraining.$(OBJEXT) mergenf.$(OBJEXT)
am_combine_tessdata_OBJECTS = combine_tessdata.$(OBJEXT)
combine_tessdata_OBJECTS = $(am_combine_tessdata_OBJECTS)
combine_tessdata_DEPENDENCIES = ../ccutil/libtesseract_ccutil.a
am_mftraining_OBJECTS = mftraining.$(OBJEXT) mergenf.$(OBJEXT)
mftraining_OBJECTS = $(am_mftraining_OBJECTS)
mftraining_DEPENDENCIES = libtesseract_training.a \
../textord/libtesseract_textord.a \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a ../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a ../cutil/libtesseract_cutil.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
am_unicharset_extractor_OBJECTS = unicharset_extractor.$(OBJEXT)
@ -91,9 +96,10 @@ unicharset_extractor_OBJECTS = $(am_unicharset_extractor_OBJECTS)
unicharset_extractor_DEPENDENCIES = ../ccutil/libtesseract_ccutil.a
am_wordlist2dawg_OBJECTS = wordlist2dawg.$(OBJEXT)
wordlist2dawg_OBJECTS = $(am_wordlist2dawg_OBJECTS)
wordlist2dawg_DEPENDENCIES = ../dict/libtesseract_dict.a \
../cutil/libtesseract_cutil.a \
wordlist2dawg_DEPENDENCIES = ../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a ../cutil/libtesseract_cutil.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@ -105,11 +111,12 @@ CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
-o $@
SOURCES = $(libtesseract_training_a_SOURCES) $(cntraining_SOURCES) \
$(combine_tessdata_SOURCES) $(mftraining_SOURCES) \
$(unicharset_extractor_SOURCES) $(wordlist2dawg_SOURCES)
DIST_SOURCES = $(libtesseract_training_a_SOURCES) \
$(cntraining_SOURCES) $(combine_tessdata_SOURCES) \
$(mftraining_SOURCES) $(unicharset_extractor_SOURCES) \
$(wordlist2dawg_SOURCES)
DIST_SOURCES = $(libtesseract_training_a_SOURCES) \
$(cntraining_SOURCES) $(mftraining_SOURCES) \
$(unicharset_extractor_SOURCES) $(wordlist2dawg_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@ -237,39 +244,41 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/wordrec -I$(top_srcdir)/cutil \
-I$(top_srcdir)/textord
EXTRA_DIST = training.cpp unicharset_extractor.dsp wordlist2dawg.dsp \
cntraining.dsp mftraining.dsp \
unicharset_extractor.vcproj wordlist2dawg.vcproj \
EXTRA_DIST = unicharset_extractor.vcproj wordlist2dawg.vcproj \
cntraining.vcproj mftraining.vcproj
include_HEADERS = \
mergenf.h name2char.h training.h
commontraining.h mergenf.h name2char.h
lib_LIBRARIES = libtesseract_training.a
libtesseract_training_a_SOURCES = \
name2char.cpp
name2char.cpp commontraining.cpp
cntraining_SOURCES = cnTraining.cpp
combine_tessdata_SOURCES = combine_tessdata.cpp
combine_tessdata_LDADD = \
../ccutil/libtesseract_ccutil.a
cntraining_SOURCES = cntraining.cpp
cntraining_LDADD = \
libtesseract_training.a \
../textord/libtesseract_textord.a \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../ccstruct/libtesseract_ccstruct.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
mftraining_SOURCES = mfTraining.cpp mergenf.cpp
mftraining_SOURCES = mftraining.cpp mergenf.cpp
mftraining_LDADD = \
libtesseract_training.a \
../textord/libtesseract_textord.a \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../ccstruct/libtesseract_ccstruct.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
@ -279,9 +288,11 @@ unicharset_extractor_LDADD = \
wordlist2dawg_SOURCES = wordlist2dawg.cpp
wordlist2dawg_LDADD = \
../classify/libtesseract_classify.a \
../dict/libtesseract_dict.a \
../cutil/libtesseract_cutil.a \
../ccstruct/libtesseract_ccstruct.a \
../image/libtesseract_image.a \
../cutil/libtesseract_cutil.a \
../viewer/libtesseract_viewer.a \
../ccutil/libtesseract_ccutil.a
@ -377,6 +388,9 @@ clean-binPROGRAMS:
cntraining$(EXEEXT): $(cntraining_OBJECTS) $(cntraining_DEPENDENCIES)
@rm -f cntraining$(EXEEXT)
$(CXXLINK) $(cntraining_OBJECTS) $(cntraining_LDADD) $(LIBS)
combine_tessdata$(EXEEXT): $(combine_tessdata_OBJECTS) $(combine_tessdata_DEPENDENCIES)
@rm -f combine_tessdata$(EXEEXT)
$(CXXLINK) $(combine_tessdata_OBJECTS) $(combine_tessdata_LDADD) $(LIBS)
mftraining$(EXEEXT): $(mftraining_OBJECTS) $(mftraining_DEPENDENCIES)
@rm -f mftraining$(EXEEXT)
$(CXXLINK) $(mftraining_OBJECTS) $(mftraining_LDADD) $(LIBS)
@ -393,9 +407,11 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cnTraining.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cntraining.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/combine_tessdata.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commontraining.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mergenf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfTraining.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mftraining.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/name2char.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unicharset_extractor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wordlist2dawg.Po@am__quote@

View File

@ -1,855 +0,0 @@
/******************************************************************************
** Filename: cnTraining.cpp
** Purpose: Generates a normproto and pffmtable.
** Author: Dan Johnson
** Revisment: Christy Russon
** History: Fri Aug 18 08:53:50 1989, DSJ, Created.
** 5/25/90, DSJ, Adapted to multiple feature types.
** Tuesday, May 17, 1998 Changes made to make feature specific and
** simplify structures. First step in simplifying training process.
**
** (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.
******************************************************************************/
/**----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "oldlist.h"
#include "efio.h"
#include "emalloc.h"
#include "featdefs.h"
#include "tessopt.h"
#include "ocrfeatures.h"
#include "general.h"
#include "clusttool.h"
#include "cluster.h"
#include "name2char.h"
#include <string.h>
#include <stdio.h>
#include <math.h>
#include "unichar.h"
#define MAXNAMESIZE 80
#define MAX_NUM_SAMPLES 10000
#define PROGRAM_FEATURE_TYPE "cn"
#define MINSD (1.0f / 64.0f)
int row_number; /* cjn: fixes link problem */
typedef struct
{
char *Label;
int SampleCount;
LIST List;
}
LABELEDLISTNODE, *LABELEDLIST;
#define round(x,frag)(floor(x/frag+.5)*frag)
/**----------------------------------------------------------------------------
Public Function Prototypes
----------------------------------------------------------------------------**/
int main (
int argc,
char **argv);
/**----------------------------------------------------------------------------
Private Function Prototypes
----------------------------------------------------------------------------**/
void ParseArguments(
int argc,
char **argv);
char *GetNextFilename ();
void ReadTrainingSamples (
FILE *File,
LIST* TrainingSamples);
LABELEDLIST FindList (
LIST List,
char *Label);
LABELEDLIST NewLabeledList (
char *Label);
void WriteTrainingSamples (
char *Directory,
LIST CharList);
void WriteNormProtos (
char *Directory,
LIST LabeledProtoList,
CLUSTERER *Clusterer);
void FreeTrainingSamples (
LIST CharList);
void FreeNormProtoList (
LIST CharList);
void FreeLabeledList (
LABELEDLIST LabeledList);
CLUSTERER *SetUpForClustering(
LABELEDLIST CharSample);
/*
PARAMDESC *ConvertToPARAMDESC(
PARAM_DESC* Param_Desc,
int N);
*/
void AddToNormProtosList(
LIST* NormProtoList,
LIST ProtoList,
char* CharName);
void WriteProtos(
FILE *File,
uinT16 N,
LIST ProtoList,
BOOL8 WriteSigProtos,
BOOL8 WriteInsigProtos);
int NumberOfProtos(
LIST ProtoList,
BOOL8 CountSigProtos,
BOOL8 CountInsigProtos);
/**----------------------------------------------------------------------------
Global Data Definitions and Declarations
----------------------------------------------------------------------------**/
static char FontName[MAXNAMESIZE];
/* globals used for parsing command line arguments */
static char *Directory = NULL;
static int MaxNumSamples = MAX_NUM_SAMPLES;
static int Argc;
static char **Argv;
/* globals used to control what information is saved in the output file */
static BOOL8 ShowAllSamples = FALSE;
static BOOL8 ShowSignificantProtos = TRUE;
static BOOL8 ShowInsignificantProtos = FALSE;
/* global variable to hold configuration parameters to control clustering */
//-M 0.025 -B 0.05 -I 0.8 -C 1e-3
static CLUSTERCONFIG Config =
{
elliptical, 0.025, 0.05, 0.8, 1e-3, 0
};
static FLOAT32 RoundingAccuracy = 0.0;
/**----------------------------------------------------------------------------
Public Code
----------------------------------------------------------------------------**/
/*---------------------------------------------------------------------------*/
int main (
int argc,
char **argv)
/*
** Parameters:
** argc number of command line arguments
** argv array of command line arguments
** Globals: none
** Operation:
** This program reads in a text file consisting of feature
** samples from a training page in the following format:
**
** FontName CharName NumberOfFeatureTypes(N)
** FeatureTypeName1 NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** FeatureTypeName2 NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** ...
** FeatureTypeNameN NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** FontName CharName ...
**
** It then appends these samples into a separate file for each
** character. The name of the file is
**
** DirectoryName/FontName/CharName.FeatureTypeName
**
** The DirectoryName can be specified via a command
** line argument. If not specified, it defaults to the
** current directory. The format of the resulting files is:
**
** NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** NumberOfFeatures(M)
** ...
**
** The output files each have a header which describes the
** type of feature which the file contains. This header is
** in the format required by the clusterer. A command line
** argument can also be used to specify that only the first
** N samples of each class should be used.
** Return: none
** Exceptions: none
** History: Fri Aug 18 08:56:17 1989, DSJ, Created.
*/
{
char *PageName;
FILE *TrainingPage;
LIST CharList = NIL;
CLUSTERER *Clusterer = NULL;
LIST ProtoList = NIL;
LIST NormProtoList = NIL;
LIST pCharList;
LABELEDLIST CharSample;
ParseArguments (argc, argv);
while ((PageName = GetNextFilename()) != NULL)
{
printf ("Reading %s ...\n", PageName);
TrainingPage = Efopen (PageName, "r");
ReadTrainingSamples (TrainingPage, &CharList);
fclose (TrainingPage);
//WriteTrainingSamples (Directory, CharList);
}
printf("Clustering ...\n");
pCharList = CharList;
iterate(pCharList)
{
//Cluster
CharSample = (LABELEDLIST) first_node (pCharList);
//printf ("\nClustering %s ...", CharSample->Label);
Clusterer = SetUpForClustering(CharSample);
float SavedMinSamples = Config.MinSamples;
Config.MagicSamples = CharSample->SampleCount;
while (Config.MinSamples > 0.001) {
ProtoList = ClusterSamples(Clusterer, &Config);
if (NumberOfProtos(ProtoList, 1, 0) > 0)
break;
else {
Config.MinSamples *= 0.95;
printf("0 significant protos for %s."
" Retrying clustering with MinSamples = %f%%\n",
CharSample->Label, Config.MinSamples);
}
}
Config.MinSamples = SavedMinSamples;
AddToNormProtosList(&NormProtoList, ProtoList, CharSample->Label);
}
FreeTrainingSamples (CharList);
WriteNormProtos (Directory, NormProtoList, Clusterer);
FreeClusterer(Clusterer);
FreeProtoList(&ProtoList);
FreeNormProtoList(NormProtoList);
printf ("\n");
return 0;
} // main
/**----------------------------------------------------------------------------
Private Code
----------------------------------------------------------------------------**/
/*---------------------------------------------------------------------------*/
void ParseArguments(
int argc,
char **argv)
/*
** Parameters:
** argc number of command line arguments to parse
** argv command line arguments
** Globals:
** ShowAllSamples flag controlling samples display
** ShowSignificantProtos flag controlling proto display
** ShowInsignificantProtos flag controlling proto display
** Config current clustering parameters
** tessoptarg, tessoptind defined by tessopt sys call
** Argc, Argv global copies of argc and argv
** Operation:
** This routine parses the command line arguments that were
** passed to the program. The legal arguments are:
** -d "turn off display of samples"
** -p "turn off significant protos"
** -n "turn off insignificant proto"
** -S [ spherical | elliptical | mixed | automatic ]
** -M MinSamples "min samples per prototype (%)"
** -B MaxIllegal "max illegal chars per cluster (%)"
** -I Independence "0 to 1"
** -C Confidence "1e-200 to 1.0"
** -D Directory
** -N MaxNumSamples
** -R RoundingAccuracy
** Return: none
** Exceptions: Illegal options terminate the program.
** History: 7/24/89, DSJ, Created.
*/
{
int Option;
int ParametersRead;
BOOL8 Error;
Error = FALSE;
Argc = argc;
Argv = argv;
while (( Option = tessopt( argc, argv, "R:N:D:C:I:M:B:S:d:n:p" )) != EOF )
{
switch ( Option )
{
case 'n':
sscanf(tessoptarg,"%d", &ParametersRead);
ShowInsignificantProtos = ParametersRead;
break;
case 'p':
sscanf(tessoptarg,"%d", &ParametersRead);
ShowSignificantProtos = ParametersRead;
break;
case 'd':
ShowAllSamples = FALSE;
break;
case 'C':
ParametersRead = sscanf( tessoptarg, "%lf", &(Config.Confidence) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.Confidence > 1 ) Config.Confidence = 1;
else if ( Config.Confidence < 0 ) Config.Confidence = 0;
break;
case 'I':
ParametersRead = sscanf( tessoptarg, "%f", &(Config.Independence) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.Independence > 1 ) Config.Independence = 1;
else if ( Config.Independence < 0 ) Config.Independence = 0;
break;
case 'M':
ParametersRead = sscanf( tessoptarg, "%f", &(Config.MinSamples) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.MinSamples > 1 ) Config.MinSamples = 1;
else if ( Config.MinSamples < 0 ) Config.MinSamples = 0;
break;
case 'B':
ParametersRead = sscanf( tessoptarg, "%f", &(Config.MaxIllegal) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.MaxIllegal > 1 ) Config.MaxIllegal = 1;
else if ( Config.MaxIllegal < 0 ) Config.MaxIllegal = 0;
break;
case 'R':
ParametersRead = sscanf( tessoptarg, "%f", &RoundingAccuracy );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( RoundingAccuracy > 0.01 ) RoundingAccuracy = 0.01;
else if ( RoundingAccuracy < 0.0 ) RoundingAccuracy = 0.0;
break;
case 'S':
switch ( tessoptarg[0] )
{
case 's': Config.ProtoStyle = spherical; break;
case 'e': Config.ProtoStyle = elliptical; break;
case 'm': Config.ProtoStyle = mixed; break;
case 'a': Config.ProtoStyle = automatic; break;
default: Error = TRUE;
}
break;
case 'D':
Directory = tessoptarg;
break;
case 'N':
if (sscanf (tessoptarg, "%d", &MaxNumSamples) != 1 ||
MaxNumSamples <= 0)
Error = TRUE;
break;
case '?':
Error = TRUE;
break;
}
if ( Error )
{
fprintf (stderr, "usage: %s [-D] [-P] [-N]\n", argv[0] );
fprintf (stderr, "\t[-S ProtoStyle]\n");
fprintf (stderr, "\t[-M MinSamples] [-B MaxBad] [-I Independence] [-C Confidence]\n" );
fprintf (stderr, "\t[-d directory] [-n MaxNumSamples] [ TrainingPage ... ]\n");
exit (2);
}
}
} /* ParseArguments */
/*---------------------------------------------------------------------------*/
char *GetNextFilename ()
/*
** Parameters: none
** Globals:
** tessoptind defined by tessopt sys call
** Argc, Argv global copies of argc and argv
** Operation:
** This routine returns the next command line argument. If
** there are no remaining command line arguments, it returns
** NULL. This routine should only be called after all option
** arguments have been parsed and removed with ParseArguments.
** Return: Next command line argument or NULL.
** Exceptions: none
** History: Fri Aug 18 09:34:12 1989, DSJ, Created.
*/
{
if (tessoptind < Argc)
return (Argv [tessoptind++]);
else
return (NULL);
} /* GetNextFilename */
/*---------------------------------------------------------------------------*/
void ReadTrainingSamples (
FILE *File,
LIST* TrainingSamples)
/*
** Parameters:
** File open text file to read samples from
** Globals: none
** Operation:
** This routine reads training samples from a file and
** places them into a data structure which organizes the
** samples by FontName and CharName. It then returns this
** data structure.
** Return: none
** Exceptions: none
** History: Fri Aug 18 13:11:39 1989, DSJ, Created.
** Tue May 17 1998 simplifications to structure, illiminated
** font, and feature specification levels of structure.
*/
{
char unichar[UNICHAR_LEN + 1];
LABELEDLIST CharSample;
FEATURE_SET FeatureSamples;
CHAR_DESC CharDesc;
int Type, i;
while (fscanf (File, "%s %s", FontName, unichar) == 2) {
CharSample = FindList (*TrainingSamples, unichar);
if (CharSample == NULL) {
CharSample = NewLabeledList (unichar);
*TrainingSamples = push (*TrainingSamples, CharSample);
}
CharDesc = ReadCharDescription (File);
Type = ShortNameToFeatureType(PROGRAM_FEATURE_TYPE);
FeatureSamples = CharDesc->FeatureSets[Type];
for (int feature = 0; feature < FeatureSamples->NumFeatures; ++feature) {
FEATURE f = FeatureSamples->Features[feature];
for (int dim =0; dim < f->Type->NumParams; ++dim)
f->Params[dim] += UniformRandomNumber(-MINSD, MINSD);
}
CharSample->List = push (CharSample->List, FeatureSamples);
CharSample->SampleCount++;
for (i = 0; i < CharDesc->NumFeatureSets; i++)
if (Type != i)
FreeFeatureSet(CharDesc->FeatureSets[i]);
free (CharDesc);
}
} // ReadTrainingSamples
/*---------------------------------------------------------------------------*/
LABELEDLIST FindList (
LIST List,
char *Label)
/*
** Parameters:
** List list to search
** Label label to search for
** Globals: none
** Operation:
** This routine searches thru a list of labeled lists to find
** a list with the specified label. If a matching labeled list
** cannot be found, NULL is returned.
** Return: Labeled list with the specified Label or NULL.
** Exceptions: none
** History: Fri Aug 18 15:57:41 1989, DSJ, Created.
*/
{
LABELEDLIST LabeledList;
iterate (List)
{
LabeledList = (LABELEDLIST) first_node (List);
if (strcmp (LabeledList->Label, Label) == 0)
return (LabeledList);
}
return (NULL);
} /* FindList */
/*---------------------------------------------------------------------------*/
LABELEDLIST NewLabeledList (
char *Label)
/*
** Parameters:
** Label label for new list
** Globals: none
** Operation:
** This routine allocates a new, empty labeled list and gives
** it the specified label.
** Return: New, empty labeled list.
** Exceptions: none
** History: Fri Aug 18 16:08:46 1989, DSJ, Created.
*/
{
LABELEDLIST LabeledList;
LabeledList = (LABELEDLIST) (char*)Emalloc (sizeof (LABELEDLISTNODE));
LabeledList->Label = (char*)Emalloc (strlen (Label)+1);
strcpy (LabeledList->Label, Label);
LabeledList->List = NIL;
LabeledList->SampleCount = 0;
return (LabeledList);
} /* NewLabeledList */
/*---------------------------------------------------------------------------*/
void WriteTrainingSamples (
char *Directory,
LIST CharList)
/*
** Parameters:
** Directory directory to place sample files into
** FontList list of fonts used in the training samples
** Globals:
** MaxNumSamples max number of samples per class to write
** Operation:
** This routine writes the specified samples into files which
** are organized according to the font name and character name
** of the samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 16:17:06 1989, DSJ, Created.
*/
{
LABELEDLIST CharSample;
FEATURE_SET FeatureSet;
LIST FeatureList;
FILE *File;
char Filename[MAXNAMESIZE];
int NumSamples;
iterate (CharList) // iterate thru all of the fonts
{
CharSample = (LABELEDLIST) first_node (CharList);
// construct the full pathname for the current samples file
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "Merged");
strcat (Filename, "/");
strcat (Filename, CharSample->Label);
strcat (Filename, ".");
strcat (Filename, PROGRAM_FEATURE_TYPE);
printf ("\nWriting %s ...", Filename);
/* if file does not exist, create a new one with an appropriate
header; otherwise append samples to the existing file */
File = fopen (Filename, "r");
if (File == NULL)
{
File = Efopen (Filename, "w");
WriteOldParamDesc
(File, FeatureDefs.FeatureDesc[ShortNameToFeatureType (PROGRAM_FEATURE_TYPE)]);
}
else
{
fclose (File);
File = Efopen (Filename, "a");
}
// append samples onto the file
FeatureList = CharSample->List;
NumSamples = 0;
iterate (FeatureList)
{
//if (NumSamples >= MaxNumSamples) break;
FeatureSet = (FEATURE_SET) first_node (FeatureList);
WriteFeatureSet (File, FeatureSet);
NumSamples++;
}
fclose (File);
}
} /* WriteTrainingSamples */
/*----------------------------------------------------------------------------*/
void WriteNormProtos (
char *Directory,
LIST LabeledProtoList,
CLUSTERER *Clusterer)
/*
** Parameters:
** Directory directory to place sample files into
** Globals:
** MaxNumSamples max number of samples per class to write
** Operation:
** This routine writes the specified samples into files which
** are organized according to the font name and character name
** of the samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 16:17:06 1989, DSJ, Created.
*/
{
FILE *File;
char Filename[MAXNAMESIZE];
LABELEDLIST LabeledProto;
int N;
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "normproto");
printf ("\nWriting %s ...", Filename);
File = Efopen (Filename, "w");
fprintf(File,"%0d\n",Clusterer->SampleSize);
WriteParamDesc(File,Clusterer->SampleSize,Clusterer->ParamDesc);
iterate(LabeledProtoList)
{
LabeledProto = (LABELEDLIST) first_node (LabeledProtoList);
N = NumberOfProtos(LabeledProto->List,
ShowSignificantProtos, ShowInsignificantProtos);
if (N < 1) {
printf ("\nError! Not enough protos for %s: %d protos"
" (%d significant protos"
", %d insignificant protos)\n",
LabeledProto->Label, N,
NumberOfProtos(LabeledProto->List, 1, 0),
NumberOfProtos(LabeledProto->List, 0, 1));
exit(1);
}
fprintf(File, "\n%s %d\n", LabeledProto->Label, N);
WriteProtos(File, Clusterer->SampleSize, LabeledProto->List,
ShowSignificantProtos, ShowInsignificantProtos);
}
fclose (File);
} // WriteNormProtos
/*---------------------------------------------------------------------------*/
void FreeTrainingSamples (
LIST CharList)
/*
** Parameters:
** FontList list of all fonts in document
** Globals: none
** Operation:
** This routine deallocates all of the space allocated to
** the specified list of training samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 17:44:27 1989, DSJ, Created.
*/
{
LABELEDLIST CharSample;
FEATURE_SET FeatureSet;
LIST FeatureList;
printf ("\nFreeTrainingSamples...");
iterate (CharList) /* iterate thru all of the fonts */
{
CharSample = (LABELEDLIST) first_node (CharList);
FeatureList = CharSample->List;
iterate (FeatureList) /* iterate thru all of the classes */
{
FeatureSet = (FEATURE_SET) first_node (FeatureList);
FreeFeatureSet (FeatureSet);
}
FreeLabeledList (CharSample);
}
destroy (CharList);
} /* FreeTrainingSamples */
/*-------------------------------------------------------------------------*/
void FreeNormProtoList (
LIST CharList)
{
LABELEDLIST CharSample;
iterate (CharList) /* iterate thru all of the fonts */
{
CharSample = (LABELEDLIST) first_node (CharList);
FreeLabeledList (CharSample);
}
destroy (CharList);
} // FreeNormProtoList
/*---------------------------------------------------------------------------*/
void FreeLabeledList (
LABELEDLIST LabeledList)
/*
** Parameters:
** LabeledList labeled list to be freed
** Globals: none
** Operation:
** This routine deallocates all of the memory consumed by
** a labeled list. It does not free any memory which may be
** consumed by the items in the list.
** Return: none
** Exceptions: none
** History: Fri Aug 18 17:52:45 1989, DSJ, Created.
*/
{
destroy (LabeledList->List);
free (LabeledList->Label);
free (LabeledList);
} /* FreeLabeledList */
/*---------------------------------------------------------------------------*/
CLUSTERER *SetUpForClustering(
LABELEDLIST CharSample)
/*
** Parameters:
** CharSample: LABELEDLIST that holds all the feature information for a
** given character.
** Globals:
** None
** Operation:
** This routine reads samples from a LABELEDLIST and enters
** those samples into a clusterer data structure. This
** data structure is then returned to the caller.
** Return:
** Pointer to new clusterer data structure.
** Exceptions:
** None
** History:
** 8/16/89, DSJ, Created.
*/
{
uinT16 N;
int i, j;
FLOAT32 *Sample = NULL;
CLUSTERER *Clusterer;
inT32 CharID;
LIST FeatureList = NULL;
FEATURE_SET FeatureSet = NULL;
FEATURE_DESC FeatureDesc = NULL;
// PARAM_DESC* ParamDesc;
FeatureDesc = FeatureDefs.FeatureDesc[ShortNameToFeatureType(PROGRAM_FEATURE_TYPE)];
N = FeatureDesc->NumParams;
//ParamDesc = ConvertToPARAMDESC(FeatureDesc->ParamDesc, N);
Clusterer = MakeClusterer(N,FeatureDesc->ParamDesc);
// free(ParamDesc);
FeatureList = CharSample->List;
CharID = 0;
iterate(FeatureList)
{
FeatureSet = (FEATURE_SET) first_node (FeatureList);
for (i=0; i < FeatureSet->MaxNumFeatures; i++)
{
if (Sample == NULL)
Sample = (FLOAT32 *)Emalloc(N * sizeof(FLOAT32));
for (j=0; j < N; j++)
if (RoundingAccuracy != 0.0)
Sample[j] = round(FeatureSet->Features[i]->Params[j], RoundingAccuracy);
else
Sample[j] = FeatureSet->Features[i]->Params[j];
MakeSample (Clusterer, Sample, CharID);
}
CharID++;
}
if ( Sample != NULL ) free( Sample );
return( Clusterer );
} /* SetUpForClustering */
/*---------------------------------------------------------------------------*/
void AddToNormProtosList(
LIST* NormProtoList,
LIST ProtoList,
char* CharName)
{
PROTOTYPE* Proto;
LABELEDLIST LabeledProtoList;
LabeledProtoList = NewLabeledList(CharName);
iterate(ProtoList)
{
Proto = (PROTOTYPE *) first_node (ProtoList);
LabeledProtoList->List = push(LabeledProtoList->List, Proto);
}
*NormProtoList = push(*NormProtoList, LabeledProtoList);
}
/*-------------------------------------------------------------------------*/
void WriteProtos(
FILE *File,
uinT16 N,
LIST ProtoList,
BOOL8 WriteSigProtos,
BOOL8 WriteInsigProtos)
{
PROTOTYPE *Proto;
// write prototypes
iterate(ProtoList)
{
Proto = (PROTOTYPE *) first_node ( ProtoList );
if (( Proto->Significant && WriteSigProtos ) ||
( ! Proto->Significant && WriteInsigProtos ) )
WritePrototype( File, N, Proto );
}
} // WriteProtos
/*---------------------------------------------------------------------------*/
int NumberOfProtos(
LIST ProtoList,
BOOL8 CountSigProtos,
BOOL8 CountInsigProtos)
{
int N = 0;
PROTOTYPE *Proto;
iterate(ProtoList)
{
Proto = (PROTOTYPE *) first_node ( ProtoList );
if (( Proto->Significant && CountSigProtos ) ||
( ! Proto->Significant && CountInsigProtos ) )
N++;
}
return(N);
}

View File

@ -1,986 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="cnTraining"
ProjectGUID="{1AC769A4-E98E-48B9-B87B-90D7837031FA}"
Keyword="MFCProj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\."
IntermediateDirectory=".\cntrain.Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\./cnTraining.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict"
PreprocessorDefinitions="TRAINING;WIN32;_WINDOWS;__NT__;__MSW32__"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\cntrain.Release/cnTraining.pch"
AssemblerListingLocation=".\cntrain.Release/"
ObjectFile=".\cntrain.Release/"
ProgramDataBaseFileName=".\cntrain.Release/"
BrowseInformation="2"
BrowseInformationFile=".\cntrain.Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib user32.lib"
OutputFile="cnTraining.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="false"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\./cnTraining.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../bin.dbg"
IntermediateDirectory=".\cntrain.Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../bin.dbg/cnTraining.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict"
PreprocessorDefinitions="_DEBUG;TRAINING;WIN32;_WINDOWS;__NT__;__MSW32__"
MinimalRebuild="true"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\cntrain.Debug/cnTraining.pch"
AssemblerListingLocation=".\cntrain.Debug/"
ObjectFile=".\cntrain.Debug/"
ProgramDataBaseFileName=".\cntrain.Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib user32.lib"
OutputFile=".\../bin.dbg/cnTraining.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../bin.dbg/cnTraining.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../bin.dbg/cnTraining.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\ccutil\clst.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\cluster.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\clusttool.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="cnTraining.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\cutil.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\danerror.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\debug.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\debugwin.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\efio.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\emalloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\errcode.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\featdefs.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\freelist.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\globaloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\globals.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\hashfn.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\kdtree.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\listio.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memblk.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memry.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\mfcpch.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="name2char.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\ocrfeatures.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldheap.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldlist.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\scrollview.cpp"
>
</File>
<File
RelativePath="..\viewer\scrollview.h"
>
</File>
<File
RelativePath="..\ccutil\serialis.cpp"
>
</File>
<File
RelativePath="..\ccutil\strngs.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\structures.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\svmnode.cpp"
>
</File>
<File
RelativePath="..\viewer\svmnode.h"
>
</File>
<File
RelativePath="..\viewer\svutil.cpp"
>
</File>
<File
RelativePath="..\viewer\svutil.h"
>
</File>
<File
RelativePath="..\ccutil\tessopt.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tprintf.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="training.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unichar.cpp"
>
</File>
<File
RelativePath="..\ccutil\unicharmap.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharset.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\varable.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\variables.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

334
training/cntraining.cpp Normal file
View File

@ -0,0 +1,334 @@
/******************************************************************************
** Filename: cntraining.cpp
** Purpose: Generates a normproto and pffmtable.
** Author: Dan Johnson
** Revisment: Christy Russon
** History: Fri Aug 18 08:53:50 1989, DSJ, Created.
** 5/25/90, DSJ, Adapted to multiple feature types.
** Tuesday, May 17, 1998 Changes made to make feature specific and
** simplify structures. First step in simplifying training process.
**
** (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.
******************************************************************************/
/**----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "oldlist.h"
#include "efio.h"
#include "emalloc.h"
#include "featdefs.h"
#include "tessopt.h"
#include "ocrfeatures.h"
#include "general.h"
#include "clusttool.h"
#include "cluster.h"
#include "name2char.h"
#include <string.h>
#include <stdio.h>
#include <math.h>
#include "unichar.h"
#include "commontraining.h"
#define PROGRAM_FEATURE_TYPE "cn"
#define MINSD (1.0f / 64.0f)
int row_number; /* cjn: fixes link problem */
/**----------------------------------------------------------------------------
Public Function Prototypes
----------------------------------------------------------------------------**/
int main (
int argc,
char **argv);
/**----------------------------------------------------------------------------
Private Function Prototypes
----------------------------------------------------------------------------**/
void ReadTrainingSamples (
FILE *File,
LIST* TrainingSamples);
void WriteNormProtos (
char *Directory,
LIST LabeledProtoList,
CLUSTERER *Clusterer);
/*
PARAMDESC *ConvertToPARAMDESC(
PARAM_DESC* Param_Desc,
int N);
*/
void WriteProtos(
FILE *File,
uinT16 N,
LIST ProtoList,
BOOL8 WriteSigProtos,
BOOL8 WriteInsigProtos);
/**----------------------------------------------------------------------------
Global Data Definitions and Declarations
----------------------------------------------------------------------------**/
/* global variable to hold configuration parameters to control clustering */
//-M 0.025 -B 0.05 -I 0.8 -C 1e-3
CLUSTERCONFIG Config =
{
elliptical, 0.025, 0.05, 0.8, 1e-3, 0
};
/**----------------------------------------------------------------------------
Public Code
----------------------------------------------------------------------------**/
/*---------------------------------------------------------------------------*/
int main (
int argc,
char **argv)
/*
** Parameters:
** argc number of command line arguments
** argv array of command line arguments
** Globals: none
** Operation:
** This program reads in a text file consisting of feature
** samples from a training page in the following format:
**
** FontName CharName NumberOfFeatureTypes(N)
** FeatureTypeName1 NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** FeatureTypeName2 NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** ...
** FeatureTypeNameN NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** FontName CharName ...
**
** It then appends these samples into a separate file for each
** character. The name of the file is
**
** DirectoryName/FontName/CharName.FeatureTypeName
**
** The DirectoryName can be specified via a command
** line argument. If not specified, it defaults to the
** current directory. The format of the resulting files is:
**
** NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** NumberOfFeatures(M)
** ...
**
** The output files each have a header which describes the
** type of feature which the file contains. This header is
** in the format required by the clusterer. A command line
** argument can also be used to specify that only the first
** N samples of each class should be used.
** Return: none
** Exceptions: none
** History: Fri Aug 18 08:56:17 1989, DSJ, Created.
*/
{
char *PageName;
FILE *TrainingPage;
LIST CharList = NIL;
CLUSTERER *Clusterer = NULL;
LIST ProtoList = NIL;
LIST NormProtoList = NIL;
LIST pCharList;
LABELEDLIST CharSample;
ParseArguments (argc, argv);
while ((PageName = GetNextFilename(argc, argv)) != NULL)
{
printf ("Reading %s ...\n", PageName);
TrainingPage = Efopen (PageName, "r");
ReadTrainingSamples (TrainingPage, &CharList);
fclose (TrainingPage);
//WriteTrainingSamples (Directory, CharList);
}
printf("Clustering ...\n");
pCharList = CharList;
iterate(pCharList)
{
//Cluster
CharSample = (LABELEDLIST) first_node (pCharList);
//printf ("\nClustering %s ...", CharSample->Label);
Clusterer = SetUpForClustering(CharSample, PROGRAM_FEATURE_TYPE);
float SavedMinSamples = Config.MinSamples;
Config.MagicSamples = CharSample->SampleCount;
while (Config.MinSamples > 0.001) {
ProtoList = ClusterSamples(Clusterer, &Config);
if (NumberOfProtos(ProtoList, 1, 0) > 0)
break;
else {
Config.MinSamples *= 0.95;
printf("0 significant protos for %s."
" Retrying clustering with MinSamples = %f%%\n",
CharSample->Label, Config.MinSamples);
}
}
Config.MinSamples = SavedMinSamples;
AddToNormProtosList(&NormProtoList, ProtoList, CharSample->Label);
}
FreeTrainingSamples (CharList);
if (Clusterer == NULL) // To avoid a SIGSEGV
return 1;
WriteNormProtos (Directory, NormProtoList, Clusterer);
FreeClusterer(Clusterer);
FreeProtoList(&ProtoList);
FreeNormProtoList(NormProtoList);
printf ("\n");
return 0;
} // main
/**----------------------------------------------------------------------------
Private Code
----------------------------------------------------------------------------**/
/*---------------------------------------------------------------------------*/
void ReadTrainingSamples (
FILE *File,
LIST* TrainingSamples)
/*
** Parameters:
** File open text file to read samples from
** Globals: none
** Operation:
** This routine reads training samples from a file and
** places them into a data structure which organizes the
** samples by FontName and CharName. It then returns this
** data structure.
** Return: none
** Exceptions: none
** History: Fri Aug 18 13:11:39 1989, DSJ, Created.
** Tue May 17 1998 simplifications to structure, illiminated
** font, and feature specification levels of structure.
*/
{
char unichar[UNICHAR_LEN + 1];
LABELEDLIST CharSample;
FEATURE_SET FeatureSamples;
CHAR_DESC CharDesc;
int Type, i;
while (fscanf (File, "%s %s", CTFontName, unichar) == 2) {
CharSample = FindList (*TrainingSamples, unichar);
if (CharSample == NULL) {
CharSample = NewLabeledList (unichar);
*TrainingSamples = push (*TrainingSamples, CharSample);
}
CharDesc = ReadCharDescription (File);
Type = ShortNameToFeatureType(PROGRAM_FEATURE_TYPE);
FeatureSamples = CharDesc->FeatureSets[Type];
for (int feature = 0; feature < FeatureSamples->NumFeatures; ++feature) {
FEATURE f = FeatureSamples->Features[feature];
for (int dim =0; dim < f->Type->NumParams; ++dim)
f->Params[dim] += UniformRandomNumber(-MINSD, MINSD);
}
CharSample->List = push (CharSample->List, FeatureSamples);
CharSample->SampleCount++;
for (i = 0; i < CharDesc->NumFeatureSets; i++)
if (Type != i)
FreeFeatureSet(CharDesc->FeatureSets[i]);
free (CharDesc);
}
} // ReadTrainingSamples
/*----------------------------------------------------------------------------*/
void WriteNormProtos (
char *Directory,
LIST LabeledProtoList,
CLUSTERER *Clusterer)
/*
** Parameters:
** Directory directory to place sample files into
** Operation:
** This routine writes the specified samples into files which
** are organized according to the font name and character name
** of the samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 16:17:06 1989, DSJ, Created.
*/
{
FILE *File;
char Filename[MAXNAMESIZE];
LABELEDLIST LabeledProto;
int N;
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "normproto");
printf ("\nWriting %s ...", Filename);
File = Efopen (Filename, "w");
fprintf(File,"%0d\n",Clusterer->SampleSize);
WriteParamDesc(File,Clusterer->SampleSize,Clusterer->ParamDesc);
iterate(LabeledProtoList)
{
LabeledProto = (LABELEDLIST) first_node (LabeledProtoList);
N = NumberOfProtos(LabeledProto->List,
ShowSignificantProtos, ShowInsignificantProtos);
if (N < 1) {
printf ("\nError! Not enough protos for %s: %d protos"
" (%d significant protos"
", %d insignificant protos)\n",
LabeledProto->Label, N,
NumberOfProtos(LabeledProto->List, 1, 0),
NumberOfProtos(LabeledProto->List, 0, 1));
exit(1);
}
fprintf(File, "\n%s %d\n", LabeledProto->Label, N);
WriteProtos(File, Clusterer->SampleSize, LabeledProto->List,
ShowSignificantProtos, ShowInsignificantProtos);
}
fclose (File);
} // WriteNormProtos
/*-------------------------------------------------------------------------*/
void WriteProtos(
FILE *File,
uinT16 N,
LIST ProtoList,
BOOL8 WriteSigProtos,
BOOL8 WriteInsigProtos)
{
PROTOTYPE *Proto;
// write prototypes
iterate(ProtoList)
{
Proto = (PROTOTYPE *) first_node ( ProtoList );
if (( Proto->Significant && WriteSigProtos ) ||
( ! Proto->Significant && WriteInsigProtos ) )
WritePrototype( File, N, Proto );
}
} // WriteProtos

View File

@ -1,243 +0,0 @@
# Microsoft Developer Studio Project File - Name="cnTraining" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=cnTraining - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "cnTraining.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "cnTraining.mak" CFG="cnTraining - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "cnTraining - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "cnTraining - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "cnTraining - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "cntrain.Release6"
# PROP Intermediate_Dir "cntrain.Release6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../ccutil" /I "../ccstruct" /I "../classify" /I "../cutil" /I "../training" /I "../viewer" /I "../dict" /D "TRAINING" /D "WIN32" /D "_CONSOLE" /D "__NT__" /D "__MSW32__" /D "_AFXDLL" /Fr /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ws2_32.lib /nologo /subsystem:console /profile /debug /machine:I386 /out:"./cnTraining.exe"
!ELSEIF "$(CFG)" == "cnTraining - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "cntrain.Debug6"
# PROP Intermediate_Dir "cntrain.Debug6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../ccutil" /I "../ccstruct" /I "../classify" /I "../cutil" /I "../training" /I "../viewer" /I "../dict" /D "_DEBUG" /D "TRAINING" /D "WIN32" /D "_CONSOLE" /D "__NT__" /D "__MSW32__" /D "_AFXDLL" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin.dbg6/cnTraining.exe" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "cnTraining - Win32 Release"
# Name "cnTraining - Win32 Debug"
# Begin Source File
SOURCE=..\ccutil\clst.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\cluster.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\clusttool.cpp
# End Source File
# Begin Source File
SOURCE=.\cnTraining.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\cutil.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\danerror.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\debug.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\debugwin.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\efio.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\emalloc.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\errcode.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\featdefs.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\freelist.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\globaloc.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\globals.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\hashfn.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\kdtree.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\listio.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\memblk.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\memry.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\mfcpch.cpp
# End Source File
# Begin Source File
SOURCE=..\training\name2char.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\ocrfeatures.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\oldheap.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\oldlist.cpp
# End Source File
# Begin Source File
SOURCE=..\viewer\scrollview.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\serialis.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\strngs.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\structures.cpp
# End Source File
# Begin Source File
SOURCE=..\viewer\svmnode.cpp
# End Source File
# Begin Source File
SOURCE=..\viewer\svutil.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\tessopt.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\tprintf.cpp
# End Source File
# Begin Source File
SOURCE=..\training\training.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\unichar.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharmap.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharset.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\varable.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\variables.cpp
# End Source File
# End Target
# End Project

View File

@ -4,6 +4,7 @@
Version="9.00"
Name="cntraining"
ProjectGUID="{1AC769A4-E98E-48B9-B87B-90D7837031FA}"
RootNamespace="cntraining"
Keyword="MFCProj"
TargetFrameworkVersion="131072"
>
@ -17,12 +18,13 @@
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\."
OutputDirectory=".."
IntermediateDirectory=".\cntrain.Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@ -48,7 +50,7 @@
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict"
PreprocessorDefinitions="TRAINING;WIN32;_WINDOWS;__NT__;__MSW32__;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="2"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\cntrain.Release/cntraining.pch"
AssemblerListingLocation=".\cntrain.Release/"
@ -72,8 +74,8 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib user32.lib"
OutputFile="cntraining.exe"
AdditionalDependencies="ws2_32.lib user32.lib ..\lib\leptonlib.lib"
OutputFile="..\cntraining.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="false"
@ -138,7 +140,7 @@
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict"
PreprocessorDefinitions="_DEBUG;TRAINING;WIN32;_WINDOWS;__NT__;__MSW32__;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
RuntimeLibrary="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\cntrain.Debug/cntraining.pch"
AssemblerListingLocation=".\cntrain.Debug/"
ObjectFile=".\cntrain.Debug/"
@ -161,7 +163,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib user32.lib"
AdditionalDependencies="ws2_32.lib user32.lib ..\lib\leptonlib.lib"
OutputFile=".\../bin.dbg/cntraining.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
@ -200,72 +202,6 @@
<References>
</References>
<Files>
<File
RelativePath="..\ccutil\clst.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\cluster.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\clusttool.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="cntraining.cpp"
>
@ -289,360 +225,8 @@
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\cutil.cpp"
RelativePath=".\commontraining.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\danerror.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\debug.cpp"
>
</File>
<File
RelativePath="..\ccutil\debugwin.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\efio.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\emalloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\errcode.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\featdefs.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\freelist.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\globaloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\globals.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\hashfn.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\kdtree.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\listio.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memblk.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memry.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\mfcpch.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="name2char.cpp"
@ -666,284 +250,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\ocrfeatures.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldheap.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldlist.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\scrollview.cpp"
>
</File>
<File
RelativePath="..\viewer\scrollview.h"
>
</File>
<File
RelativePath="..\ccutil\serialis.cpp"
>
</File>
<File
RelativePath="..\ccutil\strngs.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\structures.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\svmnode.cpp"
>
</File>
<File
RelativePath="..\viewer\svmnode.h"
>
</File>
<File
RelativePath="..\viewer\svutil.cpp"
>
</File>
<File
RelativePath="..\viewer\svutil.h"
>
</File>
<File
RelativePath="..\ccutil\tessopt.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tprintf.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="training.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unichar.cpp"
>
</File>
<File
RelativePath="..\ccutil\unicharmap.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharset.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\varable.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\variables.cpp"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -0,0 +1,31 @@
///////////////////////////////////////////////////////////////////////
// File: combine_tessdata
// Description: Creates a unified traineddata file from several
// data files produced by the training process.
// Author: Daria Antonova
// Created: Wed Jun 03 11:26:43 PST 2009
//
// (C) Copyright 2009, Google Inc.
// 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.
//
///////////////////////////////////////////////////////////////////////
#include "tessdatamanager.h"
int main(int argc, char **argv) {
if (!(argc == 2)) {
printf("Usage: %s language_data_path_prefix (e.g. tessdata/eng.)", argv[0]);
return 1;
}
STRING output_file = argv[1];
output_file += kTrainedDataSuffix;
tesseract::TessdataManager::CombineDataFiles(argv[1], output_file.string());
}

815
training/commontraining.cpp Normal file
View File

@ -0,0 +1,815 @@
// Copyright 2008 Google Inc. All Rights Reserved.
// Author: scharron@google.com (Samuel Charron)
//
// 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.
#include "commontraining.h"
#include "oldlist.h"
#include "globals.h"
#include "mf.h"
#include "clusttool.h"
#include "cluster.h"
#include "mergenf.h"
#include "tessopt.h"
#include "featdefs.h"
#include "efio.h"
#include "emalloc.h"
#include "tprintf.h"
#include "freelist.h"
#include "unicity_table.h"
#include <math.h>
#define round(x,frag)(floor(x/frag+.5)*frag)
// Global Variables.
char *Directory = NULL;
const char *InputUnicharsetFile = NULL;
const char *OutputUnicharsetFile = NULL;
const char *InputFontInfoFile = NULL;
// globals used to control what information is saved in the output file
BOOL8 ShowSignificantProtos = TRUE;
BOOL8 ShowInsignificantProtos = FALSE;
FLOAT32 RoundingAccuracy = 0.0f;
char CTFontName[MAXNAMESIZE];
const char* test_ch = "";
// The unicharset used during training
UNICHARSET unicharset_training;
/*---------------------------------------------------------------------------*/
void ParseArguments(int argc, char **argv)
/*
** Parameters:
** argc number of command line arguments to parse
** argv command line arguments
** Globals:
** ShowSignificantProtos flag controlling proto display
** ShowInsignificantProtos flag controlling proto display
** Config current clustering parameters
** tessoptarg, tessoptind defined by tessopt sys call
** Argc, Argv global copies of argc and argv
** Operation:
** This routine parses the command line arguments that were
** passed to the program. The legal arguments are:
** -d "turn off display of samples"
** -p "turn off significant protos"
** -n "turn off insignificant proto"
** -S [ spherical | elliptical | mixed | automatic ]
** -M MinSamples "min samples per prototype (%)"
** -B MaxIllegal "max illegal chars per cluster (%)"
** -I Independence "0 to 1"
** -C Confidence "1e-200 to 1.0"
** -D Directory
** -R RoundingAccuracy
** -U InputUnicharsetFile
** -O OutputUnicharsetFile
** Return: none
** Exceptions: Illegal options terminate the program.
** History: 7/24/89, DSJ, Created.
*/
{
int Option;
int ParametersRead;
BOOL8 Error;
Error = FALSE;
while (( Option = tessopt( argc, argv, "F:O:U:R:D:C:I:M:B:S:n:p" )) != EOF )
{
switch ( Option )
{
case 'n':
sscanf(tessoptarg,"%d", &ParametersRead);
ShowInsignificantProtos = ParametersRead;
break;
case 'p':
sscanf(tessoptarg,"%d", &ParametersRead);
ShowSignificantProtos = ParametersRead;
break;
case 'C':
ParametersRead = sscanf( tessoptarg, "%lf", &(Config.Confidence) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.Confidence > 1 ) Config.Confidence = 1;
else if ( Config.Confidence < 0 ) Config.Confidence = 0;
break;
case 'I':
ParametersRead = sscanf( tessoptarg, "%f", &(Config.Independence) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.Independence > 1 ) Config.Independence = 1;
else if ( Config.Independence < 0 ) Config.Independence = 0;
break;
case 'M':
ParametersRead = sscanf( tessoptarg, "%f", &(Config.MinSamples) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.MinSamples > 1 ) Config.MinSamples = 1;
else if ( Config.MinSamples < 0 ) Config.MinSamples = 0;
break;
case 'B':
ParametersRead = sscanf( tessoptarg, "%f", &(Config.MaxIllegal) );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( Config.MaxIllegal > 1 ) Config.MaxIllegal = 1;
else if ( Config.MaxIllegal < 0 ) Config.MaxIllegal = 0;
break;
case 'R':
ParametersRead = sscanf( tessoptarg, "%f", &RoundingAccuracy );
if ( ParametersRead != 1 ) Error = TRUE;
else if ( RoundingAccuracy > 0.01f ) RoundingAccuracy = 0.01f;
else if ( RoundingAccuracy < 0.0f ) RoundingAccuracy = 0.0f;
break;
case 'S':
switch ( tessoptarg[0] )
{
case 's': Config.ProtoStyle = spherical; break;
case 'e': Config.ProtoStyle = elliptical; break;
case 'm': Config.ProtoStyle = mixed; break;
case 'a': Config.ProtoStyle = automatic; break;
default: Error = TRUE;
}
break;
case 'D':
Directory = tessoptarg;
break;
case 'U':
InputUnicharsetFile = tessoptarg;
break;
case 'O':
OutputUnicharsetFile = tessoptarg;
break;
case 'F':
InputFontInfoFile = tessoptarg;
break;
case '?':
Error = TRUE;
break;
}
if ( Error )
{
fprintf (stderr, "usage: %s [-d] [-p] [-n]\n", argv[0] );
fprintf (stderr, "\t[-S ProtoStyle]\n");
fprintf (stderr, "\t[-M MinSamples] [-B MaxBad] [-I Independence]\n");
fprintf (stderr, "\t[-C Confidence] [-D Directory]\n");
fprintf (stderr, "\t[-U InputUnicharsetFile] [-O OutputUnicharsetFile]\n");
fprintf (stderr, "\t[-F FontInfoFile]\n");
fprintf (stderr, "\t[ TrainingPage ... ]\n");
exit (2);
}
}
} // ParseArguments
/*---------------------------------------------------------------------------*/
char *GetNextFilename (int Argc, char** Argv)
/*
** Parameters: none
** Globals:
** tessoptind defined by tessopt sys call
** Operation:
** This routine returns the next command line argument. If
** there are no remaining command line arguments, it returns
** NULL. This routine should only be called after all option
** arguments have been parsed and removed with ParseArguments.
** Return: Next command line argument or NULL.
** Exceptions: none
** History: Fri Aug 18 09:34:12 1989, DSJ, Created.
*/
{
if (tessoptind < Argc)
return (Argv [tessoptind++]);
else
return (NULL);
} /* GetNextFilename */
/*---------------------------------------------------------------------------*/
LABELEDLIST FindList (
LIST List,
char *Label)
/*
** Parameters:
** List list to search
** Label label to search for
** Globals: none
** Operation:
** This routine searches thru a list of labeled lists to find
** a list with the specified label. If a matching labeled list
** cannot be found, NULL is returned.
** Return: Labeled list with the specified Label or NULL.
** Exceptions: none
** History: Fri Aug 18 15:57:41 1989, DSJ, Created.
*/
{
LABELEDLIST LabeledList;
iterate (List)
{
LabeledList = (LABELEDLIST) first_node (List);
if (strcmp (LabeledList->Label, Label) == 0)
return (LabeledList);
}
return (NULL);
} /* FindList */
/*---------------------------------------------------------------------------*/
LABELEDLIST NewLabeledList (
const char *Label)
/*
** Parameters:
** Label label for new list
** Globals: none
** Operation:
** This routine allocates a new, empty labeled list and gives
** it the specified label.
** Return: New, empty labeled list.
** Exceptions: none
** History: Fri Aug 18 16:08:46 1989, DSJ, Created.
*/
{
LABELEDLIST LabeledList;
LabeledList = (LABELEDLIST) Emalloc (sizeof (LABELEDLISTNODE));
LabeledList->Label = (char*)Emalloc (strlen (Label)+1);
strcpy (LabeledList->Label, Label);
LabeledList->List = NIL;
LabeledList->SampleCount = 0;
return (LabeledList);
} /* NewLabeledList */
/*---------------------------------------------------------------------------*/
void WriteTrainingSamples (
char *Directory,
LIST CharList,
const char* program_feature_type)
/*
** Parameters:
** Directory directory to place sample files into
** FontList list of fonts used in the training samples
** Operation:
** This routine writes the specified samples into files which
** are organized according to the font name and character name
** of the samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 16:17:06 1989, DSJ, Created.
*/
{
LABELEDLIST CharSample;
FEATURE_SET FeatureSet;
LIST FeatureList;
FILE *File;
char Filename[MAXNAMESIZE];
int NumSamples;
iterate (CharList) // iterate thru all of the fonts
{
CharSample = (LABELEDLIST) first_node (CharList);
// construct the full pathname for the current samples file
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, CTFontName);
strcat (Filename, "/");
strcat (Filename, CharSample->Label);
strcat (Filename, ".");
strcat (Filename, program_feature_type);
printf ("\nWriting %s ...", Filename);
/* if file does not exist, create a new one with an appropriate
header; otherwise append samples to the existing file */
File = fopen (Filename, "r");
if (File == NULL)
{
File = Efopen (Filename, "w");
WriteOldParamDesc(
File,
FeatureDefs.FeatureDesc[ShortNameToFeatureType(
program_feature_type)]);
}
else
{
fclose (File);
File = Efopen (Filename, "a");
}
// append samples onto the file
FeatureList = CharSample->List;
NumSamples = 0;
iterate (FeatureList)
{
FeatureSet = (FEATURE_SET) first_node (FeatureList);
WriteFeatureSet (File, FeatureSet);
NumSamples++;
}
fclose (File);
}
} /* WriteTrainingSamples */
/*---------------------------------------------------------------------------*/
void FreeTrainingSamples (
LIST CharList)
/*
** Parameters:
** FontList list of all fonts in document
** Globals: none
** Operation:
** This routine deallocates all of the space allocated to
** the specified list of training samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 17:44:27 1989, DSJ, Created.
*/
{
LABELEDLIST CharSample;
FEATURE_SET FeatureSet;
LIST FeatureList;
// printf ("FreeTrainingSamples...\n");
iterate (CharList) /* iterate thru all of the fonts */
{
CharSample = (LABELEDLIST) first_node (CharList);
FeatureList = CharSample->List;
iterate (FeatureList) /* iterate thru all of the classes */
{
FeatureSet = (FEATURE_SET) first_node (FeatureList);
FreeFeatureSet (FeatureSet);
}
FreeLabeledList (CharSample);
}
destroy (CharList);
} /* FreeTrainingSamples */
/*---------------------------------------------------------------------------*/
void FreeLabeledList (
LABELEDLIST LabeledList)
/*
** Parameters:
** LabeledList labeled list to be freed
** Globals: none
** Operation:
** This routine deallocates all of the memory consumed by
** a labeled list. It does not free any memory which may be
** consumed by the items in the list.
** Return: none
** Exceptions: none
** History: Fri Aug 18 17:52:45 1989, DSJ, Created.
*/
{
destroy (LabeledList->List);
free (LabeledList->Label);
free (LabeledList);
} /* FreeLabeledList */
/*---------------------------------------------------------------------------*/
CLUSTERER *SetUpForClustering(
LABELEDLIST CharSample,
const char* program_feature_type)
/*
** Parameters:
** CharSample: LABELEDLIST that holds all the feature information for a
** given character.
** Globals:
** None
** Operation:
** This routine reads samples from a LABELEDLIST and enters
** those samples into a clusterer data structure. This
** data structure is then returned to the caller.
** Return:
** Pointer to new clusterer data structure.
** Exceptions:
** None
** History:
** 8/16/89, DSJ, Created.
*/
{
uinT16 N;
int i, j;
FLOAT32 *Sample = NULL;
CLUSTERER *Clusterer;
inT32 CharID;
LIST FeatureList = NULL;
FEATURE_SET FeatureSet = NULL;
FEATURE_DESC FeatureDesc = NULL;
// PARAM_DESC* ParamDesc;
FeatureDesc =
FeatureDefs.FeatureDesc[ShortNameToFeatureType(program_feature_type)];
N = FeatureDesc->NumParams;
// ParamDesc = ConvertToPARAMDESC(FeatureDesc->ParamDesc, N);
Clusterer = MakeClusterer(N,FeatureDesc->ParamDesc);
// free(ParamDesc);
FeatureList = CharSample->List;
CharID = 0;
iterate(FeatureList)
{
FeatureSet = (FEATURE_SET) first_node (FeatureList);
for (i=0; i < FeatureSet->MaxNumFeatures; i++)
{
if (Sample == NULL)
Sample = (FLOAT32 *)Emalloc(N * sizeof(FLOAT32));
for (j=0; j < N; j++)
if (RoundingAccuracy != 0.0f)
Sample[j] = round(FeatureSet->Features[i]->Params[j], RoundingAccuracy);
else
Sample[j] = FeatureSet->Features[i]->Params[j];
MakeSample (Clusterer, Sample, CharID);
}
CharID++;
}
if ( Sample != NULL ) free( Sample );
return( Clusterer );
} /* SetUpForClustering */
/*------------------------------------------------------------------------*/
void MergeInsignificantProtos(LIST ProtoList, const char* label,
CLUSTERER *Clusterer, CLUSTERCONFIG *Config) {
PROTOTYPE *Prototype;
bool debug = strcmp(test_ch, label) == 0;
LIST pProtoList = ProtoList;
iterate(pProtoList) {
Prototype = (PROTOTYPE *) first_node (pProtoList);
if (Prototype->Significant || Prototype->Merged)
continue;
FLOAT32 best_dist = 0.125;
PROTOTYPE* best_match = NULL;
// Find the nearest alive prototype.
LIST list_it = ProtoList;
iterate(list_it) {
PROTOTYPE* test_p = (PROTOTYPE *) first_node (list_it);
if (test_p != Prototype && !test_p->Merged) {
FLOAT32 dist = ComputeDistance(Clusterer->SampleSize,
Clusterer->ParamDesc,
Prototype->Mean, test_p->Mean);
if (dist < best_dist) {
best_match = test_p;
best_dist = dist;
}
}
}
if (best_match != NULL && !best_match->Significant) {
if (debug)
tprintf("Merging red clusters (%d+%d) at %g,%g and %g,%g\n",
best_match->NumSamples, Prototype->NumSamples,
best_match->Mean[0], best_match->Mean[1],
Prototype->Mean[0], Prototype->Mean[1]);
best_match->NumSamples = MergeClusters(Clusterer->SampleSize,
Clusterer->ParamDesc,
best_match->NumSamples,
Prototype->NumSamples,
best_match->Mean,
best_match->Mean, Prototype->Mean);
Prototype->NumSamples = 0;
Prototype->Merged = 1;
} else if (best_match != NULL) {
if (debug)
tprintf("Red proto at %g,%g matched a green one at %g,%g\n",
Prototype->Mean[0], Prototype->Mean[1],
best_match->Mean[0], best_match->Mean[1]);
Prototype->Merged = 1;
}
}
// Mark significant those that now have enough samples.
int min_samples = (inT32) (Config->MinSamples * Clusterer->NumChar);
pProtoList = ProtoList;
iterate(pProtoList) {
Prototype = (PROTOTYPE *) first_node (pProtoList);
// Process insignificant protos that do not match a green one
if (!Prototype->Significant && Prototype->NumSamples >= min_samples &&
!Prototype->Merged) {
if (debug)
tprintf("Red proto at %g,%g becoming green\n",
Prototype->Mean[0], Prototype->Mean[1]);
Prototype->Significant = true;
}
}
} /* MergeInsignificantProtos */
/*-----------------------------------------------------------------------------*/
void CleanUpUnusedData(
LIST ProtoList)
{
PROTOTYPE* Prototype;
iterate(ProtoList)
{
Prototype = (PROTOTYPE *) first_node (ProtoList);
if(Prototype->Variance.Elliptical != NULL)
{
memfree(Prototype->Variance.Elliptical);
Prototype->Variance.Elliptical = NULL;
}
if(Prototype->Magnitude.Elliptical != NULL)
{
memfree(Prototype->Magnitude.Elliptical);
Prototype->Magnitude.Elliptical = NULL;
}
if(Prototype->Weight.Elliptical != NULL)
{
memfree(Prototype->Weight.Elliptical);
Prototype->Weight.Elliptical = NULL;
}
}
}
/*------------------------------------------------------------------------*/
LIST RemoveInsignificantProtos(
LIST ProtoList,
BOOL8 KeepSigProtos,
BOOL8 KeepInsigProtos,
int N)
{
LIST NewProtoList = NIL;
LIST pProtoList;
PROTOTYPE* Proto;
PROTOTYPE* NewProto;
int i;
pProtoList = ProtoList;
iterate(pProtoList)
{
Proto = (PROTOTYPE *) first_node (pProtoList);
if ((Proto->Significant && KeepSigProtos) ||
(!Proto->Significant && KeepInsigProtos))
{
NewProto = (PROTOTYPE *)Emalloc(sizeof(PROTOTYPE));
NewProto->Mean = (FLOAT32 *)Emalloc(N * sizeof(FLOAT32));
NewProto->Significant = Proto->Significant;
NewProto->Style = Proto->Style;
NewProto->NumSamples = Proto->NumSamples;
NewProto->Cluster = NULL;
NewProto->Distrib = NULL;
for (i=0; i < N; i++)
NewProto->Mean[i] = Proto->Mean[i];
if (Proto->Variance.Elliptical != NULL)
{
NewProto->Variance.Elliptical = (FLOAT32 *)Emalloc(N * sizeof(FLOAT32));
for (i=0; i < N; i++)
NewProto->Variance.Elliptical[i] = Proto->Variance.Elliptical[i];
}
else
NewProto->Variance.Elliptical = NULL;
//---------------------------------------------
if (Proto->Magnitude.Elliptical != NULL)
{
NewProto->Magnitude.Elliptical = (FLOAT32 *)Emalloc(N * sizeof(FLOAT32));
for (i=0; i < N; i++)
NewProto->Magnitude.Elliptical[i] = Proto->Magnitude.Elliptical[i];
}
else
NewProto->Magnitude.Elliptical = NULL;
//------------------------------------------------
if (Proto->Weight.Elliptical != NULL)
{
NewProto->Weight.Elliptical = (FLOAT32 *)Emalloc(N * sizeof(FLOAT32));
for (i=0; i < N; i++)
NewProto->Weight.Elliptical[i] = Proto->Weight.Elliptical[i];
}
else
NewProto->Weight.Elliptical = NULL;
NewProto->TotalMagnitude = Proto->TotalMagnitude;
NewProto->LogMagnitude = Proto->LogMagnitude;
NewProtoList = push_last(NewProtoList, NewProto);
}
}
//FreeProtoList (ProtoList);
return (NewProtoList);
} /* RemoveInsignificantProtos */
/*----------------------------------------------------------------------------*/
MERGE_CLASS FindClass (
LIST List,
char *Label)
{
MERGE_CLASS MergeClass;
iterate (List)
{
MergeClass = (MERGE_CLASS) first_node (List);
if (strcmp (MergeClass->Label, Label) == 0)
return (MergeClass);
}
return (NULL);
} /* FindClass */
/*---------------------------------------------------------------------------*/
MERGE_CLASS NewLabeledClass (
char *Label)
{
MERGE_CLASS MergeClass;
MergeClass = new MERGE_CLASS_NODE;
MergeClass->Label = (char*)Emalloc (strlen (Label)+1);
strcpy (MergeClass->Label, Label);
MergeClass->Class = NewClass (MAX_NUM_PROTOS, MAX_NUM_CONFIGS);
return (MergeClass);
} /* NewLabeledClass */
/*-----------------------------------------------------------------------------*/
void FreeLabeledClassList (
LIST ClassList)
/*
** Parameters:
** FontList list of all fonts in document
** Globals: none
** Operation:
** This routine deallocates all of the space allocated to
** the specified list of training samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 17:44:27 1989, DSJ, Created.
*/
{
MERGE_CLASS MergeClass;
iterate (ClassList) /* iterate thru all of the fonts */
{
MergeClass = (MERGE_CLASS) first_node (ClassList);
free (MergeClass->Label);
FreeClass(MergeClass->Class);
delete MergeClass;
}
destroy (ClassList);
} /* FreeLabeledClassList */
/** SetUpForFloat2Int **************************************************/
void SetUpForFloat2Int(
LIST LabeledClassList)
{
MERGE_CLASS MergeClass;
CLASS_TYPE Class;
int NumProtos;
int NumConfigs;
int NumWords;
int i, j;
float Values[3];
PROTO NewProto;
PROTO OldProto;
BIT_VECTOR NewConfig;
BIT_VECTOR OldConfig;
// printf("Float2Int ...\n");
iterate(LabeledClassList)
{
UnicityTableEqEq<int> font_set;
MergeClass = (MERGE_CLASS) first_node (LabeledClassList);
Class = &TrainingData[unicharset_training.unichar_to_id(
MergeClass->Label)];
NumProtos = MergeClass->Class->NumProtos;
NumConfigs = MergeClass->Class->NumConfigs;
font_set.move(&MergeClass->Class->font_set);
Class->NumProtos = NumProtos;
Class->MaxNumProtos = NumProtos;
Class->Prototypes = (PROTO) Emalloc (sizeof(PROTO_STRUCT) * NumProtos);
for(i=0; i < NumProtos; i++)
{
NewProto = ProtoIn(Class, i);
OldProto = ProtoIn(MergeClass->Class, i);
Values[0] = OldProto->X;
Values[1] = OldProto->Y;
Values[2] = OldProto->Angle;
Normalize(Values);
NewProto->X = OldProto->X;
NewProto->Y = OldProto->Y;
NewProto->Length = OldProto->Length;
NewProto->Angle = OldProto->Angle;
NewProto->A = Values[0];
NewProto->B = Values[1];
NewProto->C = Values[2];
}
Class->NumConfigs = NumConfigs;
Class->MaxNumConfigs = NumConfigs;
Class->font_set.move(&font_set);
Class->Configurations = (BIT_VECTOR*) Emalloc (sizeof(BIT_VECTOR) * NumConfigs);
NumWords = WordsInVectorOfSize(NumProtos);
for(i=0; i < NumConfigs; i++)
{
NewConfig = NewBitVector(NumProtos);
OldConfig = MergeClass->Class->Configurations[i];
for(j=0; j < NumWords; j++)
NewConfig[j] = OldConfig[j];
Class->Configurations[i] = NewConfig;
}
}
} // SetUpForFloat2Int
/*--------------------------------------------------------------------------*/
void Normalize (
float *Values)
{
register float Slope;
register float Intercept;
register float Normalizer;
Slope = tan (Values [2] * 2 * PI);
Intercept = Values [1] - Slope * Values [0];
Normalizer = 1 / sqrt (Slope * Slope + 1.0);
Values [0] = Slope * Normalizer;
Values [1] = - Normalizer;
Values [2] = Intercept * Normalizer;
} // Normalize
/*-------------------------------------------------------------------------*/
void FreeNormProtoList (
LIST CharList)
{
LABELEDLIST CharSample;
iterate (CharList) /* iterate thru all of the fonts */
{
CharSample = (LABELEDLIST) first_node (CharList);
FreeLabeledList (CharSample);
}
destroy (CharList);
} // FreeNormProtoList
/*---------------------------------------------------------------------------*/
void AddToNormProtosList(
LIST* NormProtoList,
LIST ProtoList,
char* CharName)
{
PROTOTYPE* Proto;
LABELEDLIST LabeledProtoList;
LabeledProtoList = NewLabeledList(CharName);
iterate(ProtoList)
{
Proto = (PROTOTYPE *) first_node (ProtoList);
LabeledProtoList->List = push(LabeledProtoList->List, Proto);
}
*NormProtoList = push(*NormProtoList, LabeledProtoList);
}
/*---------------------------------------------------------------------------*/
int NumberOfProtos(
LIST ProtoList,
BOOL8 CountSigProtos,
BOOL8 CountInsigProtos)
{
int N = 0;
PROTOTYPE *Proto;
iterate(ProtoList)
{
Proto = (PROTOTYPE *) first_node ( ProtoList );
if (( Proto->Significant && CountSigProtos ) ||
( ! Proto->Significant && CountInsigProtos ) )
N++;
}
return(N);
}

View File

@ -1,10 +1,10 @@
/******************************************************************************
** Filename: MergeNF.c
** Purpose: Program for merging similar nano-feature protos
** Author: Dan Johnson
** History: Wed Nov 21 09:55:23 1990, DSJ, Created.
** 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.
** (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
@ -16,7 +16,7 @@
** limitations under the License.
******************************************************************************/
/**----------------------------------------------------------------------------
Include Files and Type Defines
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "mergenf.h"
#include "general.h"
@ -25,12 +25,12 @@
#include "cluster.h"
#include "oldlist.h"
#include "protos.h"
#include "minmax.h"
#include "ndminx.h"
#include "ocrfeatures.h"
#include "debug.h"
#include "const.h"
#include "featdefs.h"
#include "intproto.h"
#include "varable.h"
#include <stdio.h>
#include <string.h>
@ -38,264 +38,217 @@
/**----------------------------------------------------------------------------
Variables
Variables
-----------------------------------------------------------------------------**/
/*-------------------once in subfeat---------------------------------*/
make_float_var (AngleMatchScale, 1.0, MakeAngleMatchScale,
7, 2, SetAngleMatchScale, "Angle Match Scale ...")
double_VAR(training_angle_match_scale, 1.0, "Angle Match Scale ...");
make_float_var (SimilarityMidpoint, 0.0075, MakeSimilarityMidpoint,
7, 3, SetSimilarityMidpoint, "Similarity Midpoint ...")
double_VAR(training_similarity_midpoint, 0.0075, "Similarity Midpoint ...");
make_float_var (SimilarityCurl, 2.0, MakeSimilarityCurl,
7, 4, SetSimilarityCurl, "Similarity Curl ...")
double_VAR(training_similarity_curl, 2.0, "Similarity Curl ...");
/*-----------------------------once in fasttrain----------------------------------*/
make_float_var (TangentBBoxPad, 0.5, MakeTangentBBoxPad,
15, 3, SetTangentBBoxPad, "Tangent bounding box pad ...")
double_VAR(training_tangent_bbox_pad, 0.5, "Tangent bounding box pad ...");
make_float_var (OrthogonalBBoxPad, 2.5, MakeOrthogonalBBoxPad,
15, 4, SetOrthogonalBBoxPad, "Orthogonal bounding box pad ...")
double_VAR(training_orthogonal_bbox_pad, 2.5, "Orthogonal bounding box pad ...");
make_float_var (AnglePad, 45.0, MakeAnglePad,
15, 5, SetAnglePad, "Angle pad ...")
double_VAR(training_angle_pad, 45.0, "Angle pad ...");
/**----------------------------------------------------------------------------
Global Data Definitions and Declarations
Global Data Definitions and Declarations
----------------------------------------------------------------------------**/
//int row_number; /* kludge due to linking problems */
//int row_number; /* kludge due to linking problems */
/**----------------------------------------------------------------------------
Public Code
Public Code
----------------------------------------------------------------------------**/
/*---------------------------------------------------------------------------*/
FLOAT32 CompareProtos (
PROTO p1,
PROTO p2)
FLOAT32 CompareProtos(PROTO p1, PROTO p2) {
/*
** Parameters:
** p1, p2 protos to be compared
** Globals: none
** Operation: Compare protos p1 and p2 and return an estimate of the
** worst evidence rating that will result for any part of p1
** that is compared to p2. In other words, if p1 were broken
** into pico-features and each pico-feature was matched to p2,
** what is the worst evidence rating that will be achieved for
** any pico-feature.
** Return: Worst possible result when matching p1 to p2.
** Exceptions: none
** History: Mon Nov 26 08:27:53 1990, DSJ, Created.
** Parameters:
** p1, p2 protos to be compared
** Globals: none
** Operation: Compare protos p1 and p2 and return an estimate of the
** worst evidence rating that will result for any part of p1
** that is compared to p2. In other words, if p1 were broken
** into pico-features and each pico-feature was matched to p2,
** what is the worst evidence rating that will be achieved for
** any pico-feature.
** Return: Worst possible result when matching p1 to p2.
** Exceptions: none
** History: Mon Nov 26 08:27:53 1990, DSJ, Created.
*/
FEATURE Feature;
FLOAT32 WorstEvidence = WORST_EVIDENCE;
FLOAT32 Evidence;
FLOAT32 Angle, Length;
{
FEATURE Feature;
FLOAT32 WorstEvidence = WORST_EVIDENCE;
FLOAT32 Evidence;
FLOAT32 Angle, Length;
/* if p1 and p2 are not close in length, don't let them match */
Length = fabs (p1->Length - p2->Length);
if (Length > MAX_LENGTH_MISMATCH)
return (0.0);
/* if p1 and p2 are not close in length, don't let them match */
Length = fabs (p1->Length - p2->Length);
if (Length > MAX_LENGTH_MISMATCH)
return (0.0);
/* create a dummy pico-feature to be used for comparisons */
Feature = NewFeature (&PicoFeatDesc);
Feature->Params[PicoFeatDir] = p1->Angle;
/* create a dummy pico-feature to be used for comparisons */
Feature = NewFeature (&PicoFeatDesc);
Feature->Params[PicoFeatDir] = p1->Angle;
/* convert angle to radians */
Angle = p1->Angle * 2.0 * PI;
/* convert angle to radians */
Angle = p1->Angle * 2.0 * PI;
/* find distance from center of p1 to 1/2 picofeat from end */
Length = p1->Length / 2.0 - GetPicoFeatureLength () / 2.0;
if (Length < 0) Length = 0;
/* find distance from center of p1 to 1/2 picofeat from end */
Length = p1->Length / 2.0 - GetPicoFeatureLength () / 2.0;
if (Length < 0) Length = 0;
/* set the dummy pico-feature at one end of p1 and match it to p2 */
Feature->Params[PicoFeatX] = p1->X + cos (Angle) * Length;
Feature->Params[PicoFeatY] = p1->Y + sin (Angle) * Length;
if (DummyFastMatch (Feature, p2)) {
Evidence = SubfeatureEvidence (Feature, p2);
if (Evidence < WorstEvidence)
WorstEvidence = Evidence;
} else {
FreeFeature(Feature);
return 0.0;
}
/* set the dummy pico-feature at one end of p1 and match it to p2 */
Feature->Params[PicoFeatX] = p1->X + cos (Angle) * Length;
Feature->Params[PicoFeatY] = p1->Y + sin (Angle) * Length;
if (DummyFastMatch (Feature, p2))
{
Evidence = SubfeatureEvidence (Feature, p2);
if (Evidence < WorstEvidence)
WorstEvidence = Evidence;
}
else
{
FreeFeature (Feature);
return (0.0);
}
/* set the dummy pico-feature at the other end of p1 and match it to p2 */
Feature->Params[PicoFeatX] = p1->X - cos (Angle) * Length;
Feature->Params[PicoFeatY] = p1->Y - sin (Angle) * Length;
if (DummyFastMatch (Feature, p2)) {
Evidence = SubfeatureEvidence (Feature, p2);
if (Evidence < WorstEvidence)
WorstEvidence = Evidence;
} else {
FreeFeature(Feature);
return 0.0;
}
/* set the dummy pico-feature at the other end of p1 and match it to p2 */
Feature->Params[PicoFeatX] = p1->X - cos (Angle) * Length;
Feature->Params[PicoFeatY] = p1->Y - sin (Angle) * Length;
if (DummyFastMatch (Feature, p2))
{
Evidence = SubfeatureEvidence (Feature, p2);
if (Evidence < WorstEvidence)
WorstEvidence = Evidence;
}
else
{
FreeFeature (Feature);
return (0.0);
}
FreeFeature (Feature);
return (WorstEvidence);
FreeFeature (Feature);
return (WorstEvidence);
} /* CompareProtos */
} /* CompareProtos */
/*---------------------------------------------------------------------------*/
void ComputeMergedProto (
PROTO p1,
PROTO p2,
FLOAT32 w1,
FLOAT32 w2,
PROTO MergedProto)
PROTO p1,
PROTO p2,
FLOAT32 w1,
FLOAT32 w2,
PROTO MergedProto)
/*
** Parameters:
** p1, p2 protos to be merged
** w1, w2 weight of each proto
** MergedProto place to put resulting merged proto
** Globals: none
** Operation: This routine computes a proto which is the weighted
** average of protos p1 and p2. The new proto is returned
** in MergedProto.
** Return: none (results are returned in MergedProto)
** Exceptions: none
** History: Mon Nov 26 08:15:08 1990, DSJ, Created.
** Parameters:
** p1, p2 protos to be merged
** w1, w2 weight of each proto
** MergedProto place to put resulting merged proto
** Globals: none
** Operation: This routine computes a proto which is the weighted
** average of protos p1 and p2. The new proto is returned
** in MergedProto.
** Return: none (results are returned in MergedProto)
** Exceptions: none
** History: Mon Nov 26 08:15:08 1990, DSJ, Created.
*/
{
FLOAT32 TotalWeight;
FLOAT32 TotalWeight;
TotalWeight = w1 + w2;
w1 /= TotalWeight;
w2 /= TotalWeight;
TotalWeight = w1 + w2;
w1 /= TotalWeight;
w2 /= TotalWeight;
MergedProto->X = p1->X * w1 + p2->X * w2;
MergedProto->Y = p1->Y * w1 + p2->Y * w2;
MergedProto->Length = p1->Length * w1 + p2->Length * w2;
MergedProto->Angle = p1->Angle * w1 + p2->Angle * w2;
FillABC (MergedProto);
} /* ComputeMergedProto */
MergedProto->X = p1->X * w1 + p2->X * w2;
MergedProto->Y = p1->Y * w1 + p2->Y * w2;
MergedProto->Length = p1->Length * w1 + p2->Length * w2;
MergedProto->Angle = p1->Angle * w1 + p2->Angle * w2;
FillABC(MergedProto);
} /* ComputeMergedProto */
/*---------------------------------------------------------------------------*/
int FindClosestExistingProto (
CLASS_TYPE Class,
int NumMerged[],
PROTOTYPE *Prototype)
int FindClosestExistingProto(CLASS_TYPE Class, int NumMerged[],
PROTOTYPE *Prototype) {
/*
** Parameters:
** Class class to search for matching old proto in
** NumMerged[] # of protos merged into each proto of Class
** Prototype new proto to find match for
** Globals: none
** Operation: This routine searches thru all of the prototypes in
** Class and returns the id of the proto which would provide
** the best approximation of Prototype. If no close
** approximation can be found, NO_PROTO is returned.
** Return: Id of closest proto in Class or NO_PROTO.
** Exceptions: none
** History: Sat Nov 24 11:42:58 1990, DSJ, Created.
** Parameters:
** Class class to search for matching old proto in
** NumMerged[] # of protos merged into each proto of Class
** Prototype new proto to find match for
** Globals: none
** Operation: This routine searches thru all of the prototypes in
** Class and returns the id of the proto which would provide
** the best approximation of Prototype. If no close
** approximation can be found, NO_PROTO is returned.
** Return: Id of closest proto in Class or NO_PROTO.
** Exceptions: none
** History: Sat Nov 24 11:42:58 1990, DSJ, Created.
*/
PROTO_STRUCT NewProto;
PROTO_STRUCT MergedProto;
int Pid;
PROTO Proto;
int BestProto;
FLOAT32 BestMatch;
FLOAT32 Match, OldMatch, NewMatch;
{
PROTO_STRUCT NewProto;
PROTO_STRUCT MergedProto;
int Pid;
PROTO Proto;
int BestProto;
FLOAT32 BestMatch;
FLOAT32 Match, OldMatch, NewMatch;
MakeNewFromOld (&NewProto, Prototype);
MakeNewFromOld (&NewProto, Prototype);
BestProto = NO_PROTO;
BestMatch = WORST_MATCH_ALLOWED;
for (Pid = 0; Pid < Class->NumProtos; Pid++)
{
Proto = ProtoIn (Class, Pid);
ComputeMergedProto (Proto, &NewProto,
(FLOAT32) NumMerged[Pid], 1.0, &MergedProto);
OldMatch = CompareProtos (Proto, &MergedProto);
NewMatch = CompareProtos (&NewProto, &MergedProto);
Match = MIN (OldMatch, NewMatch);
if (Match > BestMatch)
{
BestProto = Pid;
BestMatch = Match;
}
BestProto = NO_PROTO;
BestMatch = WORST_MATCH_ALLOWED;
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
Proto = ProtoIn(Class, Pid);
ComputeMergedProto(Proto, &NewProto,
(FLOAT32) NumMerged[Pid], 1.0, &MergedProto);
OldMatch = CompareProtos(Proto, &MergedProto);
NewMatch = CompareProtos(&NewProto, &MergedProto);
Match = MIN(OldMatch, NewMatch);
if (Match > BestMatch) {
BestProto = Pid;
BestMatch = Match;
}
return (BestProto);
} /* FindClosestExistingProto */
}
return BestProto;
} /* FindClosestExistingProto */
/*---------------------------------------------------------------------------*/
void MakeNewFromOld (
PROTO New,
PROTOTYPE *Old)
void MakeNewFromOld(PROTO New, PROTOTYPE *Old) {
/*
** Parameters:
** New new proto to be filled in
** Old old proto to be converted
** Globals: none
** Operation: This fills in the fields of the New proto based on the
** fields of the Old proto.
** Return: none
** Exceptions: none
** History: Mon Nov 26 09:45:39 1990, DSJ, Created.
** Parameters:
** New new proto to be filled in
** Old old proto to be converted
** Globals: none
** Operation: This fills in the fields of the New proto based on the
** fields of the Old proto.
** Return: none
** Exceptions: none
** History: Mon Nov 26 09:45:39 1990, DSJ, Created.
*/
{
New->X = CenterX (Old->Mean);
New->Y = CenterY (Old->Mean);
New->Length = LengthOf (Old->Mean);
New->Angle = OrientationOf (Old->Mean);
FillABC (New);
} /* MakeNewFromOld */
New->X = CenterX(Old->Mean);
New->Y = CenterY(Old->Mean);
New->Length = LengthOf(Old->Mean);
New->Angle = OrientationOf(Old->Mean);
FillABC(New);
} /* MakeNewFromOld */
/*-------------------once in subfeat---------------------------------*/
/**********************************************************************
* InitSubfeatureVars
*
* Create and set up all menus and variables needed for this file.
**********************************************************************/
void InitSubfeatureVars ()
{
MakeAngleMatchScale ();
MakeSimilarityCurl ();
MakeSimilarityMidpoint ();
}
/**********************************************************************
* SubfeatureEvidence
*
* Compare a feature to a prototype. Print the result.
**********************************************************************/
FLOAT32 SubfeatureEvidence (
FEATURE Feature,
PROTO Proto)
{
float Distance;
float Dangle;
FLOAT32 SubfeatureEvidence(FEATURE Feature, PROTO Proto) {
float Distance;
float Dangle;
Dangle = Proto->Angle - Feature->Params[PicoFeatDir];
if (Dangle < -0.5) Dangle += 1.0;
if (Dangle > 0.5) Dangle -= 1.0;
Dangle *= AngleMatchScale;
Dangle = Proto->Angle - Feature->Params[PicoFeatDir];
if (Dangle < -0.5) Dangle += 1.0;
if (Dangle > 0.5) Dangle -= 1.0;
Dangle *= training_angle_match_scale;
Distance = Proto->A * Feature->Params[PicoFeatX] +
Proto->B * Feature->Params[PicoFeatY] +
Proto->C;
Distance = Proto->A * Feature->Params[PicoFeatX] +
Proto->B * Feature->Params[PicoFeatY] +
Proto->C;
return (EvidenceOf (Distance * Distance + Dangle * Dangle));
return (EvidenceOf (Distance * Distance + Dangle * Dangle));
}
/**********************************************************************
@ -310,142 +263,110 @@ FLOAT32 EvidenceOf (
register FLOAT32 Similarity)
{
Similarity /= SimilarityMidpoint;
Similarity /= training_similarity_midpoint;
if (SimilarityCurl == 3)
Similarity = Similarity * Similarity * Similarity;
else if (SimilarityCurl == 2)
Similarity = Similarity * Similarity;
else
Similarity = pow (Similarity, SimilarityCurl);
if (training_similarity_curl == 3)
Similarity = Similarity * Similarity * Similarity;
else if (training_similarity_curl == 2)
Similarity = Similarity * Similarity;
else
Similarity = static_cast<float>(pow(static_cast<double>(Similarity),
training_similarity_curl));
return (1.0 / (1.0 + Similarity));
return (1.0 / (1.0 + Similarity));
}
/*-----------------------------once in fasttrain----------------------------------*/
void InitFastTrainerVars ()
/*
** Parameters: none
** Globals: none
** Operation: This routine initializes all of the control variables
** for the fast trainer.
** Return: none
** Exceptions: none
** History: Mon Nov 12 13:27:35 1990, DSJ, Created.
*/
{
MakeTangentBBoxPad ();
MakeOrthogonalBBoxPad ();
MakeAnglePad ();
} /* InitFastTrainerVars */
/*---------------------------------------------------------------------------*/
BOOL8 DummyFastMatch (
FEATURE Feature,
PROTO Proto)
FEATURE Feature,
PROTO Proto)
/*
** Parameters:
** Feature feature to be "fast matched" to proto
** Proto proto being "fast matched" against
** Globals:
** TangentBBoxPad bounding box pad tangent to proto
** OrthogonalBBoxPad bounding box pad orthogonal to proto
** Operation: This routine returns TRUE if Feature would be matched
** by a fast match table built from Proto.
** Return: TRUE if feature could match Proto.
** Exceptions: none
** History: Wed Nov 14 17:19:58 1990, DSJ, Created.
** Parameters:
** Feature feature to be "fast matched" to proto
** Proto proto being "fast matched" against
** Globals:
** training_tangent_bbox_pad bounding box pad tangent to proto
** training_orthogonal_bbox_pad bounding box pad orthogonal to proto
** Operation: This routine returns TRUE if Feature would be matched
** by a fast match table built from Proto.
** Return: TRUE if feature could match Proto.
** Exceptions: none
** History: Wed Nov 14 17:19:58 1990, DSJ, Created.
*/
{
FRECT BoundingBox;
FLOAT32 MaxAngleError;
FLOAT32 AngleError;
FRECT BoundingBox;
FLOAT32 MaxAngleError;
FLOAT32 AngleError;
MaxAngleError = AnglePad / 360.0;
AngleError = fabs (Proto->Angle - Feature->Params[PicoFeatDir]);
if (AngleError > 0.5)
AngleError = 1.0 - AngleError;
MaxAngleError = training_angle_pad / 360.0;
AngleError = fabs (Proto->Angle - Feature->Params[PicoFeatDir]);
if (AngleError > 0.5)
AngleError = 1.0 - AngleError;
if (AngleError > MaxAngleError)
return (FALSE);
if (AngleError > MaxAngleError)
return (FALSE);
ComputePaddedBoundingBox (Proto,
TangentBBoxPad * GetPicoFeatureLength (),
OrthogonalBBoxPad * GetPicoFeatureLength (),
&BoundingBox);
ComputePaddedBoundingBox (Proto,
training_tangent_bbox_pad * GetPicoFeatureLength (),
training_orthogonal_bbox_pad * GetPicoFeatureLength (),
&BoundingBox);
return (PointInside (&BoundingBox,
Feature->Params[PicoFeatX],
Feature->Params[PicoFeatY]));
} /* DummyFastMatch */
return PointInside(&BoundingBox, Feature->Params[PicoFeatX],
Feature->Params[PicoFeatY]);
} /* DummyFastMatch */
/*----------------------------------------------------------------------------*/
void ComputePaddedBoundingBox (
PROTO Proto,
FLOAT32 TangentPad,
FLOAT32 OrthogonalPad,
FRECT *BoundingBox)
void ComputePaddedBoundingBox (PROTO Proto, FLOAT32 TangentPad,
FLOAT32 OrthogonalPad, FRECT *BoundingBox) {
/*
** Parameters:
** Proto proto to compute bounding box for
** TangentPad amount of pad to add in direction of segment
** OrthogonalPad amount of pad to add orthogonal to segment
** BoundingBox place to put results
** Globals: none
** Operation: This routine computes a bounding box that encloses the
** specified proto along with some padding. The
** amount of padding is specified as separate distances
** in the tangential and orthogonal directions.
** Return: none (results are returned in BoundingBox)
** Exceptions: none
** History: Wed Nov 14 14:55:30 1990, DSJ, Created.
** Parameters:
** Proto proto to compute bounding box for
** TangentPad amount of pad to add in direction of segment
** OrthogonalPad amount of pad to add orthogonal to segment
** BoundingBox place to put results
** Globals: none
** Operation: This routine computes a bounding box that encloses the
** specified proto along with some padding. The
** amount of padding is specified as separate distances
** in the tangential and orthogonal directions.
** Return: none (results are returned in BoundingBox)
** Exceptions: none
** History: Wed Nov 14 14:55:30 1990, DSJ, Created.
*/
FLOAT32 Pad, Length, Angle;
FLOAT32 CosOfAngle, SinOfAngle;
{
FLOAT32 Pad, Length, Angle;
FLOAT32 CosOfAngle, SinOfAngle;
Length = Proto->Length / 2.0 + TangentPad;
Angle = Proto->Angle * 2.0 * PI;
CosOfAngle = fabs(cos(Angle));
SinOfAngle = fabs(sin(Angle));
Length = Proto->Length / 2.0 + TangentPad;
Angle = Proto->Angle * 2.0 * PI;
CosOfAngle = fabs (cos (Angle));
SinOfAngle = fabs (sin (Angle));
Pad = MAX (CosOfAngle * Length, SinOfAngle * OrthogonalPad);
BoundingBox->MinX = Proto->X - Pad;
BoundingBox->MaxX = Proto->X + Pad;
Pad = MAX (CosOfAngle * Length, SinOfAngle * OrthogonalPad);
BoundingBox->MinX = Proto->X - Pad;
BoundingBox->MaxX = Proto->Y + Pad;
Pad = MAX(SinOfAngle * Length, CosOfAngle * OrthogonalPad);
BoundingBox->MinY = Proto->Y - Pad;
BoundingBox->MaxY = Proto->Y + Pad;
Pad = MAX (SinOfAngle * Length, CosOfAngle * OrthogonalPad);
BoundingBox->MinY = Proto->Y - Pad;
BoundingBox->MaxY = Proto->Y + Pad;
} /* ComputePaddedBoundingBox */
} /* ComputePaddedBoundingBox */
/*--------------------------------------------------------------------------*/
BOOL8 PointInside (
FRECT *Rectangle,
FLOAT32 X,
FLOAT32 Y)
BOOL8 PointInside(FRECT *Rectangle, FLOAT32 X, FLOAT32 Y) {
/*
** Parameters:
** Globals: none
** Operation: Return TRUE if point (X,Y) is inside of Rectangle.
** Return: Return TRUE if point (X,Y) is inside of Rectangle.
** Exceptions: none
** History: Wed Nov 14 17:26:35 1990, DSJ, Created.
** Parameters:
** Globals: none
** Operation: Return TRUE if point (X,Y) is inside of Rectangle.
** Return: Return TRUE if point (X,Y) is inside of Rectangle.
** Exceptions: none
** History: Wed Nov 14 17:26:35 1990, DSJ, Created.
*/
if (X < Rectangle->MinX) return (FALSE);
if (X > Rectangle->MaxX) return (FALSE);
if (Y < Rectangle->MinY) return (FALSE);
if (Y > Rectangle->MaxY) return (FALSE);
return (TRUE);
{
if (X < Rectangle->MinX) return (FALSE);
if (X > Rectangle->MaxX) return (FALSE);
if (Y < Rectangle->MinY) return (FALSE);
if (Y > Rectangle->MaxY) return (FALSE);
return (TRUE);
} /* PointInside */
} /* PointInside */

View File

@ -21,7 +21,8 @@
#include "protos.h"
#include "cluster.h"
#include "ocrfeatures.h"
#include "training.h"
#include "callcpp.h"
#include "picofeat.h"
#define WORST_MATCH_ALLOWED (0.9)
@ -37,8 +38,6 @@
#define MFLENGTH 2
#define ORIENTATION 3
typedef enum {PicoFeatY, PicoFeatDir, PicoFeatX} PICO_FEAT_PARAM_NAME;
typedef struct
{
FLOAT32 MinX, MaxX, MinY, MaxY;
@ -75,8 +74,6 @@ void MakeNewFromOld (
PROTO New,
PROTOTYPE *Old);
void InitSubfeatureVars ();
FLOAT32 SubfeatureEvidence (
FEATURE Feature,
PROTO Proto);
@ -84,8 +81,6 @@ FLOAT32 SubfeatureEvidence (
FLOAT32 EvidenceOf (
register FLOAT32 Similarity);
void InitFastTrainerVars ();
BOOL8 DummyFastMatch (
FEATURE Feature,
PROTO Proto);
@ -102,5 +97,3 @@ BOOL8 PointInside (
FLOAT32 Y);
extern FEATURE_DESC_STRUCT PicoFeatDesc;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

640
training/mftraining.cpp Normal file
View File

@ -0,0 +1,640 @@
/******************************************************************************
** Filename: mftraining.c
** Purpose: Separates training pages into files for each character.
** Strips from files only the features and there parameters of
the feature type mf.
** Author: Dan Johnson
** Revisment: Christy Russon
** Environment: HPUX 6.5
** Library: HPUX 6.5
** History: Fri Aug 18 08:53:50 1989, DSJ, Created.
** 5/25/90, DSJ, Adapted to multiple feature types.
** Tuesday, May 17, 1998 Changes made to make feature specific and
** simplify structures. First step in simplifying training process.
**
** (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.
******************************************************************************/
/**----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "oldlist.h"
#include "efio.h"
#include "emalloc.h"
#include "featdefs.h"
#include "tessopt.h"
#include "ocrfeatures.h"
#include "mf.h"
#include "general.h"
#include "clusttool.h"
#include "cluster.h"
#include "protos.h"
#include "ndminx.h"
#include "tprintf.h"
#include "const.h"
#include "mergenf.h"
#include "name2char.h"
#include "intproto.h"
#include "freelist.h"
#include "efio.h"
#include "danerror.h"
#include "globals.h"
#include "commontraining.h"
#include "unicity_table.h"
#include "genericvector.h"
#include "classify.h"
#include <string.h>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#ifdef WIN32
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#endif
#define PROGRAM_FEATURE_TYPE "mf"
#define MINSD (1.0f / 128.0f)
static const char* kInputUnicharsetFile = "unicharset";
static const char* kOutputUnicharsetFile = "mfunicharset";
/**----------------------------------------------------------------------------
Public Function Prototypes
----------------------------------------------------------------------------**/
int main (
int argc,
char **argv);
/**----------------------------------------------------------------------------
Private Function Prototypes
----------------------------------------------------------------------------**/
LIST ReadTrainingSamples (
FILE *File);
void WriteClusteredTrainingSamples (
char *Directory,
LIST ProtoList,
CLUSTERER *Clusterer,
LABELEDLIST CharSample);
/**/
void WriteMergedTrainingSamples(
char *Directory,
LIST ClassList);
void WriteMicrofeat(
char *Directory,
LIST ClassList);
void WriteProtos(
FILE* File,
MERGE_CLASS MergeClass);
void WriteConfigs(
FILE* File,
CLASS_TYPE Class);
/*
PARAMDESC *ConvertToPARAMDESC(
PARAM_DESC* Param_Desc,
int N);
*/
void WritePFFMTable(INT_TEMPLATES Templates, const char* filename);
// global variable to hold configuration parameters to control clustering
// -M 0.40 -B 0.05 -I 1.0 -C 1e-6.
CLUSTERCONFIG Config =
{ elliptical, 0.625, 0.05, 1.0, 1e-6, 0 };
/*----------------------------------------------------------------------------
Public Code
-----------------------------------------------------------------------------*/
void DisplayProtoList(const char* ch, LIST protolist) {
void* window = c_create_window("Char samples", 50, 200,
520, 520, -130.0, 130.0, -130.0, 130.0);
LIST proto = protolist;
iterate(proto) {
PROTOTYPE* prototype = reinterpret_cast<PROTOTYPE *>(first_node(proto));
if (prototype->Significant)
c_line_color_index(window, Green);
else if (prototype->NumSamples == 0)
c_line_color_index(window, Blue);
else if (prototype->Merged)
c_line_color_index(window, Magenta);
else
c_line_color_index(window, Red);
float x = CenterX(prototype->Mean);
float y = CenterY(prototype->Mean);
double angle = OrientationOf(prototype->Mean) * 2 * M_PI;
float dx = static_cast<float>(LengthOf(prototype->Mean) * cos(angle) / 2);
float dy = static_cast<float>(LengthOf(prototype->Mean) * sin(angle) / 2);
c_move(window, (x - dx) * 256, (y - dy) * 256);
c_draw(window, (x + dx) * 256, (y + dy) * 256);
if (prototype->Significant)
tprintf("Green proto at (%g,%g)+(%g,%g) %d samples\n",
x, y, dx, dy, prototype->NumSamples);
else if (prototype->NumSamples > 0 && !prototype->Merged)
tprintf("Red proto at (%g,%g)+(%g,%g) %d samples\n",
x, y, dx, dy, prototype->NumSamples);
}
c_make_current(window);
}
char* new_dup(const char* str) {
int len = strlen(str);
char* new_str = new char[len + 1];
strcpy(new_str, str);
return new_str;
}
/*---------------------------------------------------------------------------*/
int main (int argc, char **argv) {
/*
** Parameters:
** argc number of command line arguments
** argv array of command line arguments
** Globals: none
** Operation:
** This program reads in a text file consisting of feature
** samples from a training page in the following format:
**
** FontName CharName NumberOfFeatureTypes(N)
** FeatureTypeName1 NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** FeatureTypeName2 NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** ...
** FeatureTypeNameN NumberOfFeatures(M)
** Feature1
** ...
** FeatureM
** FontName CharName ...
**
** The result of this program is a binary inttemp file used by
** the OCR engine.
** Return: none
** Exceptions: none
** History: Fri Aug 18 08:56:17 1989, DSJ, Created.
** Mon May 18 1998, Christy Russson, Revistion started.
*/
char *PageName;
FILE *TrainingPage;
FILE *OutFile;
LIST CharList;
CLUSTERER *Clusterer = NULL;
LIST ProtoList = NIL;
LABELEDLIST CharSample;
PROTOTYPE *Prototype;
LIST ClassList = NIL;
int Cid, Pid;
PROTO Proto;
PROTO_STRUCT DummyProto;
BIT_VECTOR Config2;
MERGE_CLASS MergeClass;
INT_TEMPLATES IntTemplates;
LIST pCharList, pProtoList;
char Filename[MAXNAMESIZE];
tesseract::Classify classify;
ParseArguments (argc, argv);
if (InputUnicharsetFile == NULL) {
InputUnicharsetFile = kInputUnicharsetFile;
}
if (OutputUnicharsetFile == NULL) {
OutputUnicharsetFile = kOutputUnicharsetFile;
}
if (!unicharset_training.load_from_file(InputUnicharsetFile)) {
fprintf(stderr, "Failed to load unicharset from file %s\n"
"Building unicharset for mftraining from scratch...\n",
InputUnicharsetFile);
unicharset_training.clear();
// Space character needed to represent NIL classification.
unicharset_training.unichar_insert(" ");
}
if (InputFontInfoFile != NULL) {
FILE* f = fopen(InputFontInfoFile, "r");
if (f == NULL) {
fprintf(stderr, "Failed to load font_properties\n");
} else {
int italic, bold, fixed, serif, fraktur;
while (!feof(f)) {
FontInfo fontinfo;
fontinfo.name = new char[1024];
fontinfo.properties = 0;
if (fscanf(f, "%1024s %i %i %i %i %i\n", fontinfo.name,
&italic, &bold, &fixed, &serif, &fraktur) != 6)
continue;
fontinfo.properties =
(italic << 0) +
(bold << 1) +
(fixed << 2) +
(serif << 3) +
(fraktur << 4);
if (!classify.get_fontinfo_table().contains(fontinfo)) {
classify.get_fontinfo_table().push_back(fontinfo);
} else {
fprintf(stderr, "Font %s already defined\n", fontinfo.name);
return 1;
}
}
fclose(f);
}
}
while ((PageName = GetNextFilename(argc, argv)) != NULL) {
printf ("Reading %s ...\n", PageName);
char *short_name = strrchr(PageName, '/');
if (short_name == NULL)
short_name = PageName;
else
++short_name;
// filename is expected to be of the form [lang].[fontname].exp[num].tr
// If it is, then set short_name to be the [fontname]. Otherwise it is just
// the file basename with the .tr extension removed.
char *font_dot = strchr(short_name, '.');
char *exp_dot = (font_dot != NULL) ? strstr(font_dot, ".exp") : NULL;
if (font_dot != NULL && exp_dot != NULL && font_dot != exp_dot) {
short_name = new_dup(font_dot + 1);
short_name[exp_dot - font_dot - 1] = '\0';
} else {
short_name = new_dup(short_name);
int len = strlen(short_name);
if (!strcmp(short_name + len - 3, ".tr"))
short_name[len - 3] = '\0';
}
int fontinfo_id;
FontInfo fontinfo;
fontinfo.name = short_name;
fontinfo.properties = 0; // Not used to lookup in the table
if (!classify.get_fontinfo_table().contains(fontinfo)) {
fontinfo_id = classify.get_fontinfo_table().push_back(fontinfo);
printf("%s has no defined properties.\n", short_name);
} else {
fontinfo_id = classify.get_fontinfo_table().get_id(fontinfo);
// Update the properties field
fontinfo = classify.get_fontinfo_table().get(fontinfo_id);
delete[] short_name;
}
TrainingPage = Efopen (PageName, "r");
CharList = ReadTrainingSamples (TrainingPage);
fclose (TrainingPage);
//WriteTrainingSamples (Directory, CharList);
pCharList = CharList;
iterate(pCharList) {
//Cluster
CharSample = (LABELEDLIST) first_node (pCharList);
// printf ("\nClustering %s ...", CharSample->Label);
Clusterer = SetUpForClustering(CharSample, PROGRAM_FEATURE_TYPE);
Config.MagicSamples = CharSample->SampleCount;
ProtoList = ClusterSamples(Clusterer, &Config);
CleanUpUnusedData(ProtoList);
//Merge
MergeInsignificantProtos(ProtoList, CharSample->Label,
Clusterer, &Config);
if (strcmp(test_ch, CharSample->Label) == 0)
DisplayProtoList(test_ch, ProtoList);
ProtoList = RemoveInsignificantProtos(ProtoList, ShowSignificantProtos,
ShowInsignificantProtos,
Clusterer->SampleSize);
FreeClusterer(Clusterer);
MergeClass = FindClass (ClassList, CharSample->Label);
if (MergeClass == NULL) {
MergeClass = NewLabeledClass (CharSample->Label);
ClassList = push (ClassList, MergeClass);
}
Cid = AddConfigToClass(MergeClass->Class);
MergeClass->Class->font_set.push_back(fontinfo_id);
pProtoList = ProtoList;
iterate (pProtoList) {
Prototype = (PROTOTYPE *) first_node (pProtoList);
// see if proto can be approximated by existing proto
Pid = FindClosestExistingProto(MergeClass->Class,
MergeClass->NumMerged, Prototype);
if (Pid == NO_PROTO) {
Pid = AddProtoToClass (MergeClass->Class);
Proto = ProtoIn (MergeClass->Class, Pid);
MakeNewFromOld (Proto, Prototype);
MergeClass->NumMerged[Pid] = 1;
}
else {
MakeNewFromOld (&DummyProto, Prototype);
ComputeMergedProto (ProtoIn (MergeClass->Class, Pid), &DummyProto,
(FLOAT32) MergeClass->NumMerged[Pid], 1.0,
ProtoIn (MergeClass->Class, Pid));
MergeClass->NumMerged[Pid] ++;
}
Config2 = MergeClass->Class->Configurations[Cid];
AddProtoToConfig (Pid, Config2);
}
FreeProtoList (&ProtoList);
}
FreeTrainingSamples (CharList);
}
//WriteMergedTrainingSamples(Directory,ClassList);
WriteMicrofeat(Directory, ClassList);
SetUpForFloat2Int(ClassList);
IntTemplates = classify.CreateIntTemplates(TrainingData,
unicharset_training);
strcpy (Filename, "");
if (Directory != NULL) {
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "inttemp");
#ifdef __UNIX__
OutFile = Efopen (Filename, "w");
#else
OutFile = Efopen (Filename, "wb");
#endif
classify.WriteIntTemplates(OutFile, IntTemplates, unicharset_training);
fclose (OutFile);
strcpy (Filename, "");
if (Directory != NULL) {
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "pffmtable");
// Now create pffmtable.
WritePFFMTable(IntTemplates, Filename);
// Write updated unicharset to a file.
if (!unicharset_training.save_to_file(OutputUnicharsetFile)) {
fprintf(stderr, "Failed to save unicharset to file %s\n",
OutputUnicharsetFile);
exit(1);
}
printf ("Done!\n"); /**/
FreeLabeledClassList (ClassList);
return 0;
} /* main */
/**----------------------------------------------------------------------------
Private Code
----------------------------------------------------------------------------**/
/*---------------------------------------------------------------------------*/
LIST ReadTrainingSamples (
FILE *File)
/*
** Parameters:
** File open text file to read samples from
** Globals: none
** Operation:
** This routine reads training samples from a file and
** places them into a data structure which organizes the
** samples by FontName and CharName. It then returns this
** data structure.
** Return: none
** Exceptions: none
** History: Fri Aug 18 13:11:39 1989, DSJ, Created.
** Tue May 17 1998 simplifications to structure, illiminated
** font, and feature specification levels of structure.
*/
{
char unichar[UNICHAR_LEN + 1];
LABELEDLIST CharSample;
FEATURE_SET FeatureSamples;
LIST TrainingSamples = NIL;
CHAR_DESC CharDesc;
int Type, i;
while (fscanf (File, "%s %s", CTFontName, unichar) == 2) {
if (!unicharset_training.contains_unichar(unichar)) {
unicharset_training.unichar_insert(unichar);
if (unicharset_training.size() > MAX_NUM_CLASSES) {
cprintf("Error: Size of unicharset of mftraining is "
"greater than MAX_NUM_CLASSES\n");
exit(1);
}
}
CharSample = FindList (TrainingSamples, unichar);
if (CharSample == NULL) {
CharSample = NewLabeledList (unichar);
TrainingSamples = push (TrainingSamples, CharSample);
}
CharDesc = ReadCharDescription (File);
Type = ShortNameToFeatureType(PROGRAM_FEATURE_TYPE);
FeatureSamples = CharDesc->FeatureSets[Type];
for (int feature = 0; feature < FeatureSamples->NumFeatures; ++feature) {
FEATURE f = FeatureSamples->Features[feature];
for (int dim =0; dim < f->Type->NumParams; ++dim)
f->Params[dim] += dim == MFDirection ?
UniformRandomNumber(-MINSD_ANGLE, MINSD_ANGLE) :
UniformRandomNumber(-MINSD, MINSD);
}
CharSample->List = push (CharSample->List, FeatureSamples);
CharSample->SampleCount++;
for (i = 0; i < CharDesc->NumFeatureSets; i++)
if (Type != i)
FreeFeatureSet(CharDesc->FeatureSets[i]);
free (CharDesc);
}
return (TrainingSamples);
} /* ReadTrainingSamples */
/*----------------------------------------------------------------------------*/
void WriteClusteredTrainingSamples (
char *Directory,
LIST ProtoList,
CLUSTERER *Clusterer,
LABELEDLIST CharSample)
/*
** Parameters:
** Directory directory to place sample files into
** Operation:
** This routine writes the specified samples into files which
** are organized according to the font name and character name
** of the samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 16:17:06 1989, DSJ, Created.
*/
{
FILE *File;
char Filename[MAXNAMESIZE];
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, CTFontName);
strcat (Filename, "/");
strcat (Filename, CharSample->Label);
strcat (Filename, ".");
strcat (Filename, PROGRAM_FEATURE_TYPE);
strcat (Filename, ".p");
printf ("\nWriting %s ...", Filename);
File = Efopen (Filename, "w");
WriteProtoList(File, Clusterer->SampleSize, Clusterer->ParamDesc,
ProtoList, ShowSignificantProtos, ShowInsignificantProtos);
fclose (File);
} /* WriteClusteredTrainingSamples */
/*---------------------------------------------------------------------------*/
void WriteMergedTrainingSamples(
char *Directory,
LIST ClassList)
{
FILE *File;
char Filename[MAXNAMESIZE];
MERGE_CLASS MergeClass;
iterate (ClassList)
{
MergeClass = (MERGE_CLASS) first_node (ClassList);
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "Merged/");
strcat (Filename, MergeClass->Label);
strcat (Filename, PROTO_SUFFIX);
printf ("\nWriting Merged %s ...", Filename);
File = Efopen (Filename, "w");
WriteOldProtoFile (File, MergeClass->Class);
fclose (File);
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "Merged/");
strcat (Filename, MergeClass->Label);
strcat (Filename, CONFIG_SUFFIX);
printf ("\nWriting Merged %s ...", Filename);
File = Efopen (Filename, "w");
WriteOldConfigFile (File, MergeClass->Class);
fclose (File);
}
} // WriteMergedTrainingSamples
/*--------------------------------------------------------------------------*/
void WriteMicrofeat(
char *Directory,
LIST ClassList)
{
FILE *File;
char Filename[MAXNAMESIZE];
MERGE_CLASS MergeClass;
strcpy (Filename, "");
if (Directory != NULL)
{
strcat (Filename, Directory);
strcat (Filename, "/");
}
strcat (Filename, "Microfeat");
File = Efopen (Filename, "w");
printf ("\nWriting Merged %s ...", Filename);
iterate(ClassList)
{
MergeClass = (MERGE_CLASS) first_node (ClassList);
WriteProtos(File, MergeClass);
WriteConfigs(File, MergeClass->Class);
}
fclose (File);
} // WriteMicrofeat
/*---------------------------------------------------------------------------*/
void WriteProtos(
FILE* File,
MERGE_CLASS MergeClass)
{
float Values[3];
int i;
PROTO Proto;
fprintf(File, "%s\n", MergeClass->Label);
fprintf(File, "%d\n", MergeClass->Class->NumProtos);
for(i=0; i < MergeClass->Class->NumProtos; i++)
{
Proto = ProtoIn(MergeClass->Class,i);
fprintf(File, "\t%8.4f %8.4f %8.4f %8.4f ", Proto->X, Proto->Y,
Proto->Length, Proto->Angle);
Values[0] = Proto->X;
Values[1] = Proto->Y;
Values[2] = Proto->Angle;
Normalize(Values);
fprintf(File, "%8.4f %8.4f %8.4f\n", Values[0], Values[1], Values[2]);
}
} // WriteProtos
/*----------------------------------------------------------------------------*/
void WriteConfigs(
FILE* File,
CLASS_TYPE Class)
{
BIT_VECTOR Config;
int i, j, WordsPerConfig;
WordsPerConfig = WordsInVectorOfSize(Class->NumProtos);
fprintf(File, "%d %d\n", Class->NumConfigs,WordsPerConfig);
for(i=0; i < Class->NumConfigs; i++)
{
Config = Class->Configurations[i];
for(j=0; j < WordsPerConfig; j++)
fprintf(File, "%08x ", Config[j]);
fprintf(File, "\n");
}
fprintf(File, "\n");
} // WriteConfigs
/*--------------------------------------------------------------------------*/
void WritePFFMTable(INT_TEMPLATES Templates, const char* filename) {
FILE* fp = Efopen(filename, "wb");
/* then write out each class */
for (int i = 0; i < Templates->NumClasses; i++) {
INT_CLASS Class = ClassForClassId (Templates, i);
// Todo: Test with min instead of max
// int MaxLength = LengthForConfigId(Class, 0);
int MaxLength = 0;
const char *unichar = unicharset_training.id_to_unichar(i);
if (strcmp(unichar, " ") == 0) {
unichar = "NULL";
} else if (Class->NumConfigs == 0) {
cprintf("Error: no configs for class %s in mftraining\n", unichar);
}
for (int ConfigId = 0; ConfigId < Class->NumConfigs; ConfigId++) {
// Todo: Test with min instead of max
// if (LengthForConfigId (Class, ConfigId) < MaxLength)
if (Class->ConfigLengths[ConfigId] > MaxLength)
MaxLength = Class->ConfigLengths[ConfigId];
}
fprintf(fp, "%s %d\n", unichar, MaxLength);
}
fclose(fp);
} // WritePFFMTable

View File

@ -1,285 +0,0 @@
# Microsoft Developer Studio Project File - Name="mfTraining" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=mfTraining - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "mfTraining.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "mfTraining.mak" CFG="mfTraining - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "mfTraining - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "mfTraining - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "mfTraining - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "mftrain.Release6"
# PROP Intermediate_Dir "mftrain.Release6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../ccutil" /I "../ccstruct" /I "../classify" /I "../cutil" /I "../training" /I "../viewer" /I "../dict" /D "TRAINING" /D "WIN32" /D "_CONSOLE" /D "__NT__" /D "__MSW32__" /D "_AFXDLL" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ws2_32.lib /nologo /subsystem:console /profile /debug /machine:I386 /out:"./mfTraining.exe"
!ELSEIF "$(CFG)" == "mfTraining - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "mftrain.Debug6"
# PROP Intermediate_Dir "mftrain.Debug6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../ccutil" /I "../ccstruct" /I "../classify" /I "../cutil" /I "../training" /I "../viewer" /I "../dict" /D "_DEBUG" /D "TRAINING" /D "WIN32" /D "_CONSOLE" /D "__NT__" /D "__MSW32__" /D "_AFXDLL" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ws2_32.lib /nologo /subsystem:console /profile /debug /machine:I386 /out:"../bin.dbg6/mfTraining.exe"
!ENDIF
# Begin Target
# Name "mfTraining - Win32 Release"
# Name "mfTraining - Win32 Debug"
# Begin Source File
SOURCE=..\cutil\bitvec.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\clst.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\cluster.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\clusttool.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\cutil.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\danerror.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\debug.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\debugwin.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\efio.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\emalloc.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\errcode.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\featdefs.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\freelist.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\globaloc.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\globals.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\hashfn.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\intproto.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\kdtree.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\listio.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\memblk.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\memry.cpp
# End Source File
# Begin Source File
SOURCE=.\mergenf.cpp
!IF "$(CFG)" == "mfTraining - Win32 Release"
!ELSEIF "$(CFG)" == "mfTraining - Win32 Debug"
# SUBTRACT CPP /YX
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\ccutil\mfcpch.cpp
# End Source File
# Begin Source File
SOURCE=.\mfTraining.cpp
!IF "$(CFG)" == "mfTraining - Win32 Release"
!ELSEIF "$(CFG)" == "mfTraining - Win32 Debug"
# SUBTRACT CPP /YX
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\training\name2char.cpp
!IF "$(CFG)" == "mfTraining - Win32 Release"
!ELSEIF "$(CFG)" == "mfTraining - Win32 Debug"
# SUBTRACT CPP /YX
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\classify\ocrfeatures.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\oldheap.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\oldlist.cpp
# End Source File
# Begin Source File
SOURCE=..\classify\protos.cpp
# End Source File
# Begin Source File
SOURCE=..\viewer\scrollview.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\serialis.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\strngs.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\structures.cpp
# End Source File
# Begin Source File
SOURCE=..\viewer\svmnode.cpp
# End Source File
# Begin Source File
SOURCE=..\viewer\svutil.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\tessopt.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\tprintf.cpp
# End Source File
# Begin Source File
SOURCE=..\training\training.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\unichar.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharmap.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharset.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\varable.cpp
# End Source File
# Begin Source File
SOURCE=..\cutil\variables.cpp
# End Source File
# End Target
# End Project

View File

@ -44,10 +44,10 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict"
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict,../image"
PreprocessorDefinitions="_DEBUG;TRAINING;WIN32;_WINDOWS;__NT__;__MSW32__;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
RuntimeLibrary="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\mftrain.Debug/mftraining.pch"
AssemblerListingLocation=".\mftrain.Debug/"
ObjectFile=".\mftrain.Debug/"
@ -70,7 +70,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="user32.lib ws2_32.lib"
AdditionalDependencies="user32.lib ws2_32.lib ..\lib\leptonlib.lib"
OutputFile=".\../bin.dbg/mftraining.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
@ -107,12 +107,13 @@
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\."
OutputDirectory=".."
IntermediateDirectory=".\mftrain.Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@ -135,16 +136,16 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict"
AdditionalIncludeDirectories="../ccutil,../ccstruct,../classify,../cutil,../training,../viewer,../dict,../image"
PreprocessorDefinitions="TRAINING;WIN32;_WINDOWS;__NT__;__MSW32__;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="2"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\mftrain.Release/mftraining.pch"
AssemblerListingLocation=".\mftrain.Release/"
ObjectFile=".\mftrain.Release/"
ProgramDataBaseFileName=".\mftrain.Release/"
BrowseInformation="1"
BrowseInformation="0"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -161,8 +162,8 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="user32.lib ws2_32.lib"
OutputFile="mftraining.exe"
AdditionalDependencies="user32.lib ws2_32.lib ..\lib\leptonlib.lib"
OutputFile="..\mftraining.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="false"
@ -200,448 +201,8 @@
</References>
<Files>
<File
RelativePath="..\cutil\bitvec.cpp"
RelativePath=".\commontraining.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\clst.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\cluster.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\clusttool.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\cutil.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\danerror.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\debug.cpp"
>
</File>
<File
RelativePath="..\ccutil\debugwin.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\efio.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\emalloc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\errcode.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\featdefs.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\freelist.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\globaloc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\globals.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\hashfn.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\intproto.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\kdtree.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\listio.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memblk.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memry.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="mergenf.cpp"
@ -665,28 +226,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\mfcpch.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="mftraining.cpp"
>
@ -731,324 +270,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\ocrfeatures.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldheap.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldlist.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\classify\protos.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\scrollview.cpp"
>
</File>
<File
RelativePath="..\viewer\scrollview.h"
>
</File>
<File
RelativePath="..\ccutil\serialis.cpp"
>
</File>
<File
RelativePath="..\ccutil\strngs.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\structures.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\svmnode.cpp"
>
</File>
<File
RelativePath="..\viewer\svmnode.h"
>
</File>
<File
RelativePath="..\viewer\svutil.cpp"
>
</File>
<File
RelativePath="..\viewer\svutil.h"
>
</File>
<File
RelativePath="..\ccutil\tessopt.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tprintf.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="training.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unichar.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharmap.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharset.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\varable.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\variables.cpp"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -1,190 +0,0 @@
/*
** 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.
*/
#include "training.h"
#include "debug.h"
#include "memry.h"
#include "scrollview.h"
make_int_var (LearningDebugLevel, 0, MakeLearningDebugLevel,
18, 5, SetLearningDebugLevel,
"Learning Debug Level: ");
make_int_var (NormMethod, character, MakeNormMethod,
15, 10, SetNormMethod, "Normalization Method ...")
//char *demodir; /*demo home directory */
void cprintf( //Trace printf
const char *format,... //special message
)
{
}
char *c_alloc_string( //allocate string
inT32 count //no of chars required
)
{
return alloc_string(count);
}
void c_free_string( //free a string
char *string //string to free
)
{
free_string(string);
}
void *c_alloc_mem_p( //allocate permanent space
inT32 count //block size to allocate
)
{
return alloc_mem_p(count);
}
void *c_alloc_mem( //get some memory
inT32 count //no of bytes to get
)
{
return alloc_mem(count);
}
void c_free_mem( //free mem from alloc_mem
void *oldchunk //chunk to free
)
{
free_mem(oldchunk);
}
void c_check_mem( //check consistency
const char *string, //context message
inT8 level //level of check
)
{
check_mem(string,level);
}
void* c_alloc_struct( //allocate memory
inT32 count, //no of chars required
const char* name //class name
)
{
return alloc_struct(count,name);
}
void c_free_struct( //free a structure
void* deadstruct, //structure to free
inT32 count, //no of bytes
const char* name //class name
)
{
free_struct(deadstruct,count,name);
}
void c_make_current( /*move pen*/
void* win
)
{
ScrollView* window = (ScrollView*) win;
window->Update();
}
void reverse32(
void* ptr
)
{
char tmp;
char* cptr=(char*)ptr;
tmp=*cptr;
*cptr=*(cptr+3);
*(cptr+3)=tmp;
tmp=*(cptr+1);
*(cptr+1)=*(cptr+2);
*(cptr+2)=tmp;
}
void reverse16(
void* ptr
)
{
char tmp;
char* cptr=(char*)ptr;
tmp=*cptr;
*cptr=*(cptr+1);
*(cptr+1)=tmp;
}
ScrollView* c_create_window( /*create a window*/
const char *name, /*name/title of window*/
inT16 xpos, /*coords of window*/
inT16 ypos, /*coords of window*/
inT16 xsize, /*size of window*/
inT16 ysize, /*size of window*/
double xmin, /*scrolling limits*/
double xmax, /*to stop users*/
double ymin, /*getting lost in*/
double ymax /*empty space*/
)
{
return new ScrollView(name, xpos, ypos, xsize, ysize, xmin + xmax, ymin + ymax, true);
}
void c_line_color_index( /*set color*/
void* win,
C_COL index
)
{
// The colors are the same as the SV ones except that SV has COLOR:NONE --> offset of 1
ScrollView* window = (ScrollView*) win;
window->Pen((ScrollView::Color) (index + 1));
}
void c_move( /*move pen*/
void* win,
double x,
double y
)
{
ScrollView* window = (ScrollView*) win;
window->SetCursor((int) x, (int) y);
}
void c_draw( /*move pen*/
void* win,
double x,
double y
)
{
ScrollView* window = (ScrollView*) win;
window->DrawTo((int) x, (int) y);
}
void c_clear_window( /*move pen*/
void* win
)
{
ScrollView* window = (ScrollView*) win;
window->Clear();
}
char window_wait( /*move pen*/
void* win
)
{
ScrollView* window = (ScrollView*) win;
SVEvent* ev;
// Wait till an input event (all others are thrown away)
ev = window->AwaitEvent(SVET_ANY);
char ret = '\0';
if (ev->type == SVET_INPUT) { ret = ev->parameter[0]; }
delete ev;
return ret;
}

View File

@ -1,130 +0,0 @@
/*
** 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 TRAINING_H
#define TRAINING_H
#include "host.h"
#include "callcpp.h"
typedef enum
{
baseline, character
}
NORM_METHOD;
typedef struct
{
FLOAT32 x,y;
} FPOINT;
typedef FPOINT FVECTOR;
#define INTEL 0x4949
#define MOTO 0x4d4d
#define PICO_FEATURE_LENGTH (0.05)
#define GetPicoFeatureLength() (PICO_FEATURE_LENGTH)
extern int LearningDebugLevel;
extern int NormMethod;
void cprintf( //Trace printf
const char *format,... //special message
);
char *c_alloc_string( //allocate string
inT32 count //no of chars required
);
void c_free_string( //free a string
char *string //string to free
);
void *c_alloc_mem_p( //allocate permanent space
inT32 count //block size to allocate
);
void *c_alloc_mem( //get some memory
inT32 count //no of bytes to get
);
void c_free_mem( //free mem from alloc_mem
void *oldchunk //chunk to free
);
void c_check_mem( //check consistency
char *string, //context message
inT8 level //level of check
);
void* c_alloc_struct( //allocate memory
inT32 count, //no of chars required
const char* name //class name
);
void c_free_struct( //free a structure
void* deadstruct, //structure to free
inT32 count, //no of bytes
const char* name //class name
);
void c_make_current( /*move pen*/
void* win
);
void reverse32(
void* ptr
);
void reverse16(
void* ptr
);
ScrollView* c_create_window( /*create a window*/
const char *name, /*name/title of window*/
inT16 xpos, /*coords of window*/
inT16 ypos, /*coords of window*/
inT16 xsize, /*size of window*/
inT16 ysize, /*size of window*/
double xmin, /*scrolling limits*/
double xmax, /*to stop users*/
double ymin, /*getting lost in*/
double ymax /*empty space*/
);
void c_line_color_index( /*set color*/
void* win,
C_COL index
);
void c_move( /*move pen*/
void* win,
double x,
double y
);
void c_draw( /*move pen*/
void* win,
double x,
double y
);
void c_clear_window( /*move pen*/
void* win
);
char window_wait( /*move pen*/
void* win
);
#endif

View File

@ -45,6 +45,14 @@
static const char* const kUnicharsetFileName = "unicharset";
UNICHAR_ID wc_to_unichar_id(const UNICHARSET &unicharset, int wc) {
UNICHAR uch(wc);
char *unichar = uch.utf8_str();
UNICHAR_ID unichar_id = unicharset.unichar_to_id(unichar);
delete[] unichar;
return unichar_id;
}
// Set character properties using wctype if we have it.
// Contributed by piggy@gmail.com.
// Modified by Ray to use UNICHAR for unicode conversion
@ -57,24 +65,36 @@ void set_properties(UNICHARSET *unicharset, const char* const c_string) {
// Convert the string to a unichar id.
id = unicharset->unichar_to_id(c_string);
// Set the other_case property to be this unichar id by default.
unicharset->set_other_case(id, id);
int step = UNICHAR::utf8_step(c_string);
if (step == 0)
return; // Invalid utf-8.
// Get the next Unicode cond point in the string.
// Get the next Unicode code point in the string.
UNICHAR ch(c_string, step);
wc = ch.first_uni();
/* Copy the properties. */
if (iswalpha(wc)) {
unicharset->set_isalpha(id, 1);
if (iswlower(wc))
if (iswlower(wc)) {
unicharset->set_islower(id, 1);
if (iswupper(wc))
unicharset->set_other_case(id, wc_to_unichar_id(*unicharset,
towupper(wc)));
}
if (iswupper(wc)) {
unicharset->set_isupper(id, 1);
unicharset->set_other_case(id, wc_to_unichar_id(*unicharset,
towlower(wc)));
}
}
if (iswdigit(wc))
unicharset->set_isdigit(id, 1);
if(iswpunct(wc))
unicharset->set_ispunctuation(id, 1);
#endif
}

View File

@ -1,335 +0,0 @@
# Microsoft Developer Studio Project File - Name="unicharset_extractor" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=unicharset_extractor - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "unicharset_extractor.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "unicharset_extractor.mak" CFG="unicharset_extractor - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "unicharset_extractor - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "unicharset_extractor - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "unicharset_extractor - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "uce.Release6"
# PROP Intermediate_Dir "uce.Release6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../ccutil" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__MSW32__" /D "_AFXDLL" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 /nologo /subsystem:console /machine:I386 /out:"./unicharset_extractor.exe"
!ELSEIF "$(CFG)" == "unicharset_extractor - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "uce.Debug6"
# PROP Intermediate_Dir "uce.Debug6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../ccutil" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__MSW32__" /D "_AFXDLL" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /out:"../bin.dbg6/unicharset_extractor.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "unicharset_extractor - Win32 Release"
# Name "unicharset_extractor - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Group "ccutil"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\ccutil\clst.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\debugwin.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\errcode.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\globaloc.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\hashfn.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\memblk.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\memry.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\mfcpch.cpp
# ADD CPP /Yc"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\serialis.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\strngs.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\tessopt.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\tprintf.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\unichar.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharmap.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharset.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\ccutil\varable.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# End Group
# Begin Source File
SOURCE=..\ccutil\boxread.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=.\unicharset_extractor.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\ccutil\basedir.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\bits16.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\clst.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\debugwin.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\elst.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\elst2.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\errcode.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\fileerr.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\globaloc.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\hashfn.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\host.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\hosthplb.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\lsterr.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\mainblk.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\memblk.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\memry.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\memryerr.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\mfcpch.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\ndminx.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\notdll.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\nwmain.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\ocrclass.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\ocrshell.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\platform.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\scanutils.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\secname.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\serialis.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\stderr.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\strngs.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\tessclas.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\tessopt.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\tprintf.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\unichar.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharmap.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharset.h
# End Source File
# Begin Source File
SOURCE=..\ccutil\varable.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -17,13 +17,14 @@
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\."
OutputDirectory=".."
IntermediateDirectory=".\uce.Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@ -72,7 +73,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="user32.lib"
OutputFile=".\./unicharset_extractor.exe"
OutputFile="..\unicharset_extractor.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\./unicharset_extractor.pdb"
@ -204,10 +205,6 @@
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\ccutil\serialis.cpp"
>
</File>
<File
RelativePath="unicharset_extractor.cpp"
>
@ -230,385 +227,15 @@
/>
</FileConfiguration>
</File>
<Filter
Name="ccutil"
>
<File
RelativePath="..\ccutil\boxread.cpp"
>
</File>
<File
RelativePath="..\ccutil\clst.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\debugwin.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\errcode.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\globaloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\hashfn.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memblk.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memry.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\mfcpch.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\strngs.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tessopt.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tprintf.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="mfcpch.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unichar.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharmap.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharset.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\varable.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\ccutil\ambigs.h"
>
</File>
<File
RelativePath="..\ccutil\basedir.h"
>
@ -621,6 +248,10 @@
RelativePath="..\ccutil\boxread.h"
>
</File>
<File
RelativePath="..\ccutil\ccutil.h"
>
</File>
<File
RelativePath="..\ccutil\clst.h"
>

View File

@ -22,48 +22,54 @@
#include <stdio.h>
#include "classify.h"
#include "dawg.h"
#include "makedawg.h"
#include "lookdawg.h"
#include "reduce.h"
#include "freelist.h"
#include "emalloc.h"
#include "freelist.h"
#include "trie.h"
#include "unicharset.h"
static const int kMaxNumEdges = 10000000;
int main(int argc, char** argv) {
if (argc == 3) {
const char* wordlist_filename = argv[1];
const char* dawg_filename = argv[2];
EDGE_ARRAY dawg;
inT32 max_num_edges = 10000000;
inT32 reserved_edges = 1000000;
dawg = (EDGE_ARRAY) Emalloc(sizeof (EDGE_RECORD) * max_num_edges);
if (dawg == NULL) {
printf("error: Could not allocate enough memory for DAWG ");
printf("(%d ,%d bytes needed)\n",
static_cast<int>(sizeof (EDGE_RECORD) * max_num_edges / 1000),
static_cast<int>(sizeof (EDGE_RECORD) * max_num_edges % 1000));
if (!(argc == 4 || (argc == 5 && strcmp(argv[1], "-t") == 0))) {
printf("Usage: %s [-t] word_list_file dawg_file unicharset_file", argv[0]);
return 1;
}
tesseract::Classify classify;
int argv_index = 0;
if (argc == 5) ++argv_index;
const char* wordlist_filename = argv[++argv_index];
const char* dawg_filename = argv[++argv_index];
const char* unicharset_file = argv[++argv_index];
if (!classify.getDict().getUnicharset().load_from_file(unicharset_file)) {
tprintf("Failed to load unicharset from '%s'\n", unicharset_file);
return 1;
}
const UNICHARSET &unicharset = classify.getDict().getUnicharset();
if (argc == 4) {
tesseract::Trie trie(
// the first 3 arguments are not used in this case
tesseract::DAWG_TYPE_WORD, "", SYSTEM_DAWG_PERM,
kMaxNumEdges, unicharset.size());
printf("Reading word list from '%s'\n", wordlist_filename);
if (!trie.read_word_list(wordlist_filename, unicharset)) {
printf("Failed to read word list from '%s'\n", wordlist_filename);
exit(1);
}
printf("Building DAWG from word list in file, '%s'\n", wordlist_filename);
read_word_list(wordlist_filename, dawg, max_num_edges, reserved_edges);
trie_to_dawg(dawg, max_num_edges, reserved_edges);
printf("Writing squished DAWG file, '%s'\n", dawg_filename);
write_squished_dawg(dawg_filename, dawg, max_num_edges, reserved_edges);
return 0;
} else if (argc == 4 && strcmp(argv[1], "-t") == 0) {
EDGE_ARRAY words = read_squished_dawg(argv[3]);
check_for_words(words, argv[2]);
memfree(words);
return 0;
printf("Reducing Trie to SquishedDawg\n");
tesseract::SquishedDawg *dawg = trie.trie_to_dawg();
printf("Writing squished DAWG to '%s'\n", dawg_filename);
dawg->write_squished_dawg(dawg_filename);
delete dawg;
} else {
printf("Loading dawg DAWG from '%s'\n", dawg_filename);
tesseract::SquishedDawg words(
dawg_filename,
// these 3 arguments are not used in this case
tesseract::DAWG_TYPE_WORD, "", SYSTEM_DAWG_PERM);
printf("Checking word list from '%s'\n", wordlist_filename);
words.check_for_words(wordlist_filename, unicharset, true);
}
printf("Usage: %s [-t] word_list_file dawg_file\n", argv[0]);
return 1;
return 0;
}

View File

@ -1,319 +0,0 @@
# Microsoft Developer Studio Project File - Name="wordlist2dawg" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=wordlist2dawg - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wordlist2dawg.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wordlist2dawg.mak" CFG="wordlist2dawg - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wordlist2dawg - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "wordlist2dawg - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "wordlist2dawg - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "w2d.Release6"
# PROP Intermediate_Dir "w2d.Release6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../ccutil" /I "../cutil" /I "../dict" /I "../viewer" /I "../ccstruct" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__MSW32__" /D "_AFXDLL" /Yu"mfcpch.h" /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 /out:"./wordlist2dawg.exe"
!ELSEIF "$(CFG)" == "wordlist2dawg - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "w2d.Debug6"
# PROP Intermediate_Dir "w2d.Debug6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../ccutil" /I "../cutil" /I "../dict" /I "../viewer" /I "../ccstruct" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__MSW32__" /D "_AFXDLL" /Yu"mfcpch.h" /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin.dbg6/wordlist2dawg.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "wordlist2dawg - Win32 Release"
# Name "wordlist2dawg - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Group "ccutil"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\ccutil\clst.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\debugwin.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\errcode.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\globaloc.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\hashfn.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\memblk.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\memry.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\mfcpch.cpp
# ADD CPP /Yc"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\serialis.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\strngs.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\tessopt.cpp
# End Source File
# Begin Source File
SOURCE=..\ccutil\tprintf.cpp
# ADD CPP /Yu"mfcpch.h"
# End Source File
# Begin Source File
SOURCE=..\ccutil\unichar.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharmap.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\ccutil\unicharset.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\ccutil\varable.cpp
# End Source File
# End Group
# Begin Group "cutil"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\cutil\cutil.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\danerror.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\debug.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\emalloc.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\freelist.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\globals.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\listio.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\oldlist.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\structures.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\tordvars.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\cutil\variables.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# End Group
# Begin Group "dict"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\dict\context.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\dict\dawg.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\dict\lookdawg.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\dict\makedawg.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\dict\reduce.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\dict\trie.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# End Group
# Begin Group "ccstruct"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\ccstruct\callcpp.cpp
# End Source File
# End Group
# Begin Group "viewer"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\viewer\scrollview.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\viewer\svmnode.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\viewer\svutil.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# End Group
# Begin Source File
SOURCE=.\wordlist2dawg.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\viewer\grphics.h
# End Source File
# Begin Source File
SOURCE=..\dict\lookdawg.h
# End Source File
# Begin Source File
SOURCE=..\dict\makedawg.h
# End Source File
# Begin Source File
SOURCE=..\dict\reduce.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -17,13 +17,14 @@
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\."
OutputDirectory=".."
IntermediateDirectory=".\w2d.Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@ -46,7 +47,7 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../ccutil,../cutil,../dict,../viewer,../ccstruct"
AdditionalIncludeDirectories="../ccutil,../cutil,../dict,../viewer,../ccstruct,../image,../classify"
PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;__MSW32__;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="0"
@ -73,12 +74,13 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib user32.lib"
OutputFile=".\./wordlist2dawg.exe"
AdditionalDependencies="ws2_32.lib user32.lib ..\lib\leptonlib.lib"
OutputFile="..\wordlist2dawg.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\./wordlist2dawg.pdb"
SubSystem="1"
OptimizeReferences="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
@ -137,7 +139,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../ccutil,../cutil,../dict,../viewer,../ccstruct"
AdditionalIncludeDirectories="../ccutil,../cutil,../dict,../viewer,../ccstruct,../image,../classify"
PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;__MSW32__;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -165,7 +167,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib user32.lib"
AdditionalDependencies="ws2_32.lib user32.lib ..\lib\leptonlib.lib"
OutputFile=".\../bin.dbg/wordlist2dawg.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
@ -208,66 +210,6 @@
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\dict\lookdawg.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dict\makedawg.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dict\reduce.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="wordlist2dawg.cpp"
>
@ -292,799 +234,51 @@
/>
</FileConfiguration>
</File>
<Filter
Name="ccutil"
>
<File
RelativePath="..\ccutil\clst.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\debugwin.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\errcode.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\globaloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\hashfn.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memblk.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\memry.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\mfcpch.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\serialis.cpp"
>
</File>
<File
RelativePath="..\ccutil\strngs.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tessopt.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\tprintf.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unichar.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharmap.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\unicharset.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ccutil\varable.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="cutil"
>
<File
RelativePath="..\cutil\cutil.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\danerror.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\debug.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\emalloc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\freelist.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\globals.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\listio.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\oldlist.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\structures.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\tordvars.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\cutil\variables.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="dict"
>
<File
RelativePath="..\dict\context.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dict\dawg.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dict\trie.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="ccstruct"
>
<File
RelativePath="..\ccstruct\callcpp.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="viewer"
>
<File
RelativePath="..\viewer\scrollview.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\scrollview.h"
>
</File>
<File
RelativePath="..\viewer\svmnode.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\svmnode.h"
>
</File>
<File
RelativePath="..\viewer\svutil.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\viewer\svutil.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\classify\adaptmatch.h"
>
</File>
<File
RelativePath="..\ccutil\ambigs.h"
>
</File>
<File
RelativePath="..\ccstruct\ccstruct.h"
>
</File>
<File
RelativePath="..\ccutil\ccutil.h"
>
</File>
<File
RelativePath="..\classify\classify.h"
>
</File>
<File
RelativePath="..\cutil\cutil_class.h"
>
</File>
<File
RelativePath="..\dict\dict.h"
>
</File>
<File
RelativePath="..\ccutil\elst.h"
>
</File>
<File
RelativePath="..\viewer\grphics.h"
>
</File>
<File
RelativePath="..\image\image.h"
>
</File>
<File
RelativePath="..\dict\lookdawg.h"
>
@ -1093,6 +287,10 @@
RelativePath="..\dict\makedawg.h"
>
</File>
<File
RelativePath="..\ccstruct\ratngs.h"
>
</File>
<File
RelativePath="..\dict\reduce.h"
>

File diff suppressed because it is too large Load Diff