diff --git a/classify/adaptive.cpp b/classify/adaptive.cpp index 324fbd144..3e6023bc3 100644 --- a/classify/adaptive.cpp +++ b/classify/adaptive.cpp @@ -69,7 +69,7 @@ int AddAdaptedClass(ADAPT_TEMPLATES Templates, /*---------------------------------------------------------------------------*/ -void FreeTempConfig(TEMP_CONFIG Config) { +void FreeTempConfig(TEMP_CONFIG Config) { /* ** Parameters: ** Config config to be freed @@ -90,7 +90,7 @@ void FreeTempConfig(TEMP_CONFIG Config) { /*---------------------------------------------------------------------------*/ -void FreeTempProto(void *arg) { +void FreeTempProto(void *arg) { PROTO proto = (PROTO) arg; c_free_struct (proto, sizeof (TEMP_PROTO_STRUCT), "TEMP_PROTO_STRUCT"); @@ -98,7 +98,7 @@ void FreeTempProto(void *arg) { /*---------------------------------------------------------------------------*/ -ADAPT_CLASS NewAdaptedClass() { +ADAPT_CLASS NewAdaptedClass() { /* ** Parameters: none ** Globals: none @@ -129,7 +129,7 @@ ADAPT_CLASS NewAdaptedClass() { /*-------------------------------------------------------------------------*/ -void free_adapted_class(ADAPT_CLASS adapt_class) { +void free_adapted_class(ADAPT_CLASS adapt_class) { int i; for (i = 0; i < MAX_NUM_CONFIGS; i++) { @@ -143,12 +143,12 @@ void free_adapted_class(ADAPT_CLASS adapt_class) { FreeBitVector (adapt_class->PermProtos); FreeBitVector (adapt_class->PermConfigs); destroy_nodes (adapt_class->TempProtos, FreeTempProto); - Efree(adapt_class); + Efree(adapt_class); } /*---------------------------------------------------------------------------*/ -ADAPT_TEMPLATES NewAdaptedTemplates() { +ADAPT_TEMPLATES NewAdaptedTemplates() { /* ** Parameters: none ** Globals: none @@ -174,20 +174,20 @@ ADAPT_TEMPLATES NewAdaptedTemplates() { /*-------------------------------------------------------------------------------*/ -void free_adapted_templates(ADAPT_TEMPLATES templates) { +void free_adapted_templates(ADAPT_TEMPLATES templates) { if (templates != NULL) { int i; for (i = 0; i < NumClassesIn (templates->Templates); i++) free_adapted_class (templates->Class[i]); free_int_templates (templates->Templates); - Efree(templates); + Efree(templates); } } /*---------------------------------------------------------------------------*/ -TEMP_CONFIG NewTempConfig(int MaxProtoId) { +TEMP_CONFIG NewTempConfig(int MaxProtoId) { /* ** Parameters: ** MaxProtoId max id of any proto in new config @@ -218,7 +218,7 @@ TEMP_CONFIG NewTempConfig(int MaxProtoId) { /*---------------------------------------------------------------------------*/ -TEMP_PROTO NewTempProto() { +TEMP_PROTO NewTempProto() { /* ** Parameters: none ** Globals: none @@ -233,7 +233,7 @@ TEMP_PROTO NewTempProto() { /*---------------------------------------------------------------------------*/ -void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { +void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { /* ** Parameters: ** File open text file to print Templates to @@ -273,7 +273,7 @@ void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { /*---------------------------------------------------------------------------*/ -ADAPT_CLASS ReadAdaptedClass(FILE *File) { +ADAPT_CLASS ReadAdaptedClass(FILE *File) { /* ** Parameters: ** File open file to read adapted class from @@ -327,7 +327,7 @@ ADAPT_CLASS ReadAdaptedClass(FILE *File) { /*---------------------------------------------------------------------------*/ -ADAPT_TEMPLATES ReadAdaptedTemplates(FILE *File) { +ADAPT_TEMPLATES ReadAdaptedTemplates(FILE *File) { /* ** Parameters: ** File open text file to read adapted templates from @@ -358,7 +358,7 @@ ADAPT_TEMPLATES ReadAdaptedTemplates(FILE *File) { /*---------------------------------------------------------------------------*/ -PERM_CONFIG ReadPermConfig(FILE *File) { +PERM_CONFIG ReadPermConfig(FILE *File) { /* ** Parameters: ** File open file to read permanent config from @@ -383,7 +383,7 @@ PERM_CONFIG ReadPermConfig(FILE *File) { /*---------------------------------------------------------------------------*/ -TEMP_CONFIG ReadTempConfig(FILE *File) { +TEMP_CONFIG ReadTempConfig(FILE *File) { /* ** Parameters: ** File open file to read temporary config from @@ -411,7 +411,7 @@ TEMP_CONFIG ReadTempConfig(FILE *File) { /*---------------------------------------------------------------------------*/ -void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) { +void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) { /* ** Parameters: ** File open file to write Class to @@ -442,7 +442,7 @@ void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) { fwrite ((char *) &NumTempProtos, sizeof (int), 1, File); TempProtos = Class->TempProtos; iterate (TempProtos) { - void* proto = first(TempProtos); + void* proto = first_node(TempProtos); fwrite ((char *) proto, sizeof (TEMP_PROTO_STRUCT), 1, File); } @@ -458,7 +458,7 @@ void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) { /*---------------------------------------------------------------------------*/ -void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { +void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { /* ** Parameters: ** File open text file to write Templates to @@ -487,7 +487,7 @@ void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { /*---------------------------------------------------------------------------*/ -void WritePermConfig(FILE *File, PERM_CONFIG Config) { +void WritePermConfig(FILE *File, PERM_CONFIG Config) { /* ** Parameters: ** File open file to write Config to @@ -511,7 +511,7 @@ void WritePermConfig(FILE *File, PERM_CONFIG Config) { /*---------------------------------------------------------------------------*/ -void WriteTempConfig(FILE *File, TEMP_CONFIG Config) { +void WriteTempConfig(FILE *File, TEMP_CONFIG Config) { /* ** Parameters: ** File open file to write Config to diff --git a/classify/cluster.cpp b/classify/cluster.cpp index c88749f64..05ec304b9 100644 --- a/classify/cluster.cpp +++ b/classify/cluster.cpp @@ -551,7 +551,7 @@ void FreeClusterer(CLUSTERER *Clusterer) { if (Clusterer->Root != NULL) FreeCluster (Clusterer->Root); iterate (Clusterer->ProtoList) { - ((PROTOTYPE *) (first (Clusterer->ProtoList)))->Cluster = NULL; + ((PROTOTYPE *) (first_node (Clusterer->ProtoList)))->Cluster = NULL; } memfree(Clusterer); } @@ -629,7 +629,7 @@ CLUSTER *NextSample(LIST *SearchState) { if (*SearchState == NIL) return (NULL); - Cluster = (CLUSTER *) first (*SearchState); + Cluster = (CLUSTER *) first_node (*SearchState); *SearchState = pop (*SearchState); while (TRUE) { if (Cluster->Left == NULL) @@ -971,7 +971,7 @@ void ComputePrototypes(CLUSTERER *Clusterer, CLUSTERCONFIG *Config) { // remove the next cluster to be analyzed from the stack // try to make a prototype from the cluster // if successful, put it on the proto list, else split the cluster - Cluster = (CLUSTER *) first (ClusterStack); + Cluster = (CLUSTER *) first_node (ClusterStack); ClusterStack = pop (ClusterStack); Prototype = MakePrototype (Clusterer, Config, Cluster); if (Prototype != NULL) { @@ -1709,7 +1709,7 @@ BUCKETS *GetBuckets(DISTRIBUTION Distribution, // search for an old bucket structure with the same number of buckets NumberOfBuckets = OptimumNumberOfBuckets (SampleCount); - Buckets = (BUCKETS *) first (search (OldBuckets[(int) Distribution], + Buckets = (BUCKETS *) first_node (search (OldBuckets[(int) Distribution], &NumberOfBuckets, NumBucketsMatch)); // if a matching bucket structure is found, delete it from the list @@ -1922,7 +1922,7 @@ ComputeChiSquared (UINT16 DegreesOfFreedom, FLOAT64 Alpha) for the specified number of degrees of freedom. Search the list for the desired chi-squared. */ SearchKey.Alpha = Alpha; - OldChiSquared = (CHISTRUCT *) first (search (ChiWith[DegreesOfFreedom], + OldChiSquared = (CHISTRUCT *) first_node (search (ChiWith[DegreesOfFreedom], &SearchKey, AlphaMatch)); if (OldChiSquared == NULL) { @@ -2782,5 +2782,3 @@ double InvertMatrix(const float* input, int size, float* inv) { } return error_sum; } - - diff --git a/classify/clusttool.cpp b/classify/clusttool.cpp index 70e588ef0..50e682311 100644 --- a/classify/clusttool.cpp +++ b/classify/clusttool.cpp @@ -43,7 +43,7 @@ Return: Sample size Exceptions: ILLEGALSAMPLESIZE illegal format or range History: 6/6/89, DSJ, Created. ******************************************************************************/ -UINT16 ReadSampleSize(FILE *File) { +UINT16 ReadSampleSize(FILE *File) { int SampleSize; if ((fscanf (File, "%d", &SampleSize) != 1) || @@ -65,11 +65,11 @@ Exceptions: ILLEGALCIRCULARSPEC ILLEGALMINMAXSPEC History: 6/6/89, DSJ, Created. ******************************************************************************/ -PARAM_DESC *ReadParamDesc(FILE *File, UINT16 N) { +PARAM_DESC *ReadParamDesc(FILE *File, UINT16 N) { int i; PARAM_DESC *ParamDesc; char Token[TOKENSIZE]; - + ParamDesc = (PARAM_DESC *) Emalloc (N * sizeof (PARAM_DESC)); for (i = 0; i < N; i++) { if (fscanf (File, "%s", Token) != 1) @@ -80,7 +80,7 @@ PARAM_DESC *ReadParamDesc(FILE *File, UINT16 N) { else ParamDesc[i].Circular = FALSE; - if (fscanf (File, "%s", Token) != 1) + if (fscanf (File, "%s", Token) != 1) DoError (ILLEGALESSENTIALSPEC, "Illegal essential/non-essential spec"); if (Token[0] == 'e') @@ -112,7 +112,7 @@ Exceptions: ILLEGALSIGNIFICANCESPEC ILLEGALDISTRIBUTION History: 6/6/89, DSJ, Created. ******************************************************************************/ -PROTOTYPE *ReadPrototype(FILE *File, UINT16 N) { +PROTOTYPE *ReadPrototype(FILE *File, UINT16 N) { char Token[TOKENSIZE]; int Status; PROTOTYPE *Proto; @@ -144,7 +144,7 @@ PROTOTYPE *ReadPrototype(FILE *File, UINT16 N) { Proto->Magnitude.Spherical = 1.0 / sqrt ((double) (2.0 * PI * Proto->Variance.Spherical)); Proto->TotalMagnitude = - pow (Proto->Magnitude.Spherical, (double) N); + pow (Proto->Magnitude.Spherical, (float) N); Proto->LogMagnitude = log ((double) Proto->TotalMagnitude); Proto->Weight.Spherical = 1.0 / Proto->Variance.Spherical; Proto->Distrib = NULL; @@ -239,7 +239,7 @@ Return: Prototype style read from text file Exceptions: ILLEGALSTYLESPEC illegal prototype style specification History: 6/8/89, DSJ, Created. *******************************************************************************/ -PROTOSTYLE ReadProtoStyle(FILE *File) { +PROTOSTYLE ReadProtoStyle(FILE *File) { char Token[TOKENSIZE]; PROTOSTYLE Style; @@ -343,7 +343,7 @@ Return: None Exceptions: None History: 6/12/89, DSJ, Created. *******************************************************************************/ -void WritePrototype(FILE *File, UINT16 N, PROTOTYPE *Proto) { +void WritePrototype(FILE *File, UINT16 N, PROTOTYPE *Proto) { int i; if (Proto->Significant) @@ -413,7 +413,7 @@ Return: None Exceptions: None History: 6/8/89, DSJ, Created. ****************************************************************************/ -void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle) { +void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle) { switch (ProtoStyle) { case spherical: fprintf (File, "spherical"); @@ -438,7 +438,7 @@ void WriteProtoList( LIST ProtoList, BOOL8 WriteSigProtos, BOOL8 WriteInsigProtos) - + /* ** Parameters: ** File open text file to write prototypes to @@ -464,7 +464,7 @@ void WriteProtoList( { PROTOTYPE *Proto; - + /* write file header */ fprintf(File,"%0d\n",N); WriteParamDesc(File,N,ParamDesc); @@ -472,7 +472,7 @@ void WriteProtoList( /* write prototypes */ iterate(ProtoList) { - Proto = (PROTOTYPE *) first ( ProtoList ); + Proto = (PROTOTYPE *) first_node ( ProtoList ); if (( Proto->Significant && WriteSigProtos ) || ( ! Proto->Significant && WriteInsigProtos ) ) WritePrototype( File, N, Proto ); @@ -489,8 +489,8 @@ Return: Uniform random number Exceptions: None History: 6/6/89, DSJ, Created. *******************************************************************************/ -FLOAT32 UniformRandomNumber(FLOAT32 MMin, FLOAT32 MMax) { - double fake_drand48(); +FLOAT32 UniformRandomNumber(FLOAT32 MMin, FLOAT32 MMax) { + double fake_drand48(); FLOAT32 RandomNumber; RandomNumber = fake_drand48 (); @@ -502,6 +502,6 @@ FLOAT32 UniformRandomNumber(FLOAT32 MMin, FLOAT32 MMax) { Cheap replacement for drand48 which is not available on the PC. **********************************************************************/ -double fake_drand48() { +double fake_drand48() { return rand () / (RAND_MAX + 1.0); } diff --git a/classify/mfdefs.h b/classify/mfdefs.h index b0873b34b..65d98c445 100644 --- a/classify/mfdefs.h +++ b/classify/mfdefs.h @@ -56,12 +56,12 @@ typedef FLOAT32 *MICROFEATURE; #define SecondBulgeOf(M) ( (M)[SECONDBULGE] ) /* macros for accessing micro-feature lists */ -#define NextFeatureOf(L) ( (MICROFEATURE) first( L ) ) +#define NextFeatureOf(L) ( (MICROFEATURE) first_node ( L ) ) /**---------------------------------------------------------------------------- Public Function Prototypes ----------------------------------------------------------------------------**/ -MICROFEATURE NewMicroFeature(); +MICROFEATURE NewMicroFeature(); -void FreeMicroFeatures(MICROFEATURES MicroFeatures); +void FreeMicroFeatures(MICROFEATURES MicroFeatures); #endif diff --git a/classify/mfoutline.cpp b/classify/mfoutline.cpp index 8ea44bf16..80a149c9b 100644 --- a/classify/mfoutline.cpp +++ b/classify/mfoutline.cpp @@ -105,7 +105,7 @@ make_float_var (MaxNormScaleY, 0.325, MakeMaxNormScaleY, Public Code ----------------------------------------------------------------------------**/ /*---------------------------------------------------------------------------*/ -void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter) { +void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter) { /* ** Parameters: ** Blob blob to compute centerpoint of @@ -124,7 +124,7 @@ void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter) { TPOINT TopLeft; TPOINT BottomRight; - blob_bounding_box(Blob, &TopLeft, &BottomRight); + blob_bounding_box(Blob, &TopLeft, &BottomRight); BlobCenter->x = ((TopLeft.x << VECSCALE) + (BottomRight.x << VECSCALE)) / 2; BlobCenter->y = ((TopLeft.y << VECSCALE) + (BottomRight.y << VECSCALE)) / 2; @@ -133,7 +133,7 @@ void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter) { /*---------------------------------------------------------------------------*/ -LIST ConvertBlob(TBLOB *Blob) { +LIST ConvertBlob(TBLOB *Blob) { /* ** Parameters: ** Blob blob to be converted @@ -156,7 +156,7 @@ LIST ConvertBlob(TBLOB *Blob) { /*---------------------------------------------------------------------------*/ -MFOUTLINE ConvertOutline(TESSLINE *Outline) { +MFOUTLINE ConvertOutline(TESSLINE *Outline) { /* ** Parameters: ** Outline outline to be converted @@ -207,7 +207,7 @@ MFOUTLINE ConvertOutline(TESSLINE *Outline) { if (EdgePoint->pos.x != NextPoint->pos.x || EdgePoint->pos.y != NextPoint->pos.y) { NewPoint = NewEdgePoint (); - ClearMark(NewPoint); + ClearMark(NewPoint); IsHidden (NewPoint) = is_hidden_edge (EdgePoint) ? TRUE : FALSE; XPositionOf (NewPoint) = EdgePoint->pos.x; YPositionOf (NewPoint) = EdgePoint->pos.y; @@ -225,7 +225,7 @@ MFOUTLINE ConvertOutline(TESSLINE *Outline) { do { if (Vector->dx != 0 || Vector->dy != 0) { NewPoint = NewEdgePoint (); - ClearMark(NewPoint); + ClearMark(NewPoint); /* all edges are visible */ IsHidden (NewPoint) = FALSE; CopyPoint (Position, PositionOf (NewPoint)); @@ -248,7 +248,7 @@ MFOUTLINE ConvertOutline(TESSLINE *Outline) { if (EdgePoint->pos.x != NextPoint->pos.x || EdgePoint->pos.y != NextPoint->pos.y) { NewPoint = NewEdgePoint (); - ClearMark(NewPoint); + ClearMark(NewPoint); IsHidden (NewPoint) = is_hidden_edge (EdgePoint) ? TRUE : FALSE; XPositionOf (NewPoint) = (EdgePoint->pos.x + BlobCenter.x) / REALSCALE; @@ -261,7 +261,7 @@ MFOUTLINE ConvertOutline(TESSLINE *Outline) { while (EdgePoint != StartPoint); } - MakeOutlineCircular(MFOutline); + MakeOutlineCircular(MFOutline); return (MFOutline); } /* ConvertOutline */ @@ -308,7 +308,7 @@ LIST ConvertOutlines(TESSLINE *Outline, /*---------------------------------------------------------------------------*/ -void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats) { +void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats) { /* ** Parameters: ** Outlines list of outlines to compute stats for @@ -332,9 +332,9 @@ void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats) { MFEDGEPT *Current; MFEDGEPT *Last; - InitOutlineStats(OutlineStats); - iterate(Outlines) { - Outline = (MFOUTLINE) first (Outlines); + InitOutlineStats(OutlineStats); + iterate(Outlines) { + Outline = (MFOUTLINE) first_node (Outlines); Last = PointAt (Outline); Outline = NextPointAfter (Outline); @@ -351,13 +351,13 @@ void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats) { } while (EdgePoint != Outline); } - FinishOutlineStats(OutlineStats); + FinishOutlineStats(OutlineStats); } /* ComputeOutlineStats */ /*---------------------------------------------------------------------------*/ -void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength) { +void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength) { /* ** Parameters: ** Outline outline to be filtered @@ -454,7 +454,7 @@ void FindDirectionChanges(MFOUTLINE Outline, EdgePoint = Outline; do { Current = PointAt (EdgePoint); - ComputeDirection(Last, Current, MinSlope, MaxSlope); + ComputeDirection(Last, Current, MinSlope, MaxSlope); Last = Current; EdgePoint = NextPointAfter (EdgePoint); @@ -482,9 +482,9 @@ void FreeMFOutline(void *arg) { //MFOUTLINE Outline /* break the circular outline so we can use std. techniques to deallocate */ Start = rest (Outline); - set_rest(Outline, NIL); + set_rest(Outline, NIL); while (Start != NULL) { - c_free_struct (first (Start), sizeof (MFEDGEPT), "MFEDGEPT"); + c_free_struct (first_node (Start), sizeof (MFEDGEPT), "MFEDGEPT"); Start = pop (Start); } @@ -492,7 +492,7 @@ void FreeMFOutline(void *arg) { //MFOUTLINE Outline /*---------------------------------------------------------------------------*/ -void FreeOutlines(LIST Outlines) { +void FreeOutlines(LIST Outlines) { /* ** Parameters: ** Outlines list of mf-outlines to be freed @@ -503,12 +503,12 @@ void FreeOutlines(LIST Outlines) { ** Exceptions: none ** History: Thu Dec 13 16:14:50 1990, DSJ, Created. */ - destroy_nodes(Outlines, FreeMFOutline); + destroy_nodes(Outlines, FreeMFOutline); } /* FreeOutlines */ /*---------------------------------------------------------------------------*/ -void InitMFOutlineVars() { +void InitMFOutlineVars() { /* ** Parameters: none ** Globals: none @@ -518,17 +518,17 @@ void InitMFOutlineVars() { ** Exceptions: none ** History: Fri Dec 14 10:50:12 1990, DSJ, Created. */ - MakeNormMethod(); - MakeCharNormRange(); - MakeMinNormScaleX(); - MakeMaxNormScaleX(); - MakeMinNormScaleY(); - MakeMaxNormScaleY(); + MakeNormMethod(); + MakeCharNormRange(); + MakeMinNormScaleX(); + MakeMaxNormScaleX(); + MakeMinNormScaleY(); + MakeMaxNormScaleY(); } /* InitMFOutlineVars */ /*---------------------------------------------------------------------------*/ -void MarkDirectionChanges(MFOUTLINE Outline) { +void MarkDirectionChanges(MFOUTLINE Outline) { /* ** Parameters: ** Outline micro-feature outline to analyze @@ -565,7 +565,7 @@ void MarkDirectionChanges(MFOUTLINE Outline) { /*---------------------------------------------------------------------------*/ -MFEDGEPT *NewEdgePoint() { +MFEDGEPT *NewEdgePoint() { /* ** Parameters: none ** Globals: none @@ -582,7 +582,7 @@ MFEDGEPT *NewEdgePoint() { /*---------------------------------------------------------------------------*/ -MFOUTLINE NextExtremity(MFOUTLINE EdgePoint) { +MFOUTLINE NextExtremity(MFOUTLINE EdgePoint) { /* ** Parameters: ** EdgePoint start search from this point @@ -697,7 +697,7 @@ void NormalizeOutlines(LIST Outlines, switch (NormMethod) { case character: - ComputeOutlineStats(Outlines, &OutlineStats); + ComputeOutlineStats(Outlines, &OutlineStats); /* limit scale factor to avoid overscaling small blobs (.,`'), thin blobs (l1ift), and merged blobs */ @@ -713,8 +713,8 @@ void NormalizeOutlines(LIST Outlines, *XScale = CharNormRange * BaselineScale / *XScale; *YScale = CharNormRange * BaselineScale / *YScale; - iterate(Outlines) { - Outline = (MFOUTLINE) first (Outlines); + iterate(Outlines) { + Outline = (MFOUTLINE) first_node (Outlines); CharNormalizeOutline (Outline, OutlineStats.x, OutlineStats.y, *XScale, *YScale); @@ -722,8 +722,8 @@ void NormalizeOutlines(LIST Outlines, break; case baseline: - iterate(Outlines) { - Outline = (MFOUTLINE) first (Outlines); + iterate(Outlines) { + Outline = (MFOUTLINE) first_node (Outlines); NormalizeOutline (Outline, LineStats, 0.0); } *XScale = *YScale = ComputeScaleFactor (LineStats); @@ -733,7 +733,7 @@ void NormalizeOutlines(LIST Outlines, /*---------------------------------------------------------------------------*/ -void SettupBlobConversion(TBLOB *Blob) { +void SettupBlobConversion(TBLOB *Blob) { /* ** Parameters: ** Blob blob that is to be converted @@ -747,13 +747,13 @@ void SettupBlobConversion(TBLOB *Blob) { ** Exceptions: none ** History: Thu May 17 11:06:17 1990, DSJ, Created. */ - ComputeBlobCenter(Blob, &BlobCenter); + ComputeBlobCenter(Blob, &BlobCenter); } /* SettupBlobConversion */ /*---------------------------------------------------------------------------*/ -void SmearExtremities(MFOUTLINE Outline, FLOAT32 XScale, FLOAT32 YScale) { +void SmearExtremities(MFOUTLINE Outline, FLOAT32 XScale, FLOAT32 YScale) { /* ** Parameters: ** Outline outline whose extremities are to be smeared @@ -788,9 +788,9 @@ void SmearExtremities(MFOUTLINE Outline, FLOAT32 XScale, FLOAT32 YScale) { Current = PointAt (EdgePoint); if (IsExtremity (Current)) { XPositionOf (Current) += - UniformRandomNumber(MinXSmear, MaxXSmear); + UniformRandomNumber(MinXSmear, MaxXSmear); YPositionOf (Current) += - UniformRandomNumber(MinYSmear, MaxYSmear); + UniformRandomNumber(MinYSmear, MaxYSmear); } EdgePoint = NextPointAfter (EdgePoint); @@ -804,7 +804,7 @@ void SmearExtremities(MFOUTLINE Outline, FLOAT32 XScale, FLOAT32 YScale) { Private Code ----------------------------------------------------------------------------**/ /*---------------------------------------------------------------------------*/ -void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction) { +void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction) { /* ** Parameters: ** Start, End defines segment of outline to be modified @@ -948,7 +948,7 @@ void ComputeDirection(MFEDGEPT *Start, /*---------------------------------------------------------------------------*/ -void FinishOutlineStats(register OUTLINE_STATS *OutlineStats) { +void FinishOutlineStats(register OUTLINE_STATS *OutlineStats) { /* ** Parameters: ** OutlineStats statistics about a set of outlines @@ -988,7 +988,7 @@ void FinishOutlineStats(register OUTLINE_STATS *OutlineStats) { /*---------------------------------------------------------------------------*/ -void InitOutlineStats(OUTLINE_STATS *OutlineStats) { +void InitOutlineStats(OUTLINE_STATS *OutlineStats) { /* ** Parameters: ** OutlineStats stats data structure to be initialized @@ -1012,7 +1012,7 @@ void InitOutlineStats(OUTLINE_STATS *OutlineStats) { /*---------------------------------------------------------------------------*/ -MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint) { +MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint) { /* ** Parameters: ** EdgePoint start search from this point diff --git a/classify/mfx.cpp b/classify/mfx.cpp index 417455584..31ba27e72 100644 --- a/classify/mfx.cpp +++ b/classify/mfx.cpp @@ -158,14 +158,14 @@ CHAR_FEATURES BlobMicroFeatures(TBLOB *Blob, LINE_STATS *LineStats) { if (Blob != NULL) { Outlines = ConvertBlob (Blob); -// NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); +// NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); ExtractIntFeat(Blob, blfeatures, cnfeatures, &results); XScale = 0.2f / results.Ry; YScale = 0.2f / results.Rx; RemainingOutlines = Outlines; - iterate(RemainingOutlines) { - Outline = (MFOUTLINE) first (RemainingOutlines); + iterate(RemainingOutlines) { + Outline = (MFOUTLINE) first_node (RemainingOutlines); CharNormalizeOutline (Outline, results.Xmean, results.Ymean, XScale, YScale); @@ -173,7 +173,7 @@ CHAR_FEATURES BlobMicroFeatures(TBLOB *Blob, LINE_STATS *LineStats) { RemainingOutlines = Outlines; iterate(RemainingOutlines) { - Outline = (MFOUTLINE) first (RemainingOutlines); + Outline = (MFOUTLINE) first_node (RemainingOutlines); FindDirectionChanges(Outline, MinSlope, MaxSlope); FilterEdgeNoise(Outline, NoiseSegmentLength); MarkDirectionChanges(Outline); diff --git a/classify/normmatch.cpp b/classify/normmatch.cpp index 8af6ed41a..c8c1af96c 100644 --- a/classify/normmatch.cpp +++ b/classify/normmatch.cpp @@ -32,7 +32,7 @@ #include /* define default filenames for training data */ -#define NORM_PROTO_FILE "tessdata/normproto" +#define NORM_PROTO_FILE "normproto" typedef struct { @@ -70,7 +70,6 @@ make_float_var (NormAdjMidpoint, 32.0, MakeNormAdjMidpoint, 15, 16, SetNormAdjMidpoint, "Norm adjust midpoint ...") make_float_var (NormAdjCurl, 2.0, MakeNormAdjCurl, 15, 17, SetNormAdjCurl, "Norm adjust curl ...") -//extern char *demodir; /**---------------------------------------------------------------------------- Public Code ----------------------------------------------------------------------------**/ @@ -119,7 +118,7 @@ FLOAT32 ComputeNormMatch(CLASS_ID ClassId, FEATURE Feature, BOOL8 DebugMatch) { ProtoId = 0; iterate(Protos) { - Proto = (PROTOTYPE *) first (Protos); + Proto = (PROTOTYPE *) first_node (Protos); Delta = ParamOf (Feature, CharNormY) - Proto->Mean[CharNormY]; Match = Delta * Delta * Proto->Weight.Elliptical[CharNormY]; Delta = ParamOf (Feature, CharNormRx) - Proto->Mean[CharNormRx]; @@ -157,11 +156,11 @@ void GetNormProtos() { ** History: Wed Dec 19 16:24:25 1990, DSJ, Created. */ FILE *File; - char name[1024]; + STRING name; - strcpy(name, demodir); - strcat(name, NormProtoFile); - File = Efopen (name, "r"); + name = language_data_path_prefix; + name += NormProtoFile; + File = Efopen (name.string(), "r"); NormProtos = ReadNormProtos (File); fclose(File); @@ -170,7 +169,7 @@ void GetNormProtos() { void FreeNormProtos() { if (NormProtos != NULL) { for (int i = 0; i <= MAX_CLASS_ID; i++) - FreeProtoList(&NormProtos->Protos[i]); + FreeProtoList(&NormProtos->Protos[i]); Efree(NormProtos->ParamDesc); Efree(NormProtos); NormProtos = NULL; diff --git a/classify/outfeat.cpp b/classify/outfeat.cpp index 1200f306a..3354f14a8 100644 --- a/classify/outfeat.cpp +++ b/classify/outfeat.cpp @@ -60,7 +60,7 @@ void NormalizeOutlineX Public Code ----------------------------------------------------------------------------**/ /*---------------------------------------------------------------------------*/ -FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob, LINE_STATS *LineStats) { +FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob, LINE_STATS *LineStats) { /* ** Parameters: ** Blob blob to extract pico-features from @@ -85,10 +85,10 @@ FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob, LINE_STATS *LineStats) { Outlines = ConvertBlob (Blob); - NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); + NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); RemainingOutlines = Outlines; - iterate(RemainingOutlines) { - Outline = (MFOUTLINE) first (RemainingOutlines); + iterate(RemainingOutlines) { + Outline = (MFOUTLINE) first_node (RemainingOutlines); /*---------Debug--------------------------------------------------* OFile = fopen ("f:/ims/debug/ofOutline.logCPP", "r"); if (OFile == NULL) @@ -104,10 +104,10 @@ FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob, LINE_STATS *LineStats) { WriteOutline(OFile, Outline); fclose (OFile); *--------------------------------------------------------------------*/ - ConvertToOutlineFeatures(Outline, FeatureSet); + ConvertToOutlineFeatures(Outline, FeatureSet); } if (NormMethod == baseline) - NormalizeOutlineX(FeatureSet); + NormalizeOutlineX(FeatureSet); /*---------Debug--------------------------------------------------* File = fopen ("f:/ims/debug/ofFeatSet.logCPP", "r"); if (File == NULL) @@ -123,13 +123,13 @@ FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob, LINE_STATS *LineStats) { WriteFeatureSet(File, FeatureSet); fclose (File); *--------------------------------------------------------------------*/ - FreeOutlines(Outlines); + FreeOutlines(Outlines); return (FeatureSet); } /* ExtractOutlineFeatures */ /*---------------------------------------------------------------------------*/ -void InitOutlineFXVars() { +void InitOutlineFXVars() { //once contained a dummy /* ** Parameters: none @@ -174,13 +174,13 @@ void AddOutlineFeatureToSet(FPOINT *Start, ParamOf (Feature, OutlineFeatX) = AverageOf (Xof (*Start), Xof (*End)); ParamOf (Feature, OutlineFeatY) = AverageOf (Yof (*Start), Yof (*End)); ParamOf (Feature, OutlineFeatLength) = DistanceBetween (*Start, *End); - AddFeature(FeatureSet, Feature); + AddFeature(FeatureSet, Feature); } /* AddOutlineFeatureToSet */ /*---------------------------------------------------------------------------*/ -void ConvertToOutlineFeatures(MFOUTLINE Outline, FEATURE_SET FeatureSet) { +void ConvertToOutlineFeatures(MFOUTLINE Outline, FEATURE_SET FeatureSet) { /* ** Parameters: ** Outline outline to extract outline-features from @@ -216,7 +216,7 @@ void ConvertToOutlineFeatures(MFOUTLINE Outline, FEATURE_SET FeatureSet) { starting point for that edge. */ if (IsVisible (PointAt (Next))) { CopyPoint (PositionOf (PointAt (Next)), FeatureEnd); - AddOutlineFeatureToSet(&FeatureStart, &FeatureEnd, FeatureSet); + AddOutlineFeatureToSet(&FeatureStart, &FeatureEnd, FeatureSet); } } while (Next != First); @@ -224,7 +224,7 @@ void ConvertToOutlineFeatures(MFOUTLINE Outline, FEATURE_SET FeatureSet) { /*---------------------------------------------------------------------------*/ -void NormalizeOutlineX(FEATURE_SET FeatureSet) { +void NormalizeOutlineX(FEATURE_SET FeatureSet) { /* ** Parameters: ** FeatureSet outline-features to be normalized diff --git a/classify/picofeat.cpp b/classify/picofeat.cpp index 37d22ed48..501235dfb 100644 --- a/classify/picofeat.cpp +++ b/classify/picofeat.cpp @@ -41,9 +41,9 @@ void ConvertSegmentToPicoFeat(FPOINT *Start, FPOINT *End, FEATURE_SET FeatureSet); -void ConvertToPicoFeatures2(MFOUTLINE Outline, FEATURE_SET FeatureSet); +void ConvertToPicoFeatures2(MFOUTLINE Outline, FEATURE_SET FeatureSet); -void NormalizePicoX(FEATURE_SET FeatureSet); +void NormalizePicoX(FEATURE_SET FeatureSet); /* #if defined(__STDC__) || defined(__cplusplus) @@ -76,7 +76,7 @@ void NormalizePicoX Public Code ----------------------------------------------------------------------------**/ /*---------------------------------------------------------------------------*/ -FEATURE_SET ExtractPicoFeatures(TBLOB *Blob, LINE_STATS *LineStats) { +FEATURE_SET ExtractPicoFeatures(TBLOB *Blob, LINE_STATS *LineStats) { /* ** Parameters: ** Blob blob to extract pico-features from @@ -98,10 +98,10 @@ FEATURE_SET ExtractPicoFeatures(TBLOB *Blob, LINE_STATS *LineStats) { Outlines = ConvertBlob (Blob); - NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); + NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); RemainingOutlines = Outlines; - iterate(RemainingOutlines) { - Outline = (MFOUTLINE) first (RemainingOutlines); + iterate(RemainingOutlines) { + Outline = (MFOUTLINE) first_node (RemainingOutlines); /*---------Debug--------------------------------------------------* OFile = fopen ("f:/ims/debug/pfOutline.logCPP", "r"); if (OFile == NULL) @@ -117,10 +117,10 @@ FEATURE_SET ExtractPicoFeatures(TBLOB *Blob, LINE_STATS *LineStats) { WriteOutline(OFile, Outline); fclose (OFile); *--------------------------------------------------------------------*/ - ConvertToPicoFeatures2(Outline, FeatureSet); + ConvertToPicoFeatures2(Outline, FeatureSet); } if (NormMethod == baseline) - NormalizePicoX(FeatureSet); + NormalizePicoX(FeatureSet); /*---------Debug--------------------------------------------------* File = fopen ("f:/ims/debug/pfFeatSet.logCPP", "r"); if (File == NULL) @@ -136,14 +136,14 @@ FEATURE_SET ExtractPicoFeatures(TBLOB *Blob, LINE_STATS *LineStats) { WriteFeatureSet(File, FeatureSet); fclose (File); *--------------------------------------------------------------------*/ - FreeOutlines(Outlines); + FreeOutlines(Outlines); return (FeatureSet); } /* ExtractPicoFeatures */ /*---------------------------------------------------------------------------*/ -void InitPicoFXVars() { +void InitPicoFXVars() { /* ** Parameters: none ** Globals: @@ -156,10 +156,10 @@ void InitPicoFXVars() { */ VALUE dummy; - + float_variable (PicoFeatureLength, "PicoFeatureLength", PICO_FEATURE_LENGTH); - + } /* InitPicoFXVars */ /**---------------------------------------------------------------------------- @@ -213,7 +213,7 @@ void ConvertSegmentToPicoFeat(FPOINT *Start, ParamOf (Feature, PicoFeatDir) = Angle; ParamOf (Feature, PicoFeatX) = Xof (Center); ParamOf (Feature, PicoFeatY) = Yof (Center); - AddFeature(FeatureSet, Feature); + AddFeature(FeatureSet, Feature); Xof (Center) += Xof (Delta); Yof (Center) += Yof (Delta); @@ -222,7 +222,7 @@ void ConvertSegmentToPicoFeat(FPOINT *Start, /*---------------------------------------------------------------------------*/ -void ConvertToPicoFeatures2(MFOUTLINE Outline, FEATURE_SET FeatureSet) { +void ConvertToPicoFeatures2(MFOUTLINE Outline, FEATURE_SET FeatureSet) { /* ** Parameters: ** Outline outline to extract micro-features from @@ -267,7 +267,7 @@ void ConvertToPicoFeatures2(MFOUTLINE Outline, FEATURE_SET FeatureSet) { /*---------------------------------------------------------------------------*/ -void NormalizePicoX(FEATURE_SET FeatureSet) { +void NormalizePicoX(FEATURE_SET FeatureSet) { /* ** Parameters: ** FeatureSet pico-features to be normalized diff --git a/classify/sigmenu.cpp b/classify/sigmenu.cpp index 783b104d9..1f3f4e957 100644 --- a/classify/sigmenu.cpp +++ b/classify/sigmenu.cpp @@ -44,7 +44,7 @@ static LIST SignalMenus[NSIG]; /* must be initialized to NIL */ /**---------------------------------------------------------------------------- Private Function Prototypes ----------------------------------------------------------------------------**/ -void MainSignalHandler(int Signal); +void MainSignalHandler(int Signal); SIG_MENU_ITEM *NewSignalMenuItem (int ItemNum, const char ItemLabel[], int_void ItemFunc); @@ -97,7 +97,7 @@ int ItemNum, const char ItemLabel[], int_void ItemFunc) { SignalMenus[Signal] = s_adjoin (SignalMenus[Signal], NewItem, ItemCompare); /* set up the trap for the appropriate signal */ - signal(Signal, MainSignalHandler); + signal(Signal, MainSignalHandler); #endif #endif } /* AddSignalMenuItem */ @@ -107,7 +107,7 @@ int ItemNum, const char ItemLabel[], int_void ItemFunc) { Private Code ----------------------------------------------------------------------------**/ /*---------------------------------------------------------------------------*/ -void MainSignalHandler(int Signal) { +void MainSignalHandler(int Signal) { /* ** Parameters: ** Signal signal that caused this function to be called @@ -135,8 +135,8 @@ void MainSignalHandler(int Signal) { cprintf ("0. Resume normal operation\n"); Items = SignalMenus[Signal]; - iterate(Items) { - MenuItem = (SIG_MENU_ITEM *) first (Items); + iterate(Items) { + MenuItem = (SIG_MENU_ITEM *) first_node (Items); cprintf ("%d. %s\n", MenuItem->ItemNum, MenuItem->ItemLabel); } cprintf ("\nEnter Selection: "); @@ -151,14 +151,14 @@ void MainSignalHandler(int Signal) { } if (Command == 0) - signal(Signal, MainSignalHandler); + signal(Signal, MainSignalHandler); Items = SignalMenus[Signal]; - iterate(Items) { - MenuItem = (SIG_MENU_ITEM *) first (Items); + iterate(Items) { + MenuItem = (SIG_MENU_ITEM *) first_node (Items); if (Command == MenuItem->ItemNum) { if ((*MenuItem->ItemFunc) ( /*Params */ ) == SIG_RESUME) - signal(Signal, MainSignalHandler); + signal(Signal, MainSignalHandler); break; } }