21#define _USE_MATH_DEFINES
25# include "config_auto.h"
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);
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",
511 for (
unsigned i = 0;
i < fs_size; ++
i) {
517 for (ProtoId = 0; ProtoId < FClass->
NumProtos; ProtoId++) {
521 classify_learning_debug_level >= 2);
525 for (ConfigId = 0; ConfigId < FClass->
NumConfigs; ConfigId++) {
530 return (IntTemplates);
533#ifndef GRAPHICS_DISABLED
546 if (FeatureDisplayWindow) {
564 if (ProtoDisplayWindow) {
587 memset(ProtoSet, 0,
sizeof(*ProtoSet));
636 int b, bit_number, last_cp_bit_number, new_b, new_i, new_w;
640 uint32_t SetBitsForMask =
642 uint32_t Mask, NewMask, ClassBits;
649 uint32_t unicharset_size;
650 if (fp->
FReadEndian(&unicharset_size,
sizeof(unicharset_size), 1) != 1) {
651 tprintf(
"Bad read of inttemp!\n");
653 int32_t version_id = 0;
654 if (fp->
FReadEndian(&version_id,
sizeof(version_id), 1) != 1 ||
656 tprintf(
"Bad read of inttemp!\n");
658 if (version_id < 0) {
660 version_id = -version_id;
662 tprintf(
"Bad read of inttemp!\n");
668 if (version_id < 3) {
673 if (version_id < 2) {
675 if (fp->
FReadEndian(&IndexFor[0],
sizeof(IndexFor[0]), unicharset_size) != unicharset_size) {
676 tprintf(
"Bad read of inttemp!\n");
680 tprintf(
"Bad read of inttemp!\n");
688 if (fp->
FReadEndian(Pruner,
sizeof(Pruner->
p[0][0][0][0]), kNumBuckets) != kNumBuckets) {
689 tprintf(
"Bad read of inttemp!\n");
691 if (version_id < 2) {
692 TempClassPruner[
i] = Pruner;
699 if (version_id < 2) {
703 if (ClassIdFor[
i] > max_class_id) {
704 max_class_id = ClassIdFor[
i];
719 if (TempClassPruner[
i]->
p[
x][
y][
z][w] == 0) {
724 if (bit_number > last_cp_bit_number) {
729 Mask = SetBitsForMask << b;
730 ClassBits = TempClassPruner[
i]->p[
x][
y][
z][w] & Mask;
737 ClassBits <<= (new_b - b);
739 ClassBits >>= (b - new_b);
743 NewMask = SetBitsForMask << new_b;
753 delete TempClassPruner[
i];
764 tprintf(
"Bad read of inttemp!\n");
766 if (version_id == 0) {
768 for (j = 0; j < 5; ++j) {
770 if (fp->
FRead(&junk,
sizeof(junk), 1) != 1) {
771 tprintf(
"Bad read of inttemp!\n");
775 unsigned num_configs = version_id < 4 ? MaxNumConfigs : Class->
NumConfigs;
778 tprintf(
"Bad read of inttemp!\n");
780 if (version_id < 2) {
792 tprintf(
"Bad read of inttemp!\n");
800 if (fp->
FReadEndian(&ProtoSet->ProtoPruner,
sizeof(ProtoSet->ProtoPruner[0][0][0]),
801 num_buckets) != num_buckets) {
802 tprintf(
"Bad read of inttemp!\n");
805 if (fp->
FRead(&ProtoSet->Protos[
x].A,
sizeof(ProtoSet->Protos[
x].A), 1) != 1 ||
806 fp->
FRead(&ProtoSet->Protos[
x].B,
sizeof(ProtoSet->Protos[
x].B), 1) != 1 ||
807 fp->
FRead(&ProtoSet->Protos[
x].C,
sizeof(ProtoSet->Protos[
x].C), 1) != 1 ||
808 fp->
FRead(&ProtoSet->Protos[
x].Angle,
sizeof(ProtoSet->Protos[
x].Angle), 1) != 1) {
809 tprintf(
"Bad read of inttemp!\n");
811 if (fp->
FReadEndian(&ProtoSet->Protos[
x].Configs,
sizeof(ProtoSet->Protos[
x].Configs[0]),
812 WerdsPerConfigVec) != WerdsPerConfigVec) {
813 tprintf(
"Bad read of inttemp!\n");
818 if (version_id < 4) {
825 if (version_id < 2) {
833 if (i < Templates->NumClasses) {
835 fprintf(stderr,
"Non-contiguous class ids in inttemp\n");
840 fprintf(stderr,
"Class id %u exceeds NumClassesIn (Templates) %u\n",
i,
847 if (version_id >= 4) {
848 using namespace std::placeholders;
850 if (version_id >= 5) {
859#ifndef GRAPHICS_DISABLED
870 if (ProtoDisplayWindow) {
871 ProtoDisplayWindow->
Clear();
873 if (FeatureDisplayWindow) {
874 FeatureDisplayWindow->
Clear();
879 if (ProtoDisplayWindow) {
882 if (FeatureDisplayWindow) {
922 uint32_t unicharset_size = target_unicharset.
size();
925 if (Templates->
NumClasses != unicharset_size) {
927 "Warning: executing WriteIntTemplates() with %d classes in"
928 " Templates, while target_unicharset size is %" PRIu32
"\n",
933 fwrite(&unicharset_size,
sizeof(unicharset_size), 1,
File);
934 fwrite(&version_id,
sizeof(version_id), 1,
File);
945 Class = Templates->
Class[
i];
971 using namespace std::placeholders;
992 return static_cast<float>(Bucket) / NumBuckets - Offset;
1008 return static_cast<float>(Bucket + 1) / NumBuckets - Offset;
1022 uint32_t ClassCount, uint32_t WordIndex) {
1034 if (FillSpec->
YStart < 0) {
1041 for (Y = FillSpec->
YStart; Y <= FillSpec->YEnd; Y++) {
1043 OldWord = Pruner->
p[X][Y][Angle][WordIndex];
1044 if (ClassCount > (OldWord & ClassMask)) {
1045 OldWord &= ~ClassMask;
1046 OldWord |= ClassCount;
1047 Pruner->
p[X][Y][Angle][WordIndex] = OldWord;
1086 float Center,
float Spread,
bool debug) {
1087 int i, FirstBucket, LastBucket;
1093 FirstBucket =
static_cast<int>(std::floor((Center - Spread) *
NUM_PP_BUCKETS));
1094 if (FirstBucket < 0) {
1098 LastBucket =
static_cast<int>(std::floor((Center + Spread) *
NUM_PP_BUCKETS));
1103 tprintf(
"Circular fill from %d to %d", FirstBucket, LastBucket);
1109 if (
i == LastBucket) {
1131 float Center,
float Spread,
bool debug) {
1132 int i, FirstBucket, LastBucket;
1134 FirstBucket =
static_cast<int>(std::floor((Center - Spread) *
NUM_PP_BUCKETS));
1135 if (FirstBucket < 0) {
1139 LastBucket =
static_cast<int>(std::floor((Center + Spread) *
NUM_PP_BUCKETS));
1145 tprintf(
"Linear fill from %d to %d", FirstBucket, LastBucket);
1147 for (
i = FirstBucket;
i <= LastBucket;
i++) {
1154#ifndef GRAPHICS_DISABLED
1169 int unichar_id = INVALID_UNICHAR_ID;
1177 *shape_id = atoi(ev->parameter);
1178 *adaptive_on =
false;
1179 *pretrained_on =
true;
1183 tprintf(
"Shape %d, first unichar=%d, font=%d\n", *shape_id, unichar_id, font_id);
1186 tprintf(
"Shape index '%s' not found in shape table\n", ev->parameter);
1188 tprintf(
"No shape table loaded!\n");
1194 *adaptive_on =
true;
1195 *pretrained_on =
false;
1198 *adaptive_on =
false;
1199 *pretrained_on =
true;
1201 *adaptive_on =
true;
1202 *pretrained_on =
true;
1214 tprintf(
"Char class '%s' not found in unicharset", ev->parameter);
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 INT_VAR(name, val, comment)
#define double_VAR(name, val, comment)
#define test_bit(array, bit)
#define SET_BIT(array, bit)
#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 ProtoIn(Class, Pid)
#define GetPicoFeatureLength()
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)
bool write(FILE *f, const std::function< bool(FILE *, const T &)> &cb) const
int size() const
Return the size used.
bool read(tesseract::TFile *f, const std::function< bool(tesseract::TFile *, T *)> &cb)
int push_back(T object)
Add an element in the table.
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
std::unique_ptr< SVEvent > AwaitEvent(SVEventType type)
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)