2007-03-08 04:03:40 +08:00
|
|
|
/******************************************************************************
|
2009-07-11 10:17:36 +08:00
|
|
|
** Filename: adaptive.c
|
|
|
|
** Purpose: Adaptive matcher.
|
|
|
|
** Author: Dan Johnson
|
|
|
|
** History: Fri Mar 8 10:00:21 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
**
|
2009-07-11 10:17:36 +08:00
|
|
|
** (c) Copyright Hewlett-Packard Company, 1988.
|
2007-03-08 04:03:40 +08:00
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2010-07-31 06:46:32 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
2007-03-08 04:03:40 +08:00
|
|
|
Include Files and Type Defines
|
2010-07-31 06:46:32 +08:00
|
|
|
----------------------------------------------------------------------------*/
|
2007-03-08 04:03:40 +08:00
|
|
|
#include "adaptive.h"
|
|
|
|
#include "emalloc.h"
|
2007-07-18 09:15:07 +08:00
|
|
|
#include "globals.h"
|
2009-07-11 10:17:36 +08:00
|
|
|
#include "classify.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
#ifdef __UNIX__
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-04-28 06:48:23 +08:00
|
|
|
using tesseract::TFile;
|
|
|
|
|
2010-07-31 06:46:32 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
2007-03-08 04:03:40 +08:00
|
|
|
Public Code
|
2010-07-31 06:46:32 +08:00
|
|
|
----------------------------------------------------------------------------*/
|
2007-03-08 04:03:40 +08:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine adds a new adapted class to an existing
|
|
|
|
* set of adapted templates.
|
|
|
|
*
|
|
|
|
* @param Templates set of templates to add new class to
|
|
|
|
* @param Class new class to add to templates
|
|
|
|
* @param ClassId class id to associate with new class
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Thu Mar 14 13:06:09 1991, DSJ, Created.
|
|
|
|
*/
|
2009-07-11 10:17:36 +08:00
|
|
|
void AddAdaptedClass(ADAPT_TEMPLATES Templates,
|
|
|
|
ADAPT_CLASS Class,
|
|
|
|
CLASS_ID ClassId) {
|
2007-03-08 04:03:40 +08:00
|
|
|
INT_CLASS IntClass;
|
|
|
|
|
2016-12-13 00:21:24 +08:00
|
|
|
assert (Templates != nullptr);
|
|
|
|
assert (Class != nullptr);
|
2007-03-08 04:03:40 +08:00
|
|
|
assert (LegalClassId (ClassId));
|
|
|
|
assert (UnusedClassIdIn (Templates->Templates, ClassId));
|
|
|
|
assert (Class->NumPermConfigs == 0);
|
|
|
|
|
|
|
|
IntClass = NewIntClass (1, 1);
|
2009-07-11 10:17:36 +08:00
|
|
|
AddIntClass (Templates->Templates, ClassId, IntClass);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2016-12-13 00:21:24 +08:00
|
|
|
assert (Templates->Class[ClassId] == nullptr);
|
2009-07-11 10:17:36 +08:00
|
|
|
Templates->Class[ClassId] = Class;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
} /* AddAdaptedClass */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine frees all memory consumed by a temporary
|
|
|
|
* configuration.
|
|
|
|
*
|
|
|
|
* @param Config config to be freed
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Thu Mar 14 13:34:23 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
void FreeTempConfig(TEMP_CONFIG Config) {
|
2016-12-13 00:21:24 +08:00
|
|
|
assert (Config != nullptr);
|
2007-03-08 04:03:40 +08:00
|
|
|
FreeBitVector (Config->Protos);
|
2016-12-10 06:41:08 +08:00
|
|
|
free(Config);
|
2007-03-08 04:03:40 +08:00
|
|
|
} /* FreeTempConfig */
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2007-05-16 09:30:20 +08:00
|
|
|
void FreeTempProto(void *arg) {
|
2007-03-08 04:03:40 +08:00
|
|
|
PROTO proto = (PROTO) arg;
|
|
|
|
|
2016-12-10 06:41:08 +08:00
|
|
|
free(proto);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
2011-03-22 05:45:36 +08:00
|
|
|
void FreePermConfig(PERM_CONFIG Config) {
|
2016-12-13 00:21:24 +08:00
|
|
|
assert(Config != nullptr);
|
2014-01-25 05:12:35 +08:00
|
|
|
delete [] Config->Ambigs;
|
2016-12-10 06:41:08 +08:00
|
|
|
free(Config);
|
2011-03-22 05:45:36 +08:00
|
|
|
}
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This operation allocates and initializes a new adapted
|
|
|
|
* class data structure and returns a ptr to it.
|
|
|
|
*
|
|
|
|
* @return Ptr to new class data structure.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Thu Mar 14 12:58:13 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
ADAPT_CLASS NewAdaptedClass() {
|
2007-03-08 04:03:40 +08:00
|
|
|
ADAPT_CLASS Class;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
Class = (ADAPT_CLASS) Emalloc (sizeof (ADAPT_CLASS_STRUCT));
|
|
|
|
Class->NumPermConfigs = 0;
|
2010-11-24 02:34:14 +08:00
|
|
|
Class->MaxNumTimesSeen = 0;
|
|
|
|
Class->TempProtos = NIL_LIST;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
|
|
|
|
Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
|
|
|
|
zero_all_bits (Class->PermProtos, WordsInVectorOfSize (MAX_NUM_PROTOS));
|
|
|
|
zero_all_bits (Class->PermConfigs, WordsInVectorOfSize (MAX_NUM_CONFIGS));
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_NUM_CONFIGS; i++)
|
2016-12-13 00:21:24 +08:00
|
|
|
TempConfigFor (Class, i) = nullptr;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
return (Class);
|
|
|
|
|
|
|
|
} /* NewAdaptedClass */
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
2007-05-16 09:30:20 +08:00
|
|
|
void free_adapted_class(ADAPT_CLASS adapt_class) {
|
2007-03-08 04:03:40 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_NUM_CONFIGS; i++) {
|
|
|
|
if (ConfigIsPermanent (adapt_class, i)
|
2016-12-13 00:21:24 +08:00
|
|
|
&& PermConfigFor (adapt_class, i) != nullptr)
|
2011-03-22 05:45:36 +08:00
|
|
|
FreePermConfig (PermConfigFor (adapt_class, i));
|
2007-03-08 04:03:40 +08:00
|
|
|
else if (!ConfigIsPermanent (adapt_class, i)
|
2016-12-13 00:21:24 +08:00
|
|
|
&& TempConfigFor (adapt_class, i) != nullptr)
|
2007-03-08 04:03:40 +08:00
|
|
|
FreeTempConfig (TempConfigFor (adapt_class, i));
|
|
|
|
}
|
|
|
|
FreeBitVector (adapt_class->PermProtos);
|
|
|
|
FreeBitVector (adapt_class->PermConfigs);
|
|
|
|
destroy_nodes (adapt_class->TempProtos, FreeTempProto);
|
2007-05-16 09:30:20 +08:00
|
|
|
Efree(adapt_class);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 10:17:36 +08:00
|
|
|
namespace tesseract {
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* Allocates memory for adapted tempates.
|
|
|
|
* each char in unicharset to the newly created templates
|
|
|
|
*
|
2012-03-30 23:42:06 +08:00
|
|
|
* @param InitFromUnicharset if true, add an empty class for
|
2010-07-31 06:46:32 +08:00
|
|
|
* @return Ptr to new adapted templates.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Fri Mar 8 10:15:28 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
ADAPT_TEMPLATES Classify::NewAdaptedTemplates(bool InitFromUnicharset) {
|
2007-03-08 04:03:40 +08:00
|
|
|
ADAPT_TEMPLATES Templates;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
Templates = (ADAPT_TEMPLATES) Emalloc (sizeof (ADAPT_TEMPLATES_STRUCT));
|
|
|
|
|
|
|
|
Templates->Templates = NewIntTemplates ();
|
|
|
|
Templates->NumPermClasses = 0;
|
2009-07-11 10:17:36 +08:00
|
|
|
Templates->NumNonEmptyClasses = 0;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
/* Insert an empty class for each unichar id in unicharset */
|
|
|
|
for (i = 0; i < MAX_NUM_CLASSES; i++) {
|
2016-12-13 00:21:24 +08:00
|
|
|
Templates->Class[i] = nullptr;
|
2009-07-11 10:17:36 +08:00
|
|
|
if (InitFromUnicharset && i < unicharset.size()) {
|
|
|
|
AddAdaptedClass(Templates, NewAdaptedClass(), i);
|
|
|
|
}
|
|
|
|
}
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
return (Templates);
|
|
|
|
|
|
|
|
} /* NewAdaptedTemplates */
|
2011-03-22 05:45:36 +08:00
|
|
|
|
|
|
|
// Returns FontinfoId of the given config of the given adapted class.
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
int Classify::GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId) {
|
2011-03-22 05:45:36 +08:00
|
|
|
return (ConfigIsPermanent(Class, ConfigId) ?
|
|
|
|
PermConfigFor(Class, ConfigId)->FontinfoId :
|
|
|
|
TempConfigFor(Class, ConfigId)->FontinfoId);
|
|
|
|
}
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
} // namespace tesseract
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2007-05-16 09:30:20 +08:00
|
|
|
void free_adapted_templates(ADAPT_TEMPLATES templates) {
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2016-12-13 00:21:24 +08:00
|
|
|
if (templates != nullptr) {
|
2007-03-08 04:03:40 +08:00
|
|
|
int i;
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < (templates->Templates)->NumClasses; i++)
|
2007-03-08 04:03:40 +08:00
|
|
|
free_adapted_class (templates->Class[i]);
|
|
|
|
free_int_templates (templates->Templates);
|
2007-05-16 09:30:20 +08:00
|
|
|
Efree(templates);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine allocates and returns a new temporary config.
|
|
|
|
*
|
|
|
|
* @param MaxProtoId max id of any proto in new config
|
2011-03-22 05:45:36 +08:00
|
|
|
* @param FontinfoId font information from pre-trained templates
|
2010-07-31 06:46:32 +08:00
|
|
|
* @return Ptr to new temp config.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Thu Mar 14 13:28:21 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2011-03-22 05:45:36 +08:00
|
|
|
TEMP_CONFIG NewTempConfig(int MaxProtoId, int FontinfoId) {
|
2007-03-08 04:03:40 +08:00
|
|
|
int NumProtos = MaxProtoId + 1;
|
|
|
|
|
2017-07-15 00:30:14 +08:00
|
|
|
TEMP_CONFIG Config = (TEMP_CONFIG)malloc(sizeof(TEMP_CONFIG_STRUCT));
|
2007-03-08 04:03:40 +08:00
|
|
|
Config->Protos = NewBitVector (NumProtos);
|
|
|
|
|
|
|
|
Config->NumTimesSeen = 1;
|
|
|
|
Config->MaxProtoId = MaxProtoId;
|
|
|
|
Config->ProtoVectorSize = WordsInVectorOfSize (NumProtos);
|
|
|
|
zero_all_bits (Config->Protos, Config->ProtoVectorSize);
|
2011-03-22 05:45:36 +08:00
|
|
|
Config->FontinfoId = FontinfoId;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
return (Config);
|
|
|
|
|
|
|
|
} /* NewTempConfig */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine allocates and returns a new temporary proto.
|
|
|
|
*
|
|
|
|
* @return Ptr to new temporary proto.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Thu Mar 14 13:31:31 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
TEMP_PROTO NewTempProto() {
|
2017-07-15 00:30:14 +08:00
|
|
|
return (TEMP_PROTO)malloc(sizeof(TEMP_PROTO_STRUCT));
|
2007-03-08 04:03:40 +08:00
|
|
|
} /* NewTempProto */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 10:17:36 +08:00
|
|
|
namespace tesseract {
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine prints a summary of the adapted templates
|
|
|
|
* in Templates to File.
|
|
|
|
*
|
|
|
|
* @param File open text file to print Templates to
|
|
|
|
* @param Templates adapted templates to print to File
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Wed Mar 20 13:35:29 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
void Classify::PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
|
2007-03-08 04:03:40 +08:00
|
|
|
int i;
|
|
|
|
INT_CLASS IClass;
|
|
|
|
ADAPT_CLASS AClass;
|
|
|
|
|
|
|
|
fprintf (File, "\n\nSUMMARY OF ADAPTED TEMPLATES:\n\n");
|
|
|
|
fprintf (File, "Num classes = %d; Num permanent classes = %d\n\n",
|
2009-07-11 10:17:36 +08:00
|
|
|
Templates->NumNonEmptyClasses, Templates->NumPermClasses);
|
|
|
|
fprintf (File, " Id NC NPC NP NPP\n");
|
2007-03-08 04:03:40 +08:00
|
|
|
fprintf (File, "------------------------\n");
|
|
|
|
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < (Templates->Templates)->NumClasses; i++) {
|
|
|
|
IClass = Templates->Templates->Class[i];
|
2007-03-08 04:03:40 +08:00
|
|
|
AClass = Templates->Class[i];
|
2009-07-11 10:17:36 +08:00
|
|
|
if (!IsEmptyAdaptedClass (AClass)) {
|
|
|
|
fprintf (File, "%5d %s %3d %3d %3d %3d\n",
|
|
|
|
i, unicharset.id_to_unichar(i),
|
2009-03-11 03:03:06 +08:00
|
|
|
IClass->NumConfigs, AClass->NumPermConfigs,
|
|
|
|
IClass->NumProtos,
|
|
|
|
IClass->NumProtos - count (AClass->TempProtos));
|
2009-07-11 10:17:36 +08:00
|
|
|
}
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
fprintf (File, "\n");
|
|
|
|
|
|
|
|
} /* PrintAdaptedTemplates */
|
2009-07-11 10:17:36 +08:00
|
|
|
} // namespace tesseract
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
2018-03-29 17:58:23 +08:00
|
|
|
* Read an adapted class description from file and return
|
2010-07-31 06:46:32 +08:00
|
|
|
* a ptr to the adapted class.
|
|
|
|
*
|
2018-03-29 17:58:23 +08:00
|
|
|
* @param fp open file to read adapted class from
|
2010-07-31 06:46:32 +08:00
|
|
|
* @return Ptr to new adapted class.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Tue Mar 19 14:11:01 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2017-04-28 06:48:23 +08:00
|
|
|
ADAPT_CLASS ReadAdaptedClass(TFile *fp) {
|
2007-03-08 04:03:40 +08:00
|
|
|
int NumTempProtos;
|
|
|
|
int NumConfigs;
|
|
|
|
int i;
|
|
|
|
ADAPT_CLASS Class;
|
|
|
|
|
|
|
|
/* first read high level adapted class structure */
|
|
|
|
Class = (ADAPT_CLASS) Emalloc (sizeof (ADAPT_CLASS_STRUCT));
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(Class, sizeof(ADAPT_CLASS_STRUCT), 1);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/* then read in the definitions of the permanent protos and configs */
|
|
|
|
Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
|
|
|
|
Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fp->FRead(Class->PermProtos, sizeof(uint32_t),
|
2017-04-28 06:48:23 +08:00
|
|
|
WordsInVectorOfSize(MAX_NUM_PROTOS));
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fp->FRead(Class->PermConfigs, sizeof(uint32_t),
|
2017-04-28 06:48:23 +08:00
|
|
|
WordsInVectorOfSize(MAX_NUM_CONFIGS));
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/* then read in the list of temporary protos */
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(&NumTempProtos, sizeof(int), 1);
|
2010-11-24 02:34:14 +08:00
|
|
|
Class->TempProtos = NIL_LIST;
|
2007-03-08 04:03:40 +08:00
|
|
|
for (i = 0; i < NumTempProtos; i++) {
|
2017-07-15 00:30:14 +08:00
|
|
|
TEMP_PROTO TempProto = (TEMP_PROTO)malloc(sizeof(TEMP_PROTO_STRUCT));
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(TempProto, sizeof(TEMP_PROTO_STRUCT), 1);
|
2007-03-08 04:03:40 +08:00
|
|
|
Class->TempProtos = push_last (Class->TempProtos, TempProto);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then read in the adapted configs */
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(&NumConfigs, sizeof(int), 1);
|
2007-03-08 04:03:40 +08:00
|
|
|
for (i = 0; i < NumConfigs; i++)
|
|
|
|
if (test_bit (Class->PermConfigs, i))
|
2017-04-28 06:48:23 +08:00
|
|
|
Class->Config[i].Perm = ReadPermConfig(fp);
|
2009-03-11 03:03:06 +08:00
|
|
|
else
|
2017-04-28 06:48:23 +08:00
|
|
|
Class->Config[i].Temp = ReadTempConfig(fp);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
return (Class);
|
|
|
|
|
|
|
|
} /* ReadAdaptedClass */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 10:17:36 +08:00
|
|
|
namespace tesseract {
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
2018-03-29 17:58:23 +08:00
|
|
|
* Read a set of adapted templates from file and return
|
2010-07-31 06:46:32 +08:00
|
|
|
* a ptr to the templates.
|
|
|
|
*
|
2018-03-29 17:58:23 +08:00
|
|
|
* @param fp open text file to read adapted templates from
|
|
|
|
* @return Ptr to adapted templates read from file.
|
2010-07-31 06:46:32 +08:00
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Mon Mar 18 15:18:10 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2017-04-28 06:48:23 +08:00
|
|
|
ADAPT_TEMPLATES Classify::ReadAdaptedTemplates(TFile *fp) {
|
2007-03-08 04:03:40 +08:00
|
|
|
int i;
|
|
|
|
ADAPT_TEMPLATES Templates;
|
|
|
|
|
|
|
|
/* first read the high level adaptive template struct */
|
|
|
|
Templates = (ADAPT_TEMPLATES) Emalloc (sizeof (ADAPT_TEMPLATES_STRUCT));
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(Templates, sizeof(ADAPT_TEMPLATES_STRUCT), 1);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/* then read in the basic integer templates */
|
2017-05-04 07:09:44 +08:00
|
|
|
Templates->Templates = ReadIntTemplates(fp);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/* then read in the adaptive info for each class */
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < (Templates->Templates)->NumClasses; i++) {
|
2017-04-28 06:48:23 +08:00
|
|
|
Templates->Class[i] = ReadAdaptedClass(fp);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
return (Templates);
|
|
|
|
|
|
|
|
} /* ReadAdaptedTemplates */
|
2009-07-11 10:17:36 +08:00
|
|
|
} // namespace tesseract
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
2018-03-29 17:58:23 +08:00
|
|
|
* Read a permanent configuration description from file
|
2010-07-31 06:46:32 +08:00
|
|
|
* and return a ptr to it.
|
|
|
|
*
|
2018-03-29 17:58:23 +08:00
|
|
|
* @param fp open file to read permanent config from
|
2010-07-31 06:46:32 +08:00
|
|
|
* @return Ptr to new permanent configuration description.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Tue Mar 19 14:25:26 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2017-04-28 06:48:23 +08:00
|
|
|
PERM_CONFIG ReadPermConfig(TFile *fp) {
|
2017-07-15 00:30:14 +08:00
|
|
|
PERM_CONFIG Config = (PERM_CONFIG)malloc(sizeof(PERM_CONFIG_STRUCT));
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
uint8_t NumAmbigs;
|
|
|
|
fp->FRead(&NumAmbigs, sizeof(NumAmbigs), 1);
|
2014-01-25 05:12:35 +08:00
|
|
|
Config->Ambigs = new UNICHAR_ID[NumAmbigs + 1];
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs);
|
2011-03-22 05:45:36 +08:00
|
|
|
Config->Ambigs[NumAmbigs] = -1;
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(&(Config->FontinfoId), sizeof(int), 1);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
return (Config);
|
|
|
|
|
|
|
|
} /* ReadPermConfig */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
2018-03-29 17:58:23 +08:00
|
|
|
* Read a temporary configuration description from file
|
2010-07-31 06:46:32 +08:00
|
|
|
* and return a ptr to it.
|
|
|
|
*
|
2018-03-29 17:58:23 +08:00
|
|
|
* @param fp open file to read temporary config from
|
2010-07-31 06:46:32 +08:00
|
|
|
* @return Ptr to new temporary configuration description.
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Tue Mar 19 14:29:59 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2017-04-28 06:48:23 +08:00
|
|
|
TEMP_CONFIG ReadTempConfig(TFile *fp) {
|
2017-07-15 00:30:14 +08:00
|
|
|
TEMP_CONFIG Config = (TEMP_CONFIG)malloc(sizeof(TEMP_CONFIG_STRUCT));
|
2017-04-28 06:48:23 +08:00
|
|
|
fp->FRead(Config, sizeof(TEMP_CONFIG_STRUCT), 1);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
Config->Protos = NewBitVector (Config->ProtoVectorSize * BITSINLONG);
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fp->FRead(Config->Protos, sizeof(uint32_t), Config->ProtoVectorSize);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
return (Config);
|
|
|
|
|
|
|
|
} /* ReadTempConfig */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine writes a binary representation of Class
|
|
|
|
* to File.
|
|
|
|
*
|
|
|
|
* @param File open file to write Class to
|
|
|
|
* @param Class adapted class to write to File
|
|
|
|
* @param NumConfigs number of configs in Class
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Tue Mar 19 13:33:51 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) {
|
2007-03-08 04:03:40 +08:00
|
|
|
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 */
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fwrite ((char *) Class->PermProtos, sizeof (uint32_t),
|
2007-03-08 04:03:40 +08:00
|
|
|
WordsInVectorOfSize (MAX_NUM_PROTOS), File);
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fwrite ((char *) Class->PermConfigs, sizeof (uint32_t),
|
2007-03-08 04:03:40 +08:00
|
|
|
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) {
|
2007-05-16 09:30:20 +08:00
|
|
|
void* proto = first_node(TempProtos);
|
2007-03-08 04:03:40 +08:00
|
|
|
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);
|
2009-03-11 03:03:06 +08:00
|
|
|
else
|
|
|
|
WriteTempConfig (File, Class->Config[i].Temp);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
} /* WriteAdaptedClass */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 10:17:36 +08:00
|
|
|
namespace tesseract {
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine saves Templates to File in a binary format.
|
|
|
|
*
|
|
|
|
* @param File open text file to write Templates to
|
|
|
|
* @param Templates set of adapted templates to write to File
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Mon Mar 18 15:07:32 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
void Classify::WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
|
2007-03-08 04:03:40 +08:00
|
|
|
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 */
|
2007-07-18 09:15:07 +08:00
|
|
|
WriteIntTemplates (File, Templates->Templates, unicharset);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/* then write out the adaptive info for each class */
|
2009-03-11 03:03:06 +08:00
|
|
|
for (i = 0; i < (Templates->Templates)->NumClasses; i++) {
|
2007-03-08 04:03:40 +08:00
|
|
|
WriteAdaptedClass (File, Templates->Class[i],
|
2009-03-11 03:03:06 +08:00
|
|
|
Templates->Templates->Class[i]->NumConfigs);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
} /* WriteAdaptedTemplates */
|
2009-07-11 10:17:36 +08:00
|
|
|
} // namespace tesseract
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine writes a binary representation of a
|
|
|
|
* permanent configuration to File.
|
|
|
|
*
|
|
|
|
* @param File open file to write Config to
|
|
|
|
* @param Config permanent config to write to File
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Tue Mar 19 13:55:44 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
void WritePermConfig(FILE *File, PERM_CONFIG Config) {
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
uint8_t NumAmbigs = 0;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2016-12-13 00:21:24 +08:00
|
|
|
assert (Config != nullptr);
|
2011-03-22 05:45:36 +08:00
|
|
|
while (Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fwrite((char *) &NumAmbigs, sizeof(uint8_t), 1, File);
|
2011-03-22 05:45:36 +08:00
|
|
|
fwrite(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs, File);
|
|
|
|
fwrite(&(Config->FontinfoId), sizeof(int), 1, File);
|
2007-03-08 04:03:40 +08:00
|
|
|
} /* WritePermConfig */
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-07-31 06:46:32 +08:00
|
|
|
/**
|
|
|
|
* This routine writes a binary representation of a
|
|
|
|
* temporary configuration to File.
|
|
|
|
*
|
|
|
|
* @param File open file to write Config to
|
|
|
|
* @param Config temporary config to write to File
|
|
|
|
*
|
|
|
|
* @note Globals: none
|
|
|
|
* @note Exceptions: none
|
|
|
|
* @note History: Tue Mar 19 14:00:28 1991, DSJ, Created.
|
2007-03-08 04:03:40 +08:00
|
|
|
*/
|
2010-07-31 06:46:32 +08:00
|
|
|
void WriteTempConfig(FILE *File, TEMP_CONFIG Config) {
|
2016-12-13 00:21:24 +08:00
|
|
|
assert (Config != nullptr);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
fwrite ((char *) Config->Protos, sizeof (uint32_t),
|
2007-03-08 04:03:40 +08:00
|
|
|
Config->ProtoVectorSize, File);
|
|
|
|
|
|
|
|
} /* WriteTempConfig */
|