partial doxygen classify/intproto.cpp

This commit is contained in:
Jim O'Regan 2015-07-20 14:25:29 +01:00
parent 4bbc7aa6d2
commit dbb60411a9

View File

@ -433,10 +433,11 @@ void AddProtoToProtoPruner(PROTO Proto, int ProtoId,
} /* AddProtoToProtoPruner */ } /* AddProtoToProtoPruner */
/*---------------------------------------------------------------------------*/ /**
// Returns a quantized bucket for the given param shifted by offset, * Returns a quantized bucket for the given param shifted by offset,
// notionally (param + offset) * num_buckets, but clipped and casted to the * notionally (param + offset) * num_buckets, but clipped and casted to the
// appropriate type. * appropriate type.
*/
uinT8 Bucket8For(FLOAT32 param, FLOAT32 offset, int num_buckets) { uinT8 Bucket8For(FLOAT32 param, FLOAT32 offset, int num_buckets) {
int bucket = IntCastRounded(MapParam(param, offset, num_buckets)); int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
return static_cast<uinT8>(ClipToRange(bucket, 0, num_buckets - 1)); return static_cast<uinT8>(ClipToRange(bucket, 0, num_buckets - 1));
@ -446,52 +447,50 @@ uinT16 Bucket16For(FLOAT32 param, FLOAT32 offset, int num_buckets) {
return static_cast<uinT16>(ClipToRange(bucket, 0, num_buckets - 1)); return static_cast<uinT16>(ClipToRange(bucket, 0, num_buckets - 1));
} }
/*---------------------------------------------------------------------------*/ /**
// Returns a quantized bucket for the given circular param shifted by offset, * Returns a quantized bucket for the given circular param shifted by offset,
// notionally (param + offset) * num_buckets, but modded and casted to the * notionally (param + offset) * num_buckets, but modded and casted to the
// appropriate type. * appropriate type.
*/
uinT8 CircBucketFor(FLOAT32 param, FLOAT32 offset, int num_buckets) { uinT8 CircBucketFor(FLOAT32 param, FLOAT32 offset, int num_buckets) {
int bucket = IntCastRounded(MapParam(param, offset, num_buckets)); int bucket = IntCastRounded(MapParam(param, offset, num_buckets));
return static_cast<uinT8>(Modulo(bucket, num_buckets)); return static_cast<uinT8>(Modulo(bucket, num_buckets));
} /* CircBucketFor */ } /* CircBucketFor */
/*---------------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
void UpdateMatchDisplay() { /**
/* * This routine clears the global feature and proto
** Parameters: none * display lists.
** Globals: *
** FeatureShapes display list for features * Globals:
** ProtoShapes display list for protos * - FeatureShapes display list for features
** Operation: This routine clears the global feature and proto * - ProtoShapes display list for protos
** display lists. * @return none
** Return: none * @note Exceptions: none
** Exceptions: none * @note History: Thu Mar 21 15:40:19 1991, DSJ, Created.
** History: Thu Mar 21 15:40:19 1991, DSJ, Created.
*/ */
void UpdateMatchDisplay() {
if (IntMatchWindow != NULL) if (IntMatchWindow != NULL)
IntMatchWindow->Update(); IntMatchWindow->Update();
} /* ClearMatchDisplay */ } /* ClearMatchDisplay */
#endif #endif
/*---------------------------------------------------------------------------*/ /**
void ConvertConfig(BIT_VECTOR Config, int ConfigId, INT_CLASS Class) { * This operation updates the config vectors of all protos
/* * in Class to indicate that the protos with 1's in Config
** Parameters: * belong to a new configuration identified by ConfigId.
** Config config to be added to class * It is assumed that the length of the Config bit vector is
** ConfigId id to be used for new config * equal to the number of protos in Class.
** Class class to add new config to * @param Config config to be added to class
** Globals: none * @param ConfigId id to be used for new config
** Operation: This operation updates the config vectors of all protos * @param Class class to add new config to
** in Class to indicate that the protos with 1's in Config * @return none
** belong to a new configuration identified by ConfigId. * @note Globals: none
** It is assumed that the length of the Config bit vector is * @note Exceptions: none
** equal to the number of protos in Class. * @note History: Mon Feb 11 14:57:31 1991, DSJ, Created.
** Return: none
** Exceptions: none
** History: Mon Feb 11 14:57:31 1991, DSJ, Created.
*/ */
void ConvertConfig(BIT_VECTOR Config, int ConfigId, INT_CLASS Class) {
int ProtoId; int ProtoId;
INT_PROTO Proto; INT_PROTO Proto;
int TotalLength; int TotalLength;
@ -509,20 +508,18 @@ void ConvertConfig(BIT_VECTOR Config, int ConfigId, INT_CLASS Class) {
namespace tesseract { namespace tesseract {
/*---------------------------------------------------------------------------*/ /**
void Classify::ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class) { * This routine converts Proto to integer format and
/* * installs it as ProtoId in Class.
** Parameters: * @param Proto floating-pt proto to be converted to integer format
** Proto floating-pt proto to be converted to integer format * @param ProtoId id of proto
** ProtoId id of proto * @param Class integer class to add converted proto to
** Class integer class to add converted proto to * @return none
** Globals: none * @note Globals: none
** Operation: This routine converts Proto to integer format and * @note Exceptions: none
** installs it as ProtoId in Class. * @note History: Fri Feb 8 11:22:43 1991, DSJ, Created.
** Return: none
** Exceptions: none
** History: Fri Feb 8 11:22:43 1991, DSJ, Created.
*/ */
void Classify::ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class) {
INT_PROTO P; INT_PROTO P;
FLOAT32 Param; FLOAT32 Param;
@ -554,20 +551,18 @@ void Classify::ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class) {
} /* ConvertProto */ } /* ConvertProto */
/*---------------------------------------------------------------------------*/ /**
* This routine converts from the old floating point format
* to the new integer format.
* @param FloatProtos prototypes in old floating pt format
* @return New set of training templates in integer format.
* @note Globals: none
* @note Exceptions: none
* @note History: Thu Feb 7 14:40:42 1991, DSJ, Created.
*/
INT_TEMPLATES Classify::CreateIntTemplates(CLASSES FloatProtos, INT_TEMPLATES Classify::CreateIntTemplates(CLASSES FloatProtos,
const UNICHARSET& const UNICHARSET&
target_unicharset) { target_unicharset) {
/*
** Parameters:
** FloatProtos prototypes in old floating pt format
** Globals: none
** Operation: This routine converts from the old floating point format
** to the new integer format.
** Return: New set of training templates in integer format.
** Exceptions: none
** History: Thu Feb 7 14:40:42 1991, DSJ, Created.
*/
INT_TEMPLATES IntTemplates; INT_TEMPLATES IntTemplates;
CLASS_TYPE FClass; CLASS_TYPE FClass;
INT_CLASS IClass; INT_CLASS IClass;
@ -618,21 +613,20 @@ INT_TEMPLATES Classify::CreateIntTemplates(CLASSES FloatProtos,
} // namespace tesseract } // namespace tesseract
/*---------------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
void DisplayIntFeature(const INT_FEATURE_STRUCT* Feature, FLOAT32 Evidence) { /**
/* * This routine renders the specified feature into a
** Parameters: * global display list.
** Feature pico-feature to be displayed *
** Evidence best evidence for this feature (0-1) * Globals:
** Globals: * - FeatureShapes global display list for features
** FeatureShapes global display list for features * @param Feature pico-feature to be displayed
** Operation: This routine renders the specified feature into a * @param Evidence best evidence for this feature (0-1)
** global display list. * @return none
** Return: none * @note Exceptions: none
** Exceptions: none * @note History: Thu Mar 21 14:45:04 1991, DSJ, Created.
** History: Thu Mar 21 14:45:04 1991, DSJ, Created.
*/ */
void DisplayIntFeature(const INT_FEATURE_STRUCT* Feature, FLOAT32 Evidence) {
ScrollView::Color color = GetMatchColorFor(Evidence); ScrollView::Color color = GetMatchColorFor(Evidence);
RenderIntFeature(IntMatchWindow, Feature, color); RenderIntFeature(IntMatchWindow, Feature, color);
if (FeatureDisplayWindow) { if (FeatureDisplayWindow) {
@ -641,21 +635,20 @@ void DisplayIntFeature(const INT_FEATURE_STRUCT* Feature, FLOAT32 Evidence) {
} /* DisplayIntFeature */ } /* DisplayIntFeature */
/*---------------------------------------------------------------------------*/ /**
void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence) { * This routine renders the specified proto into a
/* * global display list.
** Parameters: *
** Class class to take proto from * Globals:
** ProtoId id of proto in Class to be displayed * - ProtoShapes global display list for protos
** Evidence total evidence for proto (0-1) * @param Class class to take proto from
** Globals: * @param ProtoId id of proto in Class to be displayed
** ProtoShapes global display list for protos * @param Evidence total evidence for proto (0-1)
** Operation: This routine renders the specified proto into a * @return none
** global display list. * @note Exceptions: none
** Return: none * @note History: Thu Mar 21 14:45:04 1991, DSJ, Created.
** Exceptions: none
** History: Thu Mar 21 14:45:04 1991, DSJ, Created.
*/ */
void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence) {
ScrollView::Color color = GetMatchColorFor(Evidence); ScrollView::Color color = GetMatchColorFor(Evidence);
RenderIntProto(IntMatchWindow, Class, ProtoId, color); RenderIntProto(IntMatchWindow, Class, ProtoId, color);
if (ProtoDisplayWindow) { if (ProtoDisplayWindow) {
@ -664,17 +657,15 @@ void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence) {
} /* DisplayIntProto */ } /* DisplayIntProto */
#endif #endif
/*---------------------------------------------------------------------------*/
INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs) { INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs) {
/* /*
** Parameters:
** MaxNumProtos number of protos to allocate space for ** MaxNumProtos number of protos to allocate space for
** MaxNumConfigs number of configs to allocate space for ** MaxNumConfigs number of configs to allocate space for
** Globals: none
** Operation: This routine creates a new integer class data structure ** Operation: This routine creates a new integer class data structure
** and returns it. Sufficient space is allocated ** and returns it. Sufficient space is allocated
** to handle the specified number of protos and configs. ** to handle the specified number of protos and configs.
** Return: New class created. * @return New class created.
** Globals: none
** Exceptions: none ** Exceptions: none
** History: Fri Feb 8 10:51:23 1991, DSJ, Created. ** History: Fri Feb 8 10:51:23 1991, DSJ, Created.
*/ */
@ -730,17 +721,15 @@ void free_int_class(INT_CLASS int_class) {
} }
/*---------------------------------------------------------------------------*/ /**
INT_TEMPLATES NewIntTemplates() { * This routine allocates a new set of integer templates
/* * initialized to hold 0 classes.
** Parameters: none * @return The integer templates created.
** Globals: none * @note Globals: none
** Operation: This routine allocates a new set of integer templates * @note Exceptions: none
** initialized to hold 0 classes. * @note History: Fri Feb 8 08:38:51 1991, DSJ, Created.
** Return: The integer templates created.
** Exceptions: none
** History: Fri Feb 8 08:38:51 1991, DSJ, Created.
*/ */
INT_TEMPLATES NewIntTemplates() {
INT_TEMPLATES T; INT_TEMPLATES T;
int i; int i;
@ -1247,27 +1236,25 @@ FLOAT32 BucketEnd(int Bucket, FLOAT32 Offset, int NumBuckets) {
} /* BucketEnd */ } /* BucketEnd */
/*---------------------------------------------------------------------------*/ /**
* This routine fills in the section of a class pruner
* corresponding to a single x value for a single proto of
* a class.
* @param FillSpec specifies which bits to fill in pruner
* @param Pruner class pruner to be filled
* @param ClassMask indicates which bits to change in each word
* @param ClassCount indicates what to change bits to
* @param WordIndex indicates which word to change
* @return none
* @note Globals: none
* @note Exceptions: none
* @note History: Tue Feb 19 11:11:29 1991, DSJ, Created.
*/
void DoFill(FILL_SPEC *FillSpec, void DoFill(FILL_SPEC *FillSpec,
CLASS_PRUNER_STRUCT* Pruner, CLASS_PRUNER_STRUCT* Pruner,
register uinT32 ClassMask, register uinT32 ClassMask,
register uinT32 ClassCount, register uinT32 ClassCount,
register uinT32 WordIndex) { register uinT32 WordIndex) {
/*
** Parameters:
** FillSpec specifies which bits to fill in pruner
** Pruner class pruner to be filled
** ClassMask indicates which bits to change in each word
** ClassCount indicates what to change bits to
** WordIndex indicates which word to change
** Globals: none
** Operation: This routine fills in the section of a class pruner
** corresponding to a single x value for a single proto of
** a class.
** Return: none
** Exceptions: none
** History: Tue Feb 19 11:11:29 1991, DSJ, Created.
*/
register int X, Y, Angle; register int X, Y, Angle;
register uinT32 OldWord; register uinT32 OldWord;
@ -1297,18 +1284,16 @@ void DoFill(FILL_SPEC *FillSpec,
} /* DoFill */ } /* DoFill */
/*---------------------------------------------------------------------------*/ /**
BOOL8 FillerDone(TABLE_FILLER *Filler) { * Return TRUE if the specified table filler is done, i.e.
/* * if it has no more lines to fill.
** Parameters: * @param Filler table filler to check if done
** Filler table filler to check if done * @return TRUE if no more lines to fill, FALSE otherwise.
** Globals: none * @note Globals: none
** Operation: Return TRUE if the specified table filler is done, i.e. * @note Exceptions: none
** if it has no more lines to fill. * @note History: Tue Feb 19 10:08:05 1991, DSJ, Created.
** Return: TRUE if no more lines to fill, FALSE otherwise.
** Exceptions: none
** History: Tue Feb 19 10:08:05 1991, DSJ, Created.
*/ */
BOOL8 FillerDone(TABLE_FILLER *Filler) {
FILL_SWITCH *Next; FILL_SWITCH *Next;
Next = &(Filler->Switch[Filler->NextSwitch]); Next = &(Filler->Switch[Filler->NextSwitch]);
@ -1321,26 +1306,24 @@ BOOL8 FillerDone(TABLE_FILLER *Filler) {
} /* FillerDone */ } /* FillerDone */
/*---------------------------------------------------------------------------*/ /**
* This routine sets Bit in each bit vector whose
* bucket lies within the range Center +- Spread. The fill
* is done for a circular dimension, i.e. bucket 0 is adjacent
* to the last bucket. It is assumed that Center and Spread
* are expressed in a circular coordinate system whose range
* is 0 to 1.
* @param ParamTable table of bit vectors, one per param bucket
* @param Bit bit position in vectors to be filled
* @param Center center of filled area
* @param Spread spread of filled area
* @return none
* @note Globals: none
* @note Exceptions: none
* @note History: Tue Oct 16 09:26:54 1990, DSJ, Created.
*/
void FillPPCircularBits(uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], void FillPPCircularBits(uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug) { int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug) {
/*
** Parameters:
** ParamTable table of bit vectors, one per param bucket
** Bit bit position in vectors to be filled
** Center center of filled area
** Spread spread of filled area
** Globals: none
** Operation: This routine sets Bit in each bit vector whose
** bucket lies within the range Center +- Spread. The fill
** is done for a circular dimension, i.e. bucket 0 is adjacent
** to the last bucket. It is assumed that Center and Spread
** are expressed in a circular coordinate system whose range
** is 0 to 1.
** Return: none
** Exceptions: none
** History: Tue Oct 16 09:26:54 1990, DSJ, Created.
*/
int i, FirstBucket, LastBucket; int i, FirstBucket, LastBucket;
if (Spread > 0.5) if (Spread > 0.5)