21#define _USE_MATH_DEFINES
36#ifndef GRAPHICS_DISABLED
50#define PROTO_PRUNER_SCALE (4.0)
52#define INT_DESCENDER (0.0 * INT_CHAR_NORM_RANGE)
53#define INT_BASELINE (0.25 * INT_CHAR_NORM_RANGE)
54#define INT_XHEIGHT (0.75 * INT_CHAR_NORM_RANGE)
55#define INT_CAPHEIGHT (1.0 * INT_CHAR_NORM_RANGE)
57#define INT_XCENTER (0.5 * INT_CHAR_NORM_RANGE)
58#define INT_YCENTER (0.5 * INT_CHAR_NORM_RANGE)
59#define INT_XRADIUS (0.2 * INT_CHAR_NORM_RANGE)
60#define INT_YRADIUS (0.2 * INT_CHAR_NORM_RANGE)
63#define INT_MAX_X INT_CHAR_NORM_RANGE
64#define INT_MAX_Y INT_CHAR_NORM_RANGE
67#define HV_TOLERANCE (0.0025)
70#define MAX_NUM_SWITCHES 3
95#define OLD_MAX_NUM_CONFIGS 32
96#define OLD_WERDS_PER_CONFIG_VEC ((OLD_MAX_NUM_CONFIGS + BITS_PER_WERD - 1) / BITS_PER_WERD)
102#define CircularIncrement(i, r) (((i) < (r)-1) ? ((i)++) : ((i) = 0))
105#define MapParam(P, O, N) (std::floor(((P) + (O)) * (N)))
110float BucketStart(
int Bucket,
float Offset,
int NumBuckets);
112float BucketEnd(
int Bucket,
float Offset,
int NumBuckets);
114void DoFill(FILL_SPEC *FillSpec, CLASS_PRUNER_STRUCT *Pruner, uint32_t ClassMask,
115 uint32_t ClassCount, uint32_t WordIndex);
120 float Center,
float Spread,
bool debug);
123 float Center,
float Spread,
bool debug);
125void GetCPPadsForLevel(
int Level,
float *EndPad,
float *SidePad,
float *AnglePad);
129void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill);
131void InitTableFiller(
float EndPad,
float SidePad,
float AnglePad, PROTO_STRUCT *Proto,
132 TABLE_FILLER *Filler);
134#ifndef GRAPHICS_DISABLED
145#ifndef GRAPHICS_DISABLED
147static ScrollView *IntMatchWindow =
nullptr;
148static ScrollView *FeatureDisplayWindow =
nullptr;
149static ScrollView *ProtoDisplayWindow =
nullptr;
157static INT_VAR(classify_num_cp_levels, 3,
"Number of Class Pruner Levels");
158static double_VAR(classify_cp_angle_pad_loose, 45.0,
"Class Pruner Angle Pad Loose");
159static double_VAR(classify_cp_angle_pad_medium, 20.0,
"Class Pruner Angle Pad Medium");
160static double_VAR(classify_cp_angle_pad_tight, 10.0,
"CLass Pruner Angle Pad Tight");
161static double_VAR(classify_cp_end_pad_loose, 0.5,
"Class Pruner End Pad Loose");
162static double_VAR(classify_cp_end_pad_medium, 0.5,
"Class Pruner End Pad Medium");
163static double_VAR(classify_cp_end_pad_tight, 0.5,
"Class Pruner End Pad Tight");
164static double_VAR(classify_cp_side_pad_loose, 2.5,
"Class Pruner Side Pad Loose");
165static double_VAR(classify_cp_side_pad_medium, 1.2,
"Class Pruner Side Pad Medium");
166static double_VAR(classify_cp_side_pad_tight, 0.6,
"Class Pruner Side Pad Tight");
167static double_VAR(classify_pp_angle_pad, 45.0,
"Proto Pruner Angle Pad");
168static double_VAR(classify_pp_end_pad, 0.5,
"Proto Prune End Pad");
169static double_VAR(classify_pp_side_pad, 2.5,
"Proto Pruner Side Pad");
180static int TruncateParam(
float Param,
int Min,
int Max) {
184 }
else if (Param >
Max) {
187 result =
static_cast<int>(std::floor(Param));
198 : X(
ClipToRange<int16_t>(static_cast<int16_t>(pos.x() + 0.5), 0, 255))
199 , Y(
ClipToRange<int16_t>(static_cast<int16_t>(pos.y() + 0.5), 0, 255))
204 : X(static_cast<uint8_t>(
ClipToRange<int>(x, 0, UINT8_MAX)))
205 , Y(static_cast<uint8_t>(
ClipToRange<int>(y, 0, UINT8_MAX)))
206 , Theta(static_cast<uint8_t>(
ClipToRange<int>(theta, 0, UINT8_MAX)))
224 if (
static_cast<unsigned>(ClassId) != Templates->
NumClasses) {
226 "Please make sure that classes are added to templates"
227 " in increasing order of ClassIds\n");
281 memset(ProtoSet, 0,
sizeof(*ProtoSet));
290 for (uint32_t *Word = Proto->Configs; Word < Proto->Configs +
WERDS_PER_CONFIG_VEC; *Word++ = 0) {
314 float EndPad, SidePad, AnglePad;
322 for (Level = classify_num_cp_levels - 1; Level >= 0; Level--) {
329 DoFill(&FillSpec, Pruner, ClassMask, ClassCount, WordIndex);
349 tprintf(
"AddProtoToProtoPruner:assert failed: %d < %d", ProtoId, Class->
NumProtos);
351 assert(ProtoId < Class->NumProtos);
356 float Angle = Proto->
Angle;
358 assert(!std::isnan(Angle));
362 classify_pp_angle_pad / 360.0, debug);
368 Pad = std::max(fabs(std::cos(Angle)) * (Length / 2.0 + classify_pp_end_pad *
GetPicoFeatureLength()),
374 Pad = std::max(fabs(std::sin(Angle)) * (Length / 2.0 + classify_pp_end_pad *
GetPicoFeatureLength()),
385uint8_t
Bucket8For(
float param,
float offset,
int num_buckets) {
387 return static_cast<uint8_t
>(ClipToRange<int>(bucket, 0, num_buckets - 1));
391 return static_cast<uint16_t
>(ClipToRange<int>(bucket, 0, num_buckets - 1));
401 return static_cast<uint8_t
>(
Modulo(bucket, num_buckets));
404#ifndef GRAPHICS_DISABLED
414 if (IntMatchWindow !=
nullptr) {
435 for (ProtoId = 0, TotalLength = 0; ProtoId < Class->
NumProtos; ProtoId++) {
453 assert(ProtoId < Class->NumProtos);
457 float Param = Proto->
A * 128;
458 P->
A = TruncateParam(
Param, -128, 127);
461 P->
B = TruncateParam(
Param, 0, 255);
464 P->
C = TruncateParam(
Param, -128, 127);
467 if (Param < 0 || Param >= 256) {
476 if (classify_learning_debug_level >= 2) {
477 tprintf(
"Converted ffeat to (A=%d,B=%d,C=%d,L=%d)", P->
A, P->
B, P->
C,
499 for (
unsigned ClassId = 0; ClassId < target_unicharset.
size(); ClassId++) {
500 FClass = &(FloatProtos[ClassId]);
502 strcmp(target_unicharset.
id_to_unichar(ClassId),
" ") != 0) {
503 tprintf(
"Warning: no protos/configs for %s in CreateIntTemplates()\n",
509 for (
unsigned i = 0; i < fs.size(); ++i) {
515 for (ProtoId = 0; ProtoId < FClass->
NumProtos; ProtoId++) {
519 classify_learning_debug_level >= 2);
523 for (ConfigId = 0; ConfigId < FClass->
NumConfigs; ConfigId++) {
528 return (IntTemplates);
531#ifndef GRAPHICS_DISABLED
544 if (FeatureDisplayWindow) {
562 if (ProtoDisplayWindow) {
585 memset(ProtoSet, 0,
sizeof(*ProtoSet));
634 int b, bit_number, last_cp_bit_number, new_b, new_i, new_w;
638 uint32_t SetBitsForMask =
640 uint32_t Mask, NewMask, ClassBits;
647 uint32_t unicharset_size;
648 if (fp->
FReadEndian(&unicharset_size,
sizeof(unicharset_size), 1) != 1) {
649 tprintf(
"Bad read of inttemp!\n");
651 int32_t version_id = 0;
652 if (fp->
FReadEndian(&version_id,
sizeof(version_id), 1) != 1 ||
654 tprintf(
"Bad read of inttemp!\n");
656 if (version_id < 0) {
658 version_id = -version_id;
660 tprintf(
"Bad read of inttemp!\n");
666 if (version_id < 3) {
671 if (version_id < 2) {
673 if (fp->
FReadEndian(&IndexFor[0],
sizeof(IndexFor[0]), unicharset_size) != unicharset_size) {
674 tprintf(
"Bad read of inttemp!\n");
678 tprintf(
"Bad read of inttemp!\n");
686 if (fp->
FReadEndian(Pruner,
sizeof(Pruner->
p[0][0][0][0]), kNumBuckets) != kNumBuckets) {
687 tprintf(
"Bad read of inttemp!\n");
689 if (version_id < 2) {
690 TempClassPruner[i] = Pruner;
697 if (version_id < 2) {
700 for (
unsigned i = 0; i < Templates->
NumClasses; i++) {
701 if (ClassIdFor[i] > max_class_id) {
702 max_class_id = ClassIdFor[i];
717 if (TempClassPruner[i]->p[x][y][z][w] == 0) {
722 if (bit_number > last_cp_bit_number) {
727 Mask = SetBitsForMask << b;
728 ClassBits = TempClassPruner[i]->p[x][y][z][w] & Mask;
735 ClassBits <<= (new_b - b);
737 ClassBits >>= (b - new_b);
741 NewMask = SetBitsForMask << new_b;
742 Templates->
ClassPruners[new_i]->
p[x][y][z][new_w] &= ~NewMask;
743 Templates->
ClassPruners[new_i]->
p[x][y][z][new_w] |= ClassBits;
751 delete TempClassPruner[i];
756 for (
unsigned i = 0; i < Templates->
NumClasses; i++) {
762 tprintf(
"Bad read of inttemp!\n");
764 if (version_id == 0) {
766 for (j = 0; j < 5; ++j) {
768 if (fp->
FRead(&junk,
sizeof(junk), 1) != 1) {
769 tprintf(
"Bad read of inttemp!\n");
773 unsigned num_configs = version_id < 4 ? MaxNumConfigs : Class->
NumConfigs;
776 tprintf(
"Bad read of inttemp!\n");
778 if (version_id < 2) {
790 tprintf(
"Bad read of inttemp!\n");
798 if (fp->
FReadEndian(&ProtoSet->ProtoPruner,
sizeof(ProtoSet->ProtoPruner[0][0][0]),
799 num_buckets) != num_buckets) {
800 tprintf(
"Bad read of inttemp!\n");
803 if (fp->
FRead(&ProtoSet->Protos[x].A,
sizeof(ProtoSet->Protos[x].A), 1) != 1 ||
804 fp->
FRead(&ProtoSet->Protos[x].B,
sizeof(ProtoSet->Protos[x].B), 1) != 1 ||
805 fp->
FRead(&ProtoSet->Protos[x].C,
sizeof(ProtoSet->Protos[x].C), 1) != 1 ||
806 fp->
FRead(&ProtoSet->Protos[x].Angle,
sizeof(ProtoSet->Protos[x].Angle), 1) != 1) {
807 tprintf(
"Bad read of inttemp!\n");
809 if (fp->
FReadEndian(&ProtoSet->Protos[x].Configs,
sizeof(ProtoSet->Protos[x].Configs[0]),
810 WerdsPerConfigVec) != WerdsPerConfigVec) {
811 tprintf(
"Bad read of inttemp!\n");
816 if (version_id < 4) {
823 if (version_id < 2) {
831 if (i < Templates->NumClasses) {
833 fprintf(stderr,
"Non-contiguous class ids in inttemp\n");
838 fprintf(stderr,
"Class id %u exceeds NumClassesIn (Templates) %u\n", i,
845 if (version_id >= 4) {
846 using namespace std::placeholders;
848 if (version_id >= 5) {
857#ifndef GRAPHICS_DISABLED
868 if (ProtoDisplayWindow) {
869 ProtoDisplayWindow->
Clear();
871 if (FeatureDisplayWindow) {
872 FeatureDisplayWindow->
Clear();
877 if (ProtoDisplayWindow) {
880 if (FeatureDisplayWindow) {
920 auto unicharset_size = target_unicharset.
size();
923 if (Templates->
NumClasses != unicharset_size) {
925 "Warning: executing WriteIntTemplates() with %d classes in"
926 " Templates, while target_unicharset size is %zu\n",
931 fwrite(&unicharset_size,
sizeof(unicharset_size), 1,
File);
932 fwrite(&version_id,
sizeof(version_id), 1,
File);
942 for (
unsigned i = 0; i < Templates->
NumClasses; i++) {
943 Class = Templates->
Class[i];
969 using namespace std::placeholders;
990 return static_cast<float>(Bucket) / NumBuckets - Offset;
1006 return static_cast<float>(Bucket + 1) / NumBuckets - Offset;
1020 uint32_t ClassCount, uint32_t WordIndex) {
1032 if (FillSpec->
YStart < 0) {
1039 for (Y = FillSpec->
YStart; Y <= FillSpec->YEnd; Y++) {
1041 OldWord = Pruner->
p[X][Y][Angle][WordIndex];
1042 if (ClassCount > (OldWord & ClassMask)) {
1043 OldWord &= ~ClassMask;
1044 OldWord |= ClassCount;
1045 Pruner->
p[X][Y][Angle][WordIndex] = OldWord;
1084 float Center,
float Spread,
bool debug) {
1085 int i, FirstBucket, LastBucket;
1091 FirstBucket =
static_cast<int>(std::floor((Center - Spread) *
NUM_PP_BUCKETS));
1092 if (FirstBucket < 0) {
1096 LastBucket =
static_cast<int>(std::floor((Center + Spread) *
NUM_PP_BUCKETS));
1101 tprintf(
"Circular fill from %d to %d", FirstBucket, LastBucket);
1107 if (i == LastBucket) {
1129 float Center,
float Spread,
bool debug) {
1130 int i, FirstBucket, LastBucket;
1132 FirstBucket =
static_cast<int>(std::floor((Center - Spread) *
NUM_PP_BUCKETS));
1133 if (FirstBucket < 0) {
1137 LastBucket =
static_cast<int>(std::floor((Center + Spread) *
NUM_PP_BUCKETS));
1143 tprintf(
"Linear fill from %d to %d", FirstBucket, LastBucket);
1145 for (i = FirstBucket; i <= LastBucket; i++) {
1152#ifndef GRAPHICS_DISABLED
1168 int unichar_id = INVALID_UNICHAR_ID;
1177 *adaptive_on =
false;
1178 *pretrained_on =
true;
1182 tprintf(
"Shape %d, first unichar=%d, font=%d\n", *shape_id, unichar_id, font_id);
1187 tprintf(
"No shape table loaded!\n");
1193 *adaptive_on =
true;
1194 *pretrained_on =
false;
1197 *adaptive_on =
false;
1198 *pretrained_on =
true;
1200 *adaptive_on =
true;
1201 *pretrained_on =
true;
1240 *AnglePad = classify_cp_angle_pad_loose / 360.0;
1246 *AnglePad = classify_cp_angle_pad_medium / 360.0;
1252 *AnglePad = classify_cp_angle_pad_tight / 360.0;
1258 *AnglePad = classify_cp_angle_pad_tight / 360.0;
1261 if (*AnglePad > 0.5) {
1273 assert(Evidence >= 0.0);
1274 assert(Evidence <= 1.0);
1276 if (Evidence >= 0.90) {
1278 }
else if (Evidence >= 0.75) {
1280 }
else if (Evidence >= 0.50) {
1301 Fill->
X = Filler->
X;
1307 while (Filler->
X >= Next->
X) {
1308 Fill->
X = Filler->
X = Next->
X;
1314 Fill->
YEnd = Next->
Y;
1343#define AS ANGLE_SHIFT
1344#define NB NUM_CP_BUCKETS
1347 float X, Y, HalfLength;
1349 float XAdjust, YAdjust;
1350 FPOINT Start, Switch1, Switch2, End;
1354 Angle = Proto->
Angle;
1357 HalfLength = Proto->
Length / 2.0;
1384 if ((Angle > 0.0 && Angle < 0.25) || (Angle > 0.5 && Angle < 0.75)) {
1386 Angle *= 2.0 * M_PI;
1387 Cos = fabs(std::cos(Angle));
1388 Sin = fabs(std::sin(Angle));
1391 Start.
x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
1392 Start.
y = Y - (HalfLength + EndPad) * Sin + SidePad * Cos;
1393 End.
x = 2.0 * X - Start.
x;
1394 End.
y = 2.0 * Y - Start.
y;
1395 Switch1.
x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
1396 Switch1.
y = Y - (HalfLength + EndPad) * Sin - SidePad * Cos;
1397 Switch2.
x = 2.0 * X - Switch1.
x;
1398 Switch2.
y = 2.0 * Y - Switch1.
y;
1400 if (Switch1.
x > Switch2.
x) {
1407 Filler->
StartDelta = -
static_cast<int16_t
>((Cos / Sin) * 256);
1408 Filler->
EndDelta =
static_cast<int16_t
>((Sin / Cos) * 256);
1411 YAdjust = XAdjust * Cos / Sin;
1413 YAdjust = XAdjust * Sin / Cos;
1420 YAdjust = XAdjust * Sin / Cos;
1428 YAdjust = XAdjust * Cos / Sin;
1436 Angle *= 2.0 * M_PI;
1437 Cos = fabs(std::cos(Angle));
1438 Sin = fabs(std::sin(Angle));
1441 Start.
x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
1442 Start.
y = Y + (HalfLength + EndPad) * Sin - SidePad * Cos;
1443 End.
x = 2.0 * X - Start.
x;
1444 End.
y = 2.0 * Y - Start.
y;
1445 Switch1.
x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
1446 Switch1.
y = Y + (HalfLength + EndPad) * Sin + SidePad * Cos;
1447 Switch2.
x = 2.0 * X - Switch1.
x;
1448 Switch2.
y = 2.0 * Y - Switch1.
y;
1450 if (Switch1.
x > Switch2.
x) {
1458 ClipToRange<int>(-
IntCastRounded((Sin / Cos) * 256), INT16_MIN, INT16_MAX));
1459 Filler->
EndDelta =
static_cast<int16_t
>(
1460 ClipToRange<int>(
IntCastRounded((Cos / Sin) * 256), INT16_MIN, INT16_MAX));
1463 YAdjust = XAdjust * Sin / Cos;
1465 YAdjust = XAdjust * Cos / Sin;
1472 YAdjust = XAdjust * Sin / Cos;
1480 YAdjust = XAdjust * Cos / Sin;
1491#ifndef GRAPHICS_DISABLED
1502 float X, Y, Dx, Dy, Length;
1505 assert(Feature !=
nullptr);
1513 Dx = (Length / 2.0) * cos((Feature->
Theta / 256.0) * 2.0 * M_PI - M_PI);
1514 Dy = (Length / 2.0) * sin((Feature->
Theta / 256.0) * 2.0 * M_PI - M_PI);
1517 window->
DrawTo(X + Dx, Y + Dy);
1540 int Xmin, Xmax, Ymin, Ymax;
1545 assert(ProtoId >= 0);
1546 assert(Class !=
nullptr);
1547 assert(ProtoId < Class->NumProtos);
1553 Proto = &(ProtoSet->Protos[ProtoSetIndex]);
1562 if (ProtoMask & ProtoSet->ProtoPruner[
PRUNER_X][Bucket][ProtoWordIndex]) {
1566 if (ProtoMask & ProtoSet->ProtoPruner[
PRUNER_Y][Bucket][ProtoWordIndex]) {
1574 Dx = (Length / 2.0) * cos((Proto->
Angle / 256.0) * 2.0 * M_PI - M_PI);
1575 Dy = (Length / 2.0) * sin((Proto->
Angle / 256.0) * 2.0 * M_PI - M_PI);
1578 window->
DrawTo(X + Dx, Y + Dy);
1582#ifndef GRAPHICS_DISABLED
1588 if (IntMatchWindow ==
nullptr) {
1592 popup_menu->AddChild(
"Debug Adapted classes",
IDA_ADAPTIVE,
"x",
"Class to debug");
1593 popup_menu->AddChild(
"Debug Static classes",
IDA_STATIC,
"x",
"Class to debug");
1594 popup_menu->AddChild(
"Debug Both",
IDA_BOTH,
"x",
"Class to debug");
1595 popup_menu->AddChild(
"Debug Shape Index",
IDA_SHAPE_INDEX,
"0",
"Index to debug");
1596 popup_menu->BuildMenu(IntMatchWindow,
false);
1605 if (ProtoDisplayWindow ==
nullptr) {
1615 if (FeatureDisplayWindow ==
nullptr) {
1623 return new ScrollView(name, xpos, ypos, 520, 520, 260, 260,
true);
#define test_bit(array, bit)
#define SET_BIT(array, bit)
#define ProtoIn(Class, Pid)
#define GetPicoFeatureLength()
#define PPrunerWordIndexFor(I)
#define BITS_PER_CP_VECTOR
#define MaxNumIntProtosIn(C)
#define MAX_NUM_PROTO_SETS
#define UnusedClassIdIn(T, c)
#define WERDS_PER_PP_VECTOR
#define INT_CHAR_NORM_RANGE
#define ClassForClassId(T, c)
#define MaxNumClassesIn(T)
#define WERDS_PER_CONFIG_VEC
#define CPrunerWordIndexFor(c)
#define CPrunerBitIndexFor(c)
#define PPrunerMaskFor(I)
#define MAX_NUM_CLASS_PRUNERS
#define WERDS_PER_CP_VECTOR
#define PROTOS_PER_PROTO_SET
#define NUM_BITS_PER_CLASS
#define CPrunerMaskFor(L, c)
#define ProtoForProtoId(C, P)
#define OLD_MAX_NUM_CONFIGS
#define CircularIncrement(i, r)
#define MapParam(P, O, N)
#define PROTO_PRUNER_SCALE
#define OLD_WERDS_PER_CONFIG_VEC
#define INT_VAR(name, val, comment)
#define double_VAR(name, val, comment)
bool FillerDone(TABLE_FILLER *Filler)
void AddIntClass(INT_TEMPLATES_STRUCT *Templates, CLASS_ID ClassId, INT_CLASS_STRUCT *Class)
void AddProtoToProtoPruner(PROTO_STRUCT *Proto, int ProtoId, INT_CLASS_STRUCT *Class, bool debug)
void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill)
void InitTableFiller(float EndPad, float SidePad, float AnglePad, PROTO_STRUCT *Proto, TABLE_FILLER *Filler)
uint8_t Bucket8For(float param, float offset, int num_buckets)
void ConvertConfig(BIT_VECTOR Config, int ConfigId, INT_CLASS_STRUCT *Class)
void DoFill(FILL_SPEC *FillSpec, CLASS_PRUNER_STRUCT *Pruner, uint32_t ClassMask, uint32_t ClassCount, uint32_t WordIndex)
void FillPPCircularBits(uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, float Center, float Spread, bool debug)
bool write_set(FILE *f, const FontSet &fs)
bool write_info(FILE *f, const FontInfo &fi)
void DisplayIntFeature(const INT_FEATURE_STRUCT *Feature, float Evidence)
void tprintf(const char *format,...)
int IntCastRounded(double x)
bool write_spacing_info(FILE *f, const FontInfo &fi)
float BucketEnd(int Bucket, float Offset, int NumBuckets)
uint8_t CircBucketFor(float param, float offset, int num_buckets)
ScrollView::Color GetMatchColorFor(float Evidence)
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
std::vector< int > FontSet
float BucketStart(int Bucket, float Offset, int NumBuckets)
void FillPPLinearBits(uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, float Center, float Spread, bool debug)
void InitIntMatchWindowIfReqd()
void InitFeatureDisplayWindowIfReqd()
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
uint16_t Bucket16For(float param, float offset, int num_buckets)
bool read_info(TFile *f, FontInfo *fi)
void DisplayIntProto(INT_CLASS_STRUCT *Class, PROTO_ID ProtoId, float Evidence)
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
void GetCPPadsForLevel(int Level, float *EndPad, float *SidePad, float *AnglePad)
void AddProtoToClassPruner(PROTO_STRUCT *Proto, CLASS_ID ClassId, INT_TEMPLATES_STRUCT *Templates)
void InitProtoDisplayWindowIfReqd()
void UpdateMatchDisplay()
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
void RenderIntProto(ScrollView *window, INT_CLASS_STRUCT *Class, PROTO_ID ProtoId, ScrollView::Color color)
int AddIntConfig(INT_CLASS_STRUCT *Class)
bool read_spacing_info(TFile *f, FontInfo *fi)
int AddIntProto(INT_CLASS_STRUCT *Class)
int size() const
Return the size used.
int push_back(T object)
Add an element in the table.
const T & at(int id) const
Return the object from an id.
bool write(FILE *f, std::function< bool(FILE *, const T &)> cb) const
bool read(tesseract::TFile *f, std::function< bool(tesseract::TFile *, T *)> cb)
size_t FReadEndian(void *buffer, size_t size, size_t count)
bool DeSerialize(std::string &data)
size_t FRead(void *buffer, size_t size, size_t count)
const char * id_to_unichar(UNICHAR_ID id) const
bool contains_unichar(const char *const unichar_repr) const
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
INT_TEMPLATES_STRUCT * CreateIntTemplates(CLASSES FloatProtos, const UNICHARSET &target_unicharset)
void WriteIntTemplates(FILE *File, INT_TEMPLATES_STRUCT *Templates, const UNICHARSET &target_unicharset)
ShapeTable * shape_table_
void ConvertProto(PROTO_STRUCT *Proto, int ProtoId, INT_CLASS_STRUCT *Class)
UnicityTable< FontSet > fontset_table_
CLASS_ID GetClassToDebug(const char *Prompt, bool *adaptive_on, bool *pretrained_on, int *shape_id)
INT_TEMPLATES_STRUCT * ReadIntTemplates(TFile *fp)
UnicityTable< FontInfo > fontinfo_table_
FILL_SWITCH Switch[MAX_NUM_SWITCHES]
uint32_t p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
uint32_t Configs[WERDS_PER_CONFIG_VEC]
PROTO_SET_STRUCT * ProtoSets[MAX_NUM_PROTO_SETS]
uint16_t ConfigLengths[MAX_NUM_CONFIGS]
std::vector< uint8_t > ProtoLengths
INT_CLASS_STRUCT()=default
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
INT_CLASS_STRUCT * Class[MAX_NUM_CLASSES]
std::vector< BIT_VECTOR > Configurations
UnicityTable< int > font_set
bool ContainsUnichar(int unichar_id) const
std::string DebugStr(unsigned shape_id) const
unsigned NumShapes() const
const Shape & GetShape(unsigned shape_id) const
void GetFirstUnicharAndFont(unsigned shape_id, int *unichar_id, int *font_id) const
void void ZoomToRectangle(int x1, int y1, int x2, int y2)
void Rectangle(int x1, int y1, int x2, int y2)
void SetCursor(int x, int y)
void DrawTo(int x, int y)
SVEvent * AwaitEvent(SVEventType type)