tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
50 assert (Templates !=
nullptr);
51 assert (Class !=
nullptr);
59 assert (Templates->
Class[ClassId] ==
nullptr);
60 Templates->
Class[ClassId] = Class;
75 assert (
Config !=
nullptr);
76 FreeBitVector (
Config->Protos);
82 auto proto = static_cast<PROTO>(arg);
162 Templates->
Class[i] =
nullptr;
184 if (templates !=
nullptr) {
185 for (
int i = 0; i < (templates->
Templates)->NumClasses; i++)
204 int NumProtos = MaxProtoId + 1;
207 Config->Protos = NewBitVector (NumProtos);
210 Config->MaxProtoId = MaxProtoId;
211 Config->ProtoVectorSize = WordsInVectorOfSize (NumProtos);
212 zero_all_bits (
Config->Protos,
Config->ProtoVectorSize);
213 Config->FontinfoId = FontinfoId;
248 fprintf (
File,
"\n\nSUMMARY OF ADAPTED TEMPLATES:\n\n");
249 fprintf (
File,
"Num classes = %d; Num permanent classes = %d\n\n",
251 fprintf (
File,
" Id NC NPC NP NPP\n");
252 fprintf (
File,
"------------------------\n");
254 for (
int i = 0; i < (Templates->
Templates)->NumClasses; i++) {
256 AClass = Templates->
Class[i];
258 fprintf (
File,
"%5d %s %3d %3d %3d %3d\n",
265 fprintf (
File,
"\n");
300 fp->
FRead(&NumTempProtos,
sizeof(
int), 1);
302 for (i = 0; i < NumTempProtos; i++) {
309 fp->
FRead(&NumConfigs,
sizeof(
int), 1);
310 for (i = 0; i < NumConfigs; i++)
343 for (
int i = 0; i < (Templates->
Templates)->NumClasses; i++) {
365 fp->
FRead(&NumAmbigs,
sizeof(NumAmbigs), 1);
368 Config->Ambigs[NumAmbigs] = -1;
425 fwrite(&NumTempProtos,
sizeof(
int), 1, File);
433 fwrite(&NumConfigs,
sizeof(
int), 1, File);
434 for (i = 0; i < NumConfigs; i++)
463 for (i = 0; i < (Templates->
Templates)->NumClasses; i++) {
482 uint8_t NumAmbigs = 0;
484 assert (
Config !=
nullptr);
485 while (
Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
487 fwrite(&NumAmbigs,
sizeof(uint8_t), 1, File);
489 fwrite(&(
Config->FontinfoId),
sizeof(
int), 1, File);
504 assert (
Config !=
nullptr);
507 fwrite(
Config->Protos, sizeof (uint32_t),
Config->ProtoVectorSize, File);
void WriteTempConfig(FILE *File, TEMP_CONFIG Config)
INT_TEMPLATES NewIntTemplates()
#define TempConfigFor(Class, ConfigId)
void destroy_nodes(LIST list, void_dest destructor)
INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs)
ADAPTED_CONFIG Config[MAX_NUM_CONFIGS]
#define test_bit(array, bit)
void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
int FRead(void *buffer, size_t size, int count)
void AddIntClass(INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class)
TEMP_CONFIG ReadTempConfig(TFile *fp)
void free_adapted_templates(ADAPT_TEMPLATES templates)
ADAPT_TEMPLATES ReadAdaptedTemplates(TFile *File)
void FreeTempConfig(TEMP_CONFIG Config)
void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates, const UNICHARSET &target_unicharset)
#define ConfigIsPermanent(Class, ConfigId)
int GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId)
TEMP_CONFIG NewTempConfig(int MaxProtoId, int FontinfoId)
ADAPT_CLASS Class[MAX_NUM_CLASSES]
void free_adapted_class(ADAPT_CLASS adapt_class)
TEMP_PROTO NewTempProto()
INT_CLASS Class[MAX_NUM_CLASSES]
void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs)
INT_TEMPLATES ReadIntTemplates(TFile *fp)
void free_int_templates(INT_TEMPLATES templates)
ADAPT_CLASS NewAdaptedClass()
const char * id_to_unichar(UNICHAR_ID id) const
#define PermConfigFor(Class, ConfigId)
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
void WritePermConfig(FILE *File, PERM_CONFIG Config)
#define UnusedClassIdIn(T, c)
LIST push_last(LIST list, void *item)
ADAPT_CLASS ReadAdaptedClass(TFile *fp)
PERM_CONFIG ReadPermConfig(TFile *fp)
void FreeTempProto(void *arg)
#define IsEmptyAdaptedClass(Class)
ADAPT_TEMPLATES NewAdaptedTemplates(bool InitFromUnicharset)
void AddAdaptedClass(ADAPT_TEMPLATES Templates, ADAPT_CLASS Class, CLASS_ID ClassId)