⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adaptive.cpp

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  #endif  fprintf (File, "\n");}                                /* PrintAdaptedTemplates *//*---------------------------------------------------------------------------*/ADAPT_CLASS ReadAdaptedClass(FILE *File) { /* **	Parameters: **		File	open file to read adapted class from **	Globals: none **	Operation: Read an adapted class description from File and return **		a ptr to the adapted class. **	Return: Ptr to new adapted class. **	Exceptions: none **	History: Tue Mar 19 14:11:01 1991, DSJ, Created. */  int NumTempProtos;  int NumConfigs;  int i;  ADAPT_CLASS Class;  TEMP_PROTO TempProto;  /* first read high level adapted class structure */  Class = (ADAPT_CLASS) Emalloc (sizeof (ADAPT_CLASS_STRUCT));  fread ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);  /* then read in the definitions of the permanent protos and configs */  Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);  Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);  fread ((char *) Class->PermProtos, sizeof (UINT32),    WordsInVectorOfSize (MAX_NUM_PROTOS), File);  fread ((char *) Class->PermConfigs, sizeof (UINT32),    WordsInVectorOfSize (MAX_NUM_CONFIGS), File);  /* then read in the list of temporary protos */  fread ((char *) &NumTempProtos, sizeof (int), 1, File);  Class->TempProtos = NIL;  for (i = 0; i < NumTempProtos; i++) {    TempProto =      (TEMP_PROTO) c_alloc_struct (sizeof (TEMP_PROTO_STRUCT),      "TEMP_PROTO_STRUCT");    fread ((char *) TempProto, sizeof (TEMP_PROTO_STRUCT), 1, File);    Class->TempProtos = push_last (Class->TempProtos, TempProto);  }  /* then read in the adapted configs */  fread ((char *) &NumConfigs, sizeof (int), 1, File);  for (i = 0; i < NumConfigs; i++)    if (test_bit (Class->PermConfigs, i))      Class->Config[i].Perm = ReadPermConfig (File);  else    Class->Config[i].Temp = ReadTempConfig (File);  return (Class);}                                /* ReadAdaptedClass *//*---------------------------------------------------------------------------*/ADAPT_TEMPLATES ReadAdaptedTemplates(FILE *File) { /* **	Parameters: **		File	open text file to read adapted templates from **	Globals: none **	Operation: Read a set of adapted templates from File and return **		a ptr to the templates. **	Return: Ptr to adapted templates read from File. **	Exceptions: none **	History: Mon Mar 18 15:18:10 1991, DSJ, Created. */  int i;  ADAPT_TEMPLATES Templates;  /* first read the high level adaptive template struct */  Templates = (ADAPT_TEMPLATES) Emalloc (sizeof (ADAPT_TEMPLATES_STRUCT));  fread ((char *) Templates, sizeof (ADAPT_TEMPLATES_STRUCT), 1, File);  /* then read in the basic integer templates */  Templates->Templates = ReadIntTemplates (File, FALSE);  /* then read in the adaptive info for each class */  for (i = 0; i < NumClassesIn (Templates->Templates); i++) {    Templates->Class[i] = ReadAdaptedClass (File);  }  return (Templates);}                                /* ReadAdaptedTemplates *//*---------------------------------------------------------------------------*/PERM_CONFIG ReadPermConfig(FILE *File) { /* **	Parameters: **		File	open file to read permanent config from **	Globals: none **	Operation: Read a permanent configuration description from File **		and return a ptr to it. **	Return: Ptr to new permanent configuration description. **	Exceptions: none **	History: Tue Mar 19 14:25:26 1991, DSJ, Created. */  PERM_CONFIG Config;  UINT8 NumAmbigs;  fread ((char *) &NumAmbigs, sizeof (UINT8), 1, File);  Config = (PERM_CONFIG) Emalloc (sizeof (char) * (NumAmbigs + 1));  fread (Config, sizeof (char), NumAmbigs, File);  Config[NumAmbigs] = '\0';  return (Config);}                                /* ReadPermConfig *//*---------------------------------------------------------------------------*/TEMP_CONFIG ReadTempConfig(FILE *File) { /* **	Parameters: **		File	open file to read temporary config from **	Globals: none **	Operation:  Read a temporary configuration description from File **		and return a ptr to it. **	Return: Ptr to new temporary configuration description. **	Exceptions: none **	History: Tue Mar 19 14:29:59 1991, DSJ, Created. */  TEMP_CONFIG Config;  Config =    (TEMP_CONFIG) c_alloc_struct (sizeof (TEMP_CONFIG_STRUCT),    "TEMP_CONFIG_STRUCT");  fread ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);  Config->Protos = NewBitVector (Config->ProtoVectorSize * BITSINLONG);  fread ((char *) Config->Protos, sizeof (UINT32),    Config->ProtoVectorSize, File);  return (Config);}                                /* ReadTempConfig *//*---------------------------------------------------------------------------*/void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) { /* **	Parameters: **		File		open file to write Class to **		Class		adapted class to write to File **		NumConfigs	number of configs in Class **	Globals: none **	Operation: This routine writes a binary representation of Class **		to File. **	Return: none **	Exceptions: none **	History: Tue Mar 19 13:33:51 1991, DSJ, Created. */  int NumTempProtos;  LIST TempProtos;  int i;  /* first write high level adapted class structure */  fwrite ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);  /* then write out the definitions of the permanent protos and configs */  fwrite ((char *) Class->PermProtos, sizeof (UINT32),    WordsInVectorOfSize (MAX_NUM_PROTOS), File);  fwrite ((char *) Class->PermConfigs, sizeof (UINT32),    WordsInVectorOfSize (MAX_NUM_CONFIGS), File);  /* then write out the list of temporary protos */  NumTempProtos = count (Class->TempProtos);  fwrite ((char *) &NumTempProtos, sizeof (int), 1, File);  TempProtos = Class->TempProtos;  iterate (TempProtos) {    void* proto = first(TempProtos);    fwrite ((char *) proto, sizeof (TEMP_PROTO_STRUCT), 1, File);  }  /* then write out the adapted configs */  fwrite ((char *) &NumConfigs, sizeof (int), 1, File);  for (i = 0; i < NumConfigs; i++)    if (test_bit (Class->PermConfigs, i))      WritePermConfig (File, Class->Config[i].Perm);  else    WriteTempConfig (File, Class->Config[i].Temp);}                                /* WriteAdaptedClass *//*---------------------------------------------------------------------------*/void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) { /* **	Parameters: **		File		open text file to write Templates to **		Templates	set of adapted templates to write to File **	Globals: none **	Operation: This routine saves Templates to File in a binary format. **	Return: none **	Exceptions: none **	History: Mon Mar 18 15:07:32 1991, DSJ, Created. */  int i;  /* first write the high level adaptive template struct */  fwrite ((char *) Templates, sizeof (ADAPT_TEMPLATES_STRUCT), 1, File);  /* then write out the basic integer templates */  WriteIntTemplates (File, Templates->Templates);  /* then write out the adaptive info for each class */  for (i = 0; i < NumClassesIn (Templates->Templates); i++) {    WriteAdaptedClass (File, Templates->Class[i],      NumIntConfigsIn (ClassForIndex      (Templates->Templates, i)));  }}                                /* WriteAdaptedTemplates *//*---------------------------------------------------------------------------*/void WritePermConfig(FILE *File, PERM_CONFIG Config) { /* **	Parameters: **		File	open file to write Config to **		Config	permanent config to write to File **	Globals: none **	Operation: This routine writes a binary representation of a **		permanent configuration to File. **	Return: none **	Exceptions: none **	History: Tue Mar 19 13:55:44 1991, DSJ, Created. */  UINT8 NumAmbigs;  assert (Config != NULL);  NumAmbigs = strlen (Config);  fwrite ((char *) &NumAmbigs, sizeof (UINT8), 1, File);  fwrite (Config, sizeof (char), NumAmbigs, File);}                                /* WritePermConfig *//*---------------------------------------------------------------------------*/void WriteTempConfig(FILE *File, TEMP_CONFIG Config) { /* **	Parameters: **		File	open file to write Config to **		Config	temporary config to write to File **	Globals: none **	Operation: This routine writes a binary representation of a **		temporary configuration to File. **	Return: none **	Exceptions: none **	History: Tue Mar 19 14:00:28 1991, DSJ, Created. */  assert (Config != NULL);                                 /* contexts not yet implemented */  assert (Config->ContextsSeen == NULL);  fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);  fwrite ((char *) Config->Protos, sizeof (UINT32),    Config->ProtoVectorSize, File);}                                /* WriteTempConfig */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -