Commit 6aac05e9 for tesseract
commit 6aac05e981af89e79c23339b8f4bb786a9d134fc
Author: Stefan Weil <sw@weilnetz.de>
Date: Thu Jun 4 15:41:40 2026 +0200
Convert enum to class enum in several files
Assisted-by: OpenCode / BigPickle
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/src/classify/cluster.cpp b/src/classify/cluster.cpp
index 4143bbbb..b926f7e4 100644
--- a/src/classify/cluster.cpp
+++ b/src/classify/cluster.cpp
@@ -1276,7 +1276,7 @@ struct BUCKETS {
}
~BUCKETS() {
}
- DISTRIBUTION Distribution = normal; // distribution being tested for
+ DISTRIBUTION Distribution = DISTRIBUTION::normal; // distribution being tested for
uint32_t SampleCount = 0; // # of samples in histogram
double Confidence = 0.0; // confidence level of test
double ChiSquared = 0.0; // test threshold
@@ -1614,7 +1614,7 @@ void FreePrototype(void *arg) { // PROTOTYPE *Prototype)
}
// deallocate the prototype statistics and then the prototype itself
- if (Prototype->Style != spherical) {
+ if (Prototype->Style != PROTOSTYLE::spherical) {
delete[] Prototype->Variance.Elliptical;
delete[] Prototype->Magnitude.Elliptical;
delete[] Prototype->Weight.Elliptical;
@@ -1672,20 +1672,21 @@ float Mean(PROTOTYPE *Proto, uint16_t Dimension) {
*/
float StandardDeviation(PROTOTYPE *Proto, uint16_t Dimension) {
switch (Proto->Style) {
- case spherical:
+ case PROTOSTYLE::spherical:
return std::sqrt(Proto->Variance.Spherical);
- case elliptical:
+ case PROTOSTYLE::elliptical:
return std::sqrt(Proto->Variance.Elliptical[Dimension]);
- case mixed:
+ case PROTOSTYLE::mixed:
switch (Proto->Distrib[Dimension]) {
- case normal:
+ case DISTRIBUTION::normal:
return std::sqrt(Proto->Variance.Elliptical[Dimension]);
- case uniform:
- case D_random:
+ case DISTRIBUTION::uniform:
+ case DISTRIBUTION::D_random:
return Proto->Variance.Elliptical[Dimension];
- case DISTRIBUTION_COUNT:
- ASSERT_HOST(!"Distribution count not allowed!");
}
+ break;
+ default:
+ break;
}
return 0.0f;
} // StandardDeviation
@@ -1976,7 +1977,7 @@ static PROTOTYPE *MakePrototype(CLUSTERER *Clusterer, CLUSTERCONFIG *Config, CLU
return nullptr;
}
- if (HOTELLING && Config->ProtoStyle == elliptical) {
+ if (HOTELLING && Config->ProtoStyle == PROTOSTYLE::elliptical) {
Proto = TestEllipticalProto(Clusterer, Config, Cluster, Statistics);
if (Proto != nullptr) {
delete Statistics;
@@ -1985,20 +1986,20 @@ static PROTOTYPE *MakePrototype(CLUSTERER *Clusterer, CLUSTERCONFIG *Config, CLU
}
// create a histogram data structure used to evaluate distributions
- Buckets = GetBuckets(Clusterer, normal, Cluster->SampleCount, Config->Confidence);
+ Buckets = GetBuckets(Clusterer, DISTRIBUTION::normal, Cluster->SampleCount, Config->Confidence);
// create a prototype based on the statistics and test it
switch (Config->ProtoStyle) {
- case spherical:
+ case PROTOSTYLE::spherical:
Proto = MakeSphericalProto(Clusterer, Cluster, Statistics, Buckets);
break;
- case elliptical:
+ case PROTOSTYLE::elliptical:
Proto = MakeEllipticalProto(Clusterer, Cluster, Statistics, Buckets);
break;
- case mixed:
+ case PROTOSTYLE::mixed:
Proto = MakeMixedProto(Clusterer, Cluster, Statistics, Buckets, Config->Confidence);
break;
- case automatic:
+ case PROTOSTYLE::automatic:
Proto = MakeSphericalProto(Clusterer, Cluster, Statistics, Buckets);
if (Proto != nullptr) {
break;
@@ -2043,14 +2044,14 @@ static PROTOTYPE *MakeDegenerateProto( // this was MinSample
if (Cluster->SampleCount < MinSamples) {
switch (Style) {
- case spherical:
+ case PROTOSTYLE::spherical:
Proto = NewSphericalProto(N, Cluster, Statistics);
break;
- case elliptical:
- case automatic:
+ case PROTOSTYLE::elliptical:
+ case PROTOSTYLE::automatic:
Proto = NewEllipticalProto(N, Cluster, Statistics);
break;
- case mixed:
+ case PROTOSTYLE::mixed:
Proto = NewMixedProto(N, Cluster, Statistics);
break;
}
@@ -2273,7 +2274,7 @@ static PROTOTYPE *MakeMixedProto(CLUSTERER *Clusterer, CLUSTER *Cluster, STATIST
}
if (RandomBuckets == nullptr) {
- RandomBuckets = GetBuckets(Clusterer, D_random, Cluster->SampleCount, Confidence);
+ RandomBuckets = GetBuckets(Clusterer, DISTRIBUTION::D_random, Cluster->SampleCount, Confidence);
}
MakeDimRandom(i, Proto, &(Clusterer->ParamDesc[i]));
FillBuckets(RandomBuckets, Cluster, i, &(Clusterer->ParamDesc[i]), Proto->Mean[i],
@@ -2283,7 +2284,7 @@ static PROTOTYPE *MakeMixedProto(CLUSTERER *Clusterer, CLUSTER *Cluster, STATIST
}
if (UniformBuckets == nullptr) {
- UniformBuckets = GetBuckets(Clusterer, uniform, Cluster->SampleCount, Confidence);
+ UniformBuckets = GetBuckets(Clusterer, DISTRIBUTION::uniform, Cluster->SampleCount, Confidence);
}
MakeDimUniform(i, Proto, Statistics);
FillBuckets(UniformBuckets, Cluster, i, &(Clusterer->ParamDesc[i]), Proto->Mean[i],
@@ -2309,7 +2310,7 @@ static PROTOTYPE *MakeMixedProto(CLUSTERER *Clusterer, CLUSTER *Cluster, STATIST
* @param ParamDesc description of specified dimension
*/
static void MakeDimRandom(uint16_t i, PROTOTYPE *Proto, PARAM_DESC *ParamDesc) {
- Proto->Distrib[i] = D_random;
+ Proto->Distrib[i] = DISTRIBUTION::D_random;
Proto->Mean[i] = ParamDesc->MidRange;
Proto->Variance.Elliptical[i] = ParamDesc->HalfRange;
@@ -2330,7 +2331,7 @@ static void MakeDimRandom(uint16_t i, PROTOTYPE *Proto, PARAM_DESC *ParamDesc) {
* @param Statistics statistical info about prototype
*/
static void MakeDimUniform(uint16_t i, PROTOTYPE *Proto, STATISTICS *Statistics) {
- Proto->Distrib[i] = uniform;
+ Proto->Distrib[i] = DISTRIBUTION::uniform;
Proto->Mean[i] = Proto->Cluster->Mean[i] + (Statistics->Min[i] + Statistics->Max[i]) / 2;
Proto->Variance.Elliptical[i] = (Statistics->Max[i] - Statistics->Min[i]) / 2;
if (Proto->Variance.Elliptical[i] < MINVARIANCE) {
@@ -2488,7 +2489,7 @@ static PROTOTYPE *NewEllipticalProto(int16_t N, CLUSTER *Cluster, STATISTICS *St
Proto->TotalMagnitude *= Proto->Magnitude.Elliptical[i];
}
Proto->LogMagnitude = log(static_cast<double>(Proto->TotalMagnitude));
- Proto->Style = elliptical;
+ Proto->Style = PROTOSTYLE::elliptical;
return (Proto);
} // NewEllipticalProto
@@ -2508,8 +2509,8 @@ static PROTOTYPE *NewEllipticalProto(int16_t N, CLUSTER *Cluster, STATISTICS *St
static PROTOTYPE *NewMixedProto(int16_t N, CLUSTER *Cluster, STATISTICS *Statistics) {
auto Proto = NewEllipticalProto(N, Cluster, Statistics);
Proto->Distrib.clear();
- Proto->Distrib.resize(N, normal);
- Proto->Style = mixed;
+ Proto->Distrib.resize(N, DISTRIBUTION::normal);
+ Proto->Style = PROTOSTYLE::mixed;
return Proto;
} // NewMixedProto
@@ -2527,7 +2528,7 @@ static PROTOTYPE *NewSimpleProto(int16_t N, CLUSTER *Cluster) {
Proto->Distrib.clear();
Proto->Significant = true;
Proto->Merged = false;
- Proto->Style = spherical;
+ Proto->Style = PROTOSTYLE::spherical;
Proto->NumSamples = Cluster->SampleCount;
Proto->Cluster = Cluster;
Proto->Cluster->Prototype = true;
@@ -2603,12 +2604,12 @@ static BUCKETS *GetBuckets(CLUSTERER *clusterer, DISTRIBUTION Distribution, uint
double Confidence) {
// Get an old bucket structure with the same number of buckets.
uint16_t NumberOfBuckets = OptimumNumberOfBuckets(SampleCount);
- BUCKETS *Buckets = clusterer->bucket_cache[Distribution][NumberOfBuckets - MINBUCKETS];
+ BUCKETS *Buckets = clusterer->bucket_cache[static_cast<size_t>(Distribution)][NumberOfBuckets - MINBUCKETS];
// If a matching bucket structure is not found, make one and save it.
if (Buckets == nullptr) {
Buckets = MakeBuckets(Distribution, SampleCount, Confidence);
- clusterer->bucket_cache[Distribution][NumberOfBuckets - MINBUCKETS] = Buckets;
+ clusterer->bucket_cache[static_cast<size_t>(Distribution)][NumberOfBuckets - MINBUCKETS] = Buckets;
} else {
// Just adjust the existing buckets.
if (SampleCount != Buckets->SampleCount) {
@@ -2899,11 +2900,11 @@ static void FillBuckets(BUCKETS *Buckets, CLUSTER *Cluster, uint16_t Dim, PARAM_
InitSampleSearch(SearchState, Cluster);
while ((Sample = NextSample(&SearchState)) != nullptr) {
switch (Buckets->Distribution) {
- case normal:
+ case DISTRIBUTION::normal:
BucketID = NormalBucket(ParamDesc, Sample->Mean[Dim], Mean, StdDev);
break;
- case D_random:
- case uniform:
+ case DISTRIBUTION::D_random:
+ case DISTRIBUTION::uniform:
BucketID = UniformBucket(ParamDesc, Sample->Mean[Dim], Mean, StdDev);
break;
default:
diff --git a/src/classify/cluster.h b/src/classify/cluster.h
index c8580bf6..33f0afda 100644
--- a/src/classify/cluster.h
+++ b/src/classify/cluster.h
@@ -50,7 +50,12 @@ struct CLUSTER {
};
using SAMPLE = CLUSTER; // can refer to as either sample or cluster
-typedef enum { spherical, elliptical, mixed, automatic } PROTOSTYLE;
+enum class PROTOSTYLE {
+ spherical,
+ elliptical,
+ mixed,
+ automatic
+};
struct CLUSTERCONFIG { // parameters to control clustering
PROTOSTYLE ProtoStyle; // specifies types of protos to be made
@@ -62,7 +67,12 @@ struct CLUSTERCONFIG { // parameters to control clustering
int MagicSamples; // Ideal number of samples in a cluster.
};
-typedef enum { normal, uniform, D_random, DISTRIBUTION_COUNT } DISTRIBUTION;
+enum class DISTRIBUTION : uint8_t {
+ normal,
+ uniform,
+ D_random
+};
+constexpr int kDistributionCount = 3;
union FLOATUNION {
float Spherical;
@@ -76,7 +86,7 @@ struct PROTOTYPE {
// samples then it was actually merged.
// Otherwise it matched an already significant
// cluster.
- unsigned Style : 2; // spherical, elliptical, or mixed
+ PROTOSTYLE Style : 2; // spherical, elliptical, or mixed
unsigned NumSamples : 28; // number of samples in the cluster
CLUSTER *Cluster; // ptr to cluster which made prototype
std::vector<DISTRIBUTION> Distrib; // different distribution for each dimension
@@ -97,7 +107,7 @@ struct CLUSTERER {
LIST ProtoList; // list of prototypes
uint32_t NumChar; // # of characters represented by samples
// cache of reusable histograms by distribution type and number of buckets.
- BUCKETS *bucket_cache[DISTRIBUTION_COUNT][MAXBUCKETS + 1 - MINBUCKETS];
+ BUCKETS *bucket_cache[kDistributionCount][MAXBUCKETS + 1 - MINBUCKETS];
};
struct SAMPLELIST {
diff --git a/src/classify/clusttool.cpp b/src/classify/clusttool.cpp
index de8b1f5c..e11c9374 100644
--- a/src/classify/clusttool.cpp
+++ b/src/classify/clusttool.cpp
@@ -88,16 +88,16 @@ static void WriteNFloats(FILE *File, uint16_t N, float Array[]) {
*/
static void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle) {
switch (ProtoStyle) {
- case spherical:
+ case PROTOSTYLE::spherical:
fprintf(File, "spherical");
break;
- case elliptical:
+ case PROTOSTYLE::elliptical:
fprintf(File, "elliptical");
break;
- case mixed:
+ case PROTOSTYLE::mixed:
fprintf(File, "mixed");
break;
- case automatic:
+ case PROTOSTYLE::automatic:
fprintf(File, "automatic");
break;
}
@@ -184,17 +184,17 @@ PROTOTYPE *ReadPrototype(TFile *fp, uint16_t N) {
switch (shape_token[0]) {
case 's':
- Proto->Style = spherical;
+ Proto->Style = PROTOSTYLE::spherical;
break;
case 'e':
- Proto->Style = elliptical;
+ Proto->Style = PROTOSTYLE::elliptical;
break;
case 'a':
- Proto->Style = automatic;
+ Proto->Style = PROTOSTYLE::automatic;
break;
default:
tprintf("Invalid prototype style specification:%s\n", shape_token);
- Proto->Style = elliptical;
+ Proto->Style = PROTOSTYLE::elliptical;
}
ASSERT_HOST(SampleCount >= 0);
@@ -204,7 +204,7 @@ PROTOTYPE *ReadPrototype(TFile *fp, uint16_t N) {
ReadNFloats(fp, N, &Proto->Mean[0]);
switch (Proto->Style) {
- case spherical:
+ case PROTOSTYLE::spherical:
ReadNFloats(fp, 1, &(Proto->Variance.Spherical));
Proto->Magnitude.Spherical = 1.0 / sqrt(2.0 * M_PI * Proto->Variance.Spherical);
Proto->TotalMagnitude = std::pow(Proto->Magnitude.Spherical, static_cast<float>(N));
@@ -212,7 +212,7 @@ PROTOTYPE *ReadPrototype(TFile *fp, uint16_t N) {
Proto->Weight.Spherical = 1.0 / Proto->Variance.Spherical;
Proto->Distrib.clear();
break;
- case elliptical:
+ case PROTOSTYLE::elliptical:
Proto->Variance.Elliptical = new float[N];
ReadNFloats(fp, N, Proto->Variance.Elliptical);
Proto->Magnitude.Elliptical = new float[N];
@@ -276,32 +276,32 @@ void WritePrototype(FILE *File, uint16_t N, PROTOTYPE *Proto) {
} else {
fprintf(File, "insignificant ");
}
- WriteProtoStyle(File, static_cast<PROTOSTYLE>(Proto->Style));
+ WriteProtoStyle(File, Proto->Style);
fprintf(File, "%6u\n\t", Proto->NumSamples);
WriteNFloats(File, N, &Proto->Mean[0]);
fprintf(File, "\t");
switch (Proto->Style) {
- case spherical:
+ case PROTOSTYLE::spherical:
WriteNFloats(File, 1, &(Proto->Variance.Spherical));
break;
- case elliptical:
+ case PROTOSTYLE::elliptical:
WriteNFloats(File, N, Proto->Variance.Elliptical);
break;
- case mixed:
+ case PROTOSTYLE::automatic:
+ break;
+ case PROTOSTYLE::mixed:
for (i = 0; i < N; i++) {
switch (Proto->Distrib[i]) {
- case normal:
+ case DISTRIBUTION::normal:
fprintf(File, " %9s", "normal");
break;
- case uniform:
+ case DISTRIBUTION::uniform:
fprintf(File, " %9s", "uniform");
break;
- case D_random:
+ case DISTRIBUTION::D_random:
fprintf(File, " %9s", "random");
break;
- case DISTRIBUTION_COUNT:
- ASSERT_HOST(!"Distribution count not allowed!");
}
}
fprintf(File, "\n\t");
diff --git a/src/classify/intproto.cpp b/src/classify/intproto.cpp
index f5f08cf1..0d2f3746 100644
--- a/src/classify/intproto.cpp
+++ b/src/classify/intproto.cpp
@@ -66,7 +66,7 @@ namespace tesseract {
/** define pad used to snap near horiz/vertical protos to horiz/vertical */
#define HV_TOLERANCE (0.0025) /* approx 0.9 degrees */
-typedef enum { StartSwitch, EndSwitch, LastSwitch } SWITCH_TYPE;
+enum class SWITCH_TYPE { StartSwitch, EndSwitch, LastSwitch };
#define MAX_NUM_SWITCHES 3
struct FILL_SWITCH {
@@ -1065,7 +1065,7 @@ bool FillerDone(TABLE_FILLER *Filler) {
Next = &(Filler->Switch[Filler->NextSwitch]);
- return Filler->X > Next->X && Next->Type == LastSwitch;
+ return Filler->X > Next->X && Next->Type == SWITCH_TYPE::LastSwitch;
} /* FillerDone */
@@ -1306,11 +1306,11 @@ void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill) {
Next = &(Filler->Switch[Filler->NextSwitch]);
while (Filler->X >= Next->X) {
Fill->X = Filler->X = Next->X;
- if (Next->Type == StartSwitch) {
+ if (Next->Type == SWITCH_TYPE::StartSwitch) {
Fill->YStart = Next->Y;
Filler->StartDelta = Next->Delta;
Filler->YStart = Next->YInit;
- } else if (Next->Type == EndSwitch) {
+ } else if (Next->Type == SWITCH_TYPE::EndSwitch) {
Fill->YEnd = Next->Y;
Filler->EndDelta = Next->Delta;
Filler->YEnd = Next->YInit;
@@ -1367,7 +1367,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
Filler->YEnd = Bucket16For(Y + SidePad, YS, NB * 256);
Filler->StartDelta = 0;
Filler->EndDelta = 0;
- Filler->Switch[0].Type = LastSwitch;
+ Filler->Switch[0].Type = SWITCH_TYPE::LastSwitch;
Filler->Switch[0].X = Bucket8For(X + HalfLength + EndPad, XS, NB);
} else if (fabs(Angle - 0.25) < HV_TOLERANCE || fabs(Angle - 0.75) < HV_TOLERANCE) {
/* vertical proto - handle as special case */
@@ -1376,7 +1376,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
Filler->YEnd = Bucket16For(Y + HalfLength + EndPad, YS, NB * 256);
Filler->StartDelta = 0;
Filler->EndDelta = 0;
- Filler->Switch[0].Type = LastSwitch;
+ Filler->Switch[0].Type = SWITCH_TYPE::LastSwitch;
Filler->Switch[0].X = Bucket8For(X + SidePad, XS, NB);
} else {
/* diagonal proto */
@@ -1413,7 +1413,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
YAdjust = XAdjust * Sin / Cos;
Filler->YEnd = Bucket16For(Start.y + YAdjust, YS, NB * 256);
- Filler->Switch[S1].Type = StartSwitch;
+ Filler->Switch[S1].Type = SWITCH_TYPE::StartSwitch;
Filler->Switch[S1].X = Bucket8For(Switch1.x, XS, NB);
Filler->Switch[S1].Y = Bucket8For(Switch1.y, YS, NB);
XAdjust = Switch1.x - BucketStart(Filler->Switch[S1].X, XS, NB);
@@ -1421,7 +1421,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
Filler->Switch[S1].YInit = Bucket16For(Switch1.y - YAdjust, YS, NB * 256);
Filler->Switch[S1].Delta = Filler->EndDelta;
- Filler->Switch[S2].Type = EndSwitch;
+ Filler->Switch[S2].Type = SWITCH_TYPE::EndSwitch;
Filler->Switch[S2].X = Bucket8For(Switch2.x, XS, NB);
Filler->Switch[S2].Y = Bucket8For(Switch2.y, YS, NB);
XAdjust = Switch2.x - BucketStart(Filler->Switch[S2].X, XS, NB);
@@ -1429,7 +1429,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
Filler->Switch[S2].YInit = Bucket16For(Switch2.y + YAdjust, YS, NB * 256);
Filler->Switch[S2].Delta = Filler->StartDelta;
- Filler->Switch[2].Type = LastSwitch;
+ Filler->Switch[2].Type = SWITCH_TYPE::LastSwitch;
Filler->Switch[2].X = Bucket8For(End.x, XS, NB);
} else {
/* falling diagonal proto */
@@ -1465,7 +1465,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
YAdjust = XAdjust * Cos / Sin;
Filler->YEnd = Bucket16For(Start.y + YAdjust, YS, NB * 256);
- Filler->Switch[S1].Type = EndSwitch;
+ Filler->Switch[S1].Type = SWITCH_TYPE::EndSwitch;
Filler->Switch[S1].X = Bucket8For(Switch1.x, XS, NB);
Filler->Switch[S1].Y = Bucket8For(Switch1.y, YS, NB);
XAdjust = Switch1.x - BucketStart(Filler->Switch[S1].X, XS, NB);
@@ -1473,7 +1473,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
Filler->Switch[S1].YInit = Bucket16For(Switch1.y + YAdjust, YS, NB * 256);
Filler->Switch[S1].Delta = Filler->StartDelta;
- Filler->Switch[S2].Type = StartSwitch;
+ Filler->Switch[S2].Type = SWITCH_TYPE::StartSwitch;
Filler->Switch[S2].X = Bucket8For(Switch2.x, XS, NB);
Filler->Switch[S2].Y = Bucket8For(Switch2.y, YS, NB);
XAdjust = Switch2.x - BucketStart(Filler->Switch[S2].X, XS, NB);
@@ -1481,7 +1481,7 @@ void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *
Filler->Switch[S2].YInit = Bucket16For(Switch2.y - YAdjust, YS, NB * 256);
Filler->Switch[S2].Delta = Filler->EndDelta;
- Filler->Switch[2].Type = LastSwitch;
+ Filler->Switch[2].Type = SWITCH_TYPE::LastSwitch;
Filler->Switch[2].X = Bucket8For(End.x, XS, NB);
}
}
diff --git a/src/classify/mfoutline.cpp b/src/classify/mfoutline.cpp
index 4c2aac77..219fe501 100644
--- a/src/classify/mfoutline.cpp
+++ b/src/classify/mfoutline.cpp
@@ -33,7 +33,7 @@ namespace tesseract {
*/
LIST ConvertBlob(TBLOB *blob) {
LIST outlines = NIL_LIST;
- return (blob == nullptr) ? NIL_LIST : ConvertOutlines(blob->outlines, outlines, outer);
+ return (blob == nullptr) ? NIL_LIST : ConvertOutlines(blob->outlines, outlines, OUTLINETYPE::outer);
}
/*---------------------------------------------------------------------------*/
@@ -340,10 +340,10 @@ void ComputeDirection(MFEDGEPT *Start, MFEDGEPT *Finish, float MinSlope, float M
if (Delta.x == 0) {
if (Delta.y < 0) {
Start->Slope = -FLT_MAX;
- Start->Direction = south;
+ Start->Direction = DIRECTION::south;
} else {
Start->Slope = FLT_MAX;
- Start->Direction = north;
+ Start->Direction = DIRECTION::north;
}
} else {
Start->Slope = Delta.y / Delta.x;
@@ -351,40 +351,40 @@ void ComputeDirection(MFEDGEPT *Start, MFEDGEPT *Finish, float MinSlope, float M
if (Delta.y > 0) {
if (Start->Slope > MinSlope) {
if (Start->Slope < MaxSlope) {
- Start->Direction = northeast;
+ Start->Direction = DIRECTION::northeast;
} else {
- Start->Direction = north;
+ Start->Direction = DIRECTION::north;
}
} else {
- Start->Direction = east;
+ Start->Direction = DIRECTION::east;
}
} else if (Start->Slope < -MinSlope) {
if (Start->Slope > -MaxSlope) {
- Start->Direction = southeast;
+ Start->Direction = DIRECTION::southeast;
} else {
- Start->Direction = south;
+ Start->Direction = DIRECTION::south;
}
} else {
- Start->Direction = east;
+ Start->Direction = DIRECTION::east;
}
} else if (Delta.y > 0) {
if (Start->Slope < -MinSlope) {
if (Start->Slope > -MaxSlope) {
- Start->Direction = northwest;
+ Start->Direction = DIRECTION::northwest;
} else {
- Start->Direction = north;
+ Start->Direction = DIRECTION::north;
}
} else {
- Start->Direction = west;
+ Start->Direction = DIRECTION::west;
}
} else if (Start->Slope > MinSlope) {
if (Start->Slope < MaxSlope) {
- Start->Direction = southwest;
+ Start->Direction = DIRECTION::southwest;
} else {
- Start->Direction = south;
+ Start->Direction = DIRECTION::south;
}
} else {
- Start->Direction = west;
+ Start->Direction = DIRECTION::west;
}
}
Finish->PreviousDirection = Start->Direction;
diff --git a/src/classify/mfoutline.h b/src/classify/mfoutline.h
index b0045df5..dece79ef 100644
--- a/src/classify/mfoutline.h
+++ b/src/classify/mfoutline.h
@@ -27,7 +27,7 @@ namespace tesseract {
using MFOUTLINE = LIST;
-enum DIRECTION : uint8_t { north, south, east, west, northeast, northwest, southeast, southwest };
+enum class DIRECTION : uint8_t { north, south, east, west, northeast, northwest, southeast, southwest };
struct MFEDGEPT {
// Inline functions for manipulating micro-feature outline edge points.
@@ -48,7 +48,7 @@ struct MFEDGEPT {
DIRECTION PreviousDirection;
};
-enum OUTLINETYPE { outer, hole };
+enum class OUTLINETYPE { outer, hole };
enum NORM_METHOD { baseline, character };
diff --git a/src/training/cntraining.cpp b/src/training/cntraining.cpp
index 6116ba87..47f7feb6 100644
--- a/src/training/cntraining.cpp
+++ b/src/training/cntraining.cpp
@@ -49,7 +49,7 @@ static void WriteProtos(FILE *File, uint16_t N, LIST ProtoList, bool WriteSigPro
----------------------------------------------------------------------------*/
/* global variable to hold configuration parameters to control clustering */
//-M 0.025 -B 0.05 -I 0.8 -C 1e-3
-static const CLUSTERCONFIG CNConfig = {elliptical, 0.025, 0.05, 0.8, 1e-3, 0};
+static const CLUSTERCONFIG CNConfig = {PROTOSTYLE::elliptical, 0.025, 0.05, 0.8, 1e-3, 0};
/*----------------------------------------------------------------------------
Public Code
diff --git a/src/training/common/commontraining.cpp b/src/training/common/commontraining.cpp
index 60f3bd64..9303266b 100644
--- a/src/training/common/commontraining.cpp
+++ b/src/training/common/commontraining.cpp
@@ -86,7 +86,7 @@ namespace tesseract {
// global variable to hold configuration parameters to control clustering
// -M 0.625 -B 0.05 -I 1.0 -C 1e-6.
-CLUSTERCONFIG Config = {elliptical, 0.625, 0.05, 1.0, 1e-6, 0};
+CLUSTERCONFIG Config = {PROTOSTYLE::elliptical, 0.625, 0.05, 1.0, 1e-6, 0};
FEATURE_DEFS_STRUCT feature_defs;
static CCUtil ccutil;