From a18816f8390745f1c5d9b44b9734ff1795f0248b Mon Sep 17 00:00:00 2001 From: joregan Date: Tue, 27 Jul 2010 13:23:23 +0000 Subject: [PATCH] partial merge of doxygen branch (stuff without conflicts, basically) git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@441 d0cd1f9f-072b-0410-8dd7-cf729c803f20 --- api/baseapi.h | 584 ++++++++------ api/tesseractmain.h | 63 +- ccmain/callnet.h | 7 +- ccmain/charcut.h | 121 ++- ccmain/control.h | 84 +- ccmain/fixspace.h | 2 +- ccmain/output.h | 73 +- ccmain/tessio.h | 232 ++++-- ccmain/thresholder.h | 135 ++-- ccmain/varabled.h | 75 +- ccstruct/ratngs.cpp | 106 +-- ccstruct/ratngs.h | 38 +- ccstruct/werd.cpp | 139 ++-- ccstruct/werd.h | 36 +- ccutil/tessdatamanager.h | 126 +-- ccutil/unicity_table.h | 52 +- classify/adaptmatch.cpp | 662 ++++++++-------- classify/adaptmatch.h | 12 +- classify/extract.cpp | 63 +- classify/extract.h | 4 +- classify/featdefs.cpp | 153 ++-- classify/float2int.cpp | 92 ++- classify/float2int.h | 8 +- classify/fxdefs.cpp | 33 +- classify/fxdefs.h | 32 +- classify/fxid.h | 14 +- classify/intproto.cpp | 24 +- classify/kdtree.cpp | 179 +++-- classify/kdtree.h | 31 +- classify/protos.cpp | 88 ++- classify/protos.h | 24 +- classify/speckle.cpp | 76 +- classify/speckle.h | 14 +- cutil/bitvec.cpp | 86 +- cutil/bitvec.h | 10 +- cutil/oldheap.cpp | 211 +++-- cutil/oldheap.h | 12 +- dict/choices.cpp | 40 +- dict/choices.h | 76 +- dict/dawg.h | 182 ++--- dict/dict.h | 276 +++---- dict/matchdefs.h | 24 +- dict/states.cpp | 36 +- dict/states.h | 5 +- dict/trie.h | 64 +- doc/Doxyfile | 1608 ++++++++++++++++++++++++++++++++++++++ image/img.h | 452 +++++++---- textord/blkocc.cpp | 61 +- textord/linefind.cpp | 9 +- textord/linefind.h | 98 ++- viewer/scrollview.cpp | 36 +- viewer/svutil.h | 60 +- wordrec/associate.h | 19 +- wordrec/badwords.cpp | 64 +- wordrec/bestfirst.cpp | 70 +- wordrec/chop.cpp | 66 +- wordrec/chop.h | 6 +- wordrec/chopper.cpp | 79 +- wordrec/closed.cpp | 18 +- wordrec/closed.h | 4 +- wordrec/seam.cpp | 112 +-- wordrec/seam.h | 10 +- wordrec/tessinit.cpp | 14 +- wordrec/tface.cpp | 108 +-- wordrec/wordclass.cpp | 29 +- 65 files changed, 4742 insertions(+), 2585 deletions(-) diff --git a/api/baseapi.h b/api/baseapi.h index 5f4ee8f94e..ee8dd61de4 100644 --- a/api/baseapi.h +++ b/api/baseapi.h @@ -64,174 +64,208 @@ typedef int (Dict::*DictFunc)(void* void_dawg_args, int char_index, const void *word, bool word_end); enum PageSegMode { - PSM_AUTO, // Fully automatic page segmentation. - PSM_SINGLE_COLUMN, // Assume a single column of text of variable sizes. - PSM_SINGLE_BLOCK, // Assume a single uniform block of text. (Default.) - PSM_SINGLE_LINE, // Treat the image as a single text line. - PSM_SINGLE_WORD, // Treat the image as a single word. - PSM_SINGLE_CHAR, // Treat the image as a single character. - - PSM_COUNT // Number of enum entries. + PSM_AUTO, ///< Fully automatic page segmentation. + PSM_SINGLE_COLUMN, ///< Assume a single column of text of variable sizes. + PSM_SINGLE_BLOCK, ///< Assume a single uniform block of text. (Default.) + PSM_SINGLE_LINE, ///< Treat the image as a single text line. + PSM_SINGLE_WORD, ///< Treat the image as a single word. + PSM_SINGLE_CHAR, ///< Treat the image as a single character. + + PSM_COUNT ///< Number of enum entries. }; -// The values in the AccuracyVSpeed enum provide hints for how the engine -// should trade speed for accuracy. There is no guarantee of any effect. +/** + * The values in the AccuracyVSpeed enum provide hints for how the engine + * should trade speed for accuracy. There is no guarantee of any effect. + */ enum AccuracyVSpeed { - AVS_FASTEST = 0, // Fastest speed, but lowest accuracy. - AVS_MOST_ACCURATE = 100 // Greatest accuracy, but slowest speed. + AVS_FASTEST = 0, ///< Fastest speed, but lowest accuracy. + AVS_MOST_ACCURATE = 100 ///< Greatest accuracy, but slowest speed. }; -// Base class for all tesseract APIs. -// Specific classes can add ability to work on different inputs or produce -// different outputs. -// This class is mostly an interface layer on top of the Tesseract instance -// class to hide the data types so that users of this class don't have to -// include any other Tesseract headers. - +/** + * Base class for all tesseract APIs. + * Specific classes can add ability to work on different inputs or produce + * different outputs. + * This class is mostly an interface layer on top of the Tesseract instance + * class to hide the data types so that users of this class don't have to + * include any other Tesseract headers. + */ class TESSDLL_API TessBaseAPI { public: TessBaseAPI(); virtual ~TessBaseAPI(); - // Set the name of the input file. Needed only for training and - // reading a UNLV zone file. + /** + * Set the name of the input file. Needed only for training and + * reading a UNLV zone file. + */ void SetInputName(const char* name); - // Set the name of the bonus output files. Needed only for debugging. + /** Set the name of the bonus output files. Needed only for debugging. */ void SetOutputName(const char* name); - // Set the value of an internal "variable" (of either old or new types). - // Supply the name of the variable and the value as a string, just as - // you would in a config file. - // Returns false if the name lookup failed. - // Eg SetVariable("tessedit_char_blacklist", "xyz"); to ignore x, y and z. - // Or SetVariable("bln_numericmode", "1"); to set numeric-only mode. - // SetVariable may be used before Init, but settings will revert to - // defaults on End(). + /** + * Set the value of an internal "variable" (of either old or new types). + * Supply the name of the variable and the value as a string, just as + * you would in a config file. + * Returns false if the name lookup failed. + * Eg SetVariable("tessedit_char_blacklist", "xyz"); to ignore x, y and z. + * Or SetVariable("bln_numericmode", "1"); to set numeric-only mode. + * SetVariable may be used before Init, but settings will revert to + * defaults on End(). + */ bool SetVariable(const char* variable, const char* value); - // Eventually instances will be thread-safe and totally independent, - // but for now, they all point to the same underlying engine, - // and are NOT RE-ENTRANT OR THREAD-SAFE. For now: - // it is safe to Init multiple TessBaseAPIs in the same language, use them - // sequentially, and End or delete them all, but once one is Ended, you can't - // do anything other than End the others. After End, it is safe to Init - // again on the same one. - // - // Start tesseract. Returns zero on success and -1 on failure. - // NOTE that the only members that may be called before Init are those - // listed above here in the class definition. - // - // The datapath must be the name of the data directory (no ending /) or - // some other file in which the data directory resides (for instance argv[0].) - // The language is (usually) an ISO 639-3 string or NULL will default to eng. - // It is entirely safe (and eventually will be efficient too) to call - // Init multiple times on the same instance to change language, or just - // to reset the classifier. - // WARNING: On changing languages, all Variables are reset back to their - // default values. If you have a rare need to set a Variable that controls - // initialization for a second call to Init you should explicitly - // call End() and then use SetVariable before Init. This is only a very - // rare use case, since there are very few uses that require any variables - // to be set before Init. + /** + * Eventually instances will be thread-safe and totally independent, + * but for now, they all point to the same underlying engine, + * and are NOT RE-ENTRANT OR THREAD-SAFE. For now: + * it is safe to Init multiple TessBaseAPIs in the same language, use them + * sequentially, and End or delete them all, but once one is Ended, you can't + * do anything other than End the others. After End, it is safe to Init + * again on the same one. + * + * Start tesseract. Returns zero on success and -1 on failure. + * NOTE that the only members that may be called before Init are those + * listed above here in the class definition. + * + * The datapath must be the name of the data directory (no ending /) or + * some other file in which the data directory resides (for instance argv[0].) + * The language is (usually) an ISO 639-3 string or NULL will default to eng. + * It is entirely safe (and eventually will be efficient too) to call + * Init multiple times on the same instance to change language, or just + * to reset the classifier. + * WARNING: On changing languages, all Variables are reset back to their + * default values. If you have a rare need to set a Variable that controls + * initialization for a second call to Init you should explicitly + * call End() and then use SetVariable before Init. This is only a very + * rare use case, since there are very few uses that require any variables + * to be set before Init. + */ int Init(const char* datapath, const char* language, char **configs, int configs_size, bool configs_global_only); int Init(const char* datapath, const char* language) { return Init(datapath, language, 0, 0, false); } - // Init only the lang model component of Tesseract. The only functions - // that work after this init are SetVariable and IsValidWord. - // WARNING: temporary! This function will be removed from here and placed - // in a separate API at some future time. + /** + * Init only the lang model component of Tesseract. The only functions + * that work after this init are SetVariable and IsValidWord. + * WARNING: temporary! This function will be removed from here and placed + * in a separate API at some future time. + */ int InitLangMod(const char* datapath, const char* language); - // Init everything except the language model. Used to allow initialization for - // the specified language without any available dawg models. + /** + * Init everything except the language model. Used to allow initialization for + * the specified language without any available dawg models. + */ int InitWithoutLangModel(const char* datapath, const char* language); - // Read a "config" file containing a set of variable, value pairs. - // Searches the standard places: tessdata/configs, tessdata/tessconfigs - // and also accepts a relative or absolute path name. + /** + * Read a "config" file containing a set of variable, value pairs. + * Searches the standard places: tessdata/configs, tessdata/tessconfigs + * and also accepts a relative or absolute path name. + */ void ReadConfigFile(const char* filename, bool global_only); - // Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK. - // The mode is stored as an INT_VARIABLE so it can also be modified by - // ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string). + /** + * Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK. + * The mode is stored as an INT_VARIABLE so it can also be modified by + * ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string). + */ void SetPageSegMode(PageSegMode mode); - // Return the current page segmentation mode. + /** Return the current page segmentation mode. */ PageSegMode GetPageSegMode() const; - // Set the hint for trading accuracy against speed. - // Default is AVS_FASTEST, which is the old behaviour. - // Note that this is only a hint. Depending on the language and/or - // build configuration, speed and accuracy may not be tradeable. - // Also note that despite being an enum, any value in the range - // AVS_FASTEST to AVS_MOST_ACCURATE can be provided, and may or may not - // have an effect, depending on the implementation. - // The mode is stored as an INT_VARIABLE so it can also be modified by - // ReadConfigFile or SetVariable("tessedit_accuracyvspeed", mode as string). + /** + * Set the hint for trading accuracy against speed. + * Default is AVS_FASTEST, which is the old behaviour. + * Note that this is only a hint. Depending on the language and/or + * build configuration, speed and accuracy may not be tradeable. + * Also note that despite being an enum, any value in the range + * AVS_FASTEST to AVS_MOST_ACCURATE can be provided, and may or may not + * have an effect, depending on the implementation. + * The mode is stored as an INT_VARIABLE so it can also be modified by + * ReadConfigFile or SetVariable("tessedit_accuracyvspeed", mode as string). + */ void SetAccuracyVSpeed(AccuracyVSpeed mode); - // Recognize a rectangle from an image and return the result as a string. - // May be called many times for a single Init. - // Currently has no error checking. - // Greyscale of 8 and color of 24 or 32 bits per pixel may be given. - // Palette color images will not work properly and must be converted to - // 24 bit. - // Binary images of 1 bit per pixel may also be given but they must be - // byte packed with the MSB of the first byte being the first pixel, and a - // 1 represents WHITE. For binary images set bytes_per_pixel=0. - // The recognized text is returned as a char* which is coded - // as UTF8 and must be freed with the delete [] operator. - // - // Note that TesseractRect is the simplified convenience interface. - // For advanced uses, use SetImage, (optionally) SetRectangle, Recognize, - // and one or more of the Get*Text functions below. + /** + * Recognize a rectangle from an image and return the result as a string. + * May be called many times for a single Init. + * Currently has no error checking. + * Greyscale of 8 and color of 24 or 32 bits per pixel may be given. + * Palette color images will not work properly and must be converted to + * 24 bit. + * Binary images of 1 bit per pixel may also be given but they must be + * byte packed with the MSB of the first byte being the first pixel, and a + * 1 represents WHITE. For binary images set bytes_per_pixel=0. + * The recognized text is returned as a char* which is coded + * as UTF8 and must be freed with the delete [] operator. + * + * Note that TesseractRect is the simplified convenience interface. + * For advanced uses, use SetImage, (optionally) SetRectangle, Recognize, + * and one or more of the Get*Text functions below. + */ char* TesseractRect(const unsigned char* imagedata, int bytes_per_pixel, int bytes_per_line, int left, int top, int width, int height); - // Call between pages or documents etc to free up memory and forget - // adaptive data. + /** + * Call between pages or documents etc to free up memory and forget + * adaptive data. + */ void ClearAdaptiveClassifier(); - // ------------------------Advanced API-------------------------------- - // The following methods break TesseractRect into pieces, so you can - // get hold of the thresholded image, get the text in different formats, - // get bounding boxes, confidences etc. - - // Provide an image for Tesseract to recognize. Format is as - // TesseractRect above. Does not copy the image buffer, or take - // ownership. The source image may be destroyed after Recognize is called, - // either explicitly or implicitly via one of the Get*Text functions. - // SetImage clears all recognition results, and sets the rectangle to the - // full image, so it may be followed immediately by a GetUTF8Text, and it - // will automatically perform recognition. + /** + * @defgroup AdvancedAPI Advanced API + * The following methods break TesseractRect into pieces, so you can + * get hold of the thresholded image, get the text in different formats, + * get bounding boxes, confidences etc. + */ + /* @{ */ + + /** + * Provide an image for Tesseract to recognize. Format is as + * TesseractRect above. Does not copy the image buffer, or take + * ownership. The source image may be destroyed after Recognize is called, + * either explicitly or implicitly via one of the Get*Text functions. + * SetImage clears all recognition results, and sets the rectangle to the + * full image, so it may be followed immediately by a GetUTF8Text, and it + * will automatically perform recognition. + */ void SetImage(const unsigned char* imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line); - // Provide an image for Tesseract to recognize. As with SetImage above, - // Tesseract doesn't take a copy or ownership or pixDestroy the image, so - // it must persist until after Recognize. - // Pix vs raw, which to use? - // Use Pix where possible. A future version of Tesseract may choose to use Pix - // as its internal representation and discard IMAGE altogether. - // Because of that, an implementation that sources and targets Pix may end up - // with less copies than an implementation that does not. + /** + * Provide an image for Tesseract to recognize. As with SetImage above, + * Tesseract doesn't take a copy or ownership or pixDestroy the image, so + * it must persist until after Recognize. + * Pix vs raw, which to use? + * Use Pix where possible. A future version of Tesseract may choose to use Pix + * as its internal representation and discard IMAGE altogether. + * Because of that, an implementation that sources and targets Pix may end up + * with less copies than an implementation that does not. + */ void SetImage(const Pix* pix); - // Restrict recognition to a sub-rectangle of the image. Call after SetImage. - // Each SetRectangle clears the recogntion results so multiple rectangles - // can be recognized with the same image. + /** + * Restrict recognition to a sub-rectangle of the image. Call after SetImage. + * Each SetRectangle clears the recogntion results so multiple rectangles + * can be recognized with the same image. + */ void SetRectangle(int left, int top, int width, int height); - // In extreme cases only, usually with a subclass of Thresholder, it - // is possible to provide a different Thresholder. The Thresholder may - // be preloaded with an image, settings etc, or they may be set after. - // Note that Tesseract takes ownership of the Thresholder and will - // delete it when it it is replaced or the API is destructed. + /** + * In extreme cases only, usually with a subclass of Thresholder, it + * is possible to provide a different Thresholder. The Thresholder may + * be preloaded with an image, settings etc, or they may be set after. + * Note that Tesseract takes ownership of the Thresholder and will + * delete it when it it is replaced or the API is destructed. + */ void SetThresholder(ImageThresholder* thresholder) { if (thresholder_ != 0) delete thresholder_; @@ -239,145 +273,190 @@ class TESSDLL_API TessBaseAPI { ClearResults(); } - // Get a copy of the internal thresholded image from Tesseract. - // Caller takes ownership of the Pix and must pixDestroy it. - // May be called any time after SetImage, or after TesseractRect. + /** + * Get a copy of the internal thresholded image from Tesseract. + * Caller takes ownership of the Pix and must pixDestroy it. + * May be called any time after SetImage, or after TesseractRect. + */ Pix* GetThresholdedImage(); - // Get the result of page layout analysis as a leptonica-style - // Boxa, Pixa pair, in reading order. - // Can be called before or after Recognize. + /** + * Get the result of page layout analysis as a leptonica-style + * Boxa, Pixa pair, in reading order. + * Can be called before or after Recognize. + */ Boxa* GetRegions(Pixa** pixa); - // Get the textlines as a leptonica-style - // Boxa, Pixa pair, in reading order. - // Can be called before or after Recognize. - // If blockids is not NULL, the block-id of each line is also returned as an - // array of one element per line. delete [] after use. + /** + * Get the textlines as a leptonica-style + * Boxa, Pixa pair, in reading order. + * Can be called before or after Recognize. + * If blockids is not NULL, the block-id of each line is also returned as an + * array of one element per line. delete [] after use. + */ Boxa* GetTextlines(Pixa** pixa, int** blockids); - // Get the words as a leptonica-style - // Boxa, Pixa pair, in reading order. - // Can be called before or after Recognize. + /** + * Get the words as a leptonica-style + * Boxa, Pixa pair, in reading order. + * Can be called before or after Recognize. + */ Boxa* GetWords(Pixa** pixa); - // Dump the internal binary image to a PGM file. - // Deprecated. Use GetThresholdedImage and write the image using pixWrite - // instead if possible. + /** + * Dump the internal binary image to a PGM file. + * @deprecated Use GetThresholdedImage and write the image using pixWrite + * instead if possible. + */ void DumpPGM(const char* filename); - // Recognize the image from SetAndThresholdImage, generating Tesseract - // internal structures. Returns 0 on success. - // Optional. The Get*Text functions below will call Recognize if needed. - // After Recognize, the output is kept internally until the next SetImage. + /** + * Recognize the image from SetAndThresholdImage, generating Tesseract + * internal structures. Returns 0 on success. + * Optional. The Get*Text functions below will call Recognize if needed. + * After Recognize, the output is kept internally until the next SetImage. + */ int Recognize(ETEXT_STRUCT* monitor); - // Methods to retrieve information after SetAndThresholdImage(), - // Recognize() or TesseractRect(). (Recognize is called implicitly if needed.) + /** + * Methods to retrieve information after SetAndThresholdImage(), + * Recognize() or TesseractRect(). (Recognize is called implicitly if needed.) + */ - // Variant on Recognize used for testing chopper. + /** Variant on Recognize used for testing chopper. */ int RecognizeForChopTest(struct ETEXT_STRUCT* monitor); - // The recognized text is returned as a char* which is coded - // as UTF8 and must be freed with the delete [] operator. + /** + * The recognized text is returned as a char* which is coded + * as UTF8 and must be freed with the delete [] operator. + */ char* GetUTF8Text(); - // Make a HTML-formatted string with hOCR markup from the internal - // data structures. - // STL removed from original patch submission and refactored by rays. - // page_id is 1-based and will appear in the output. + /** + * Make a HTML-formatted string with hOCR markup from the internal + * data structures. + * STL removed from original patch submission and refactored by rays. + * page_id is 1-based and will appear in the output. + */ char* GetHOCRText(int page_id); - // The recognized text is returned as a char* which is coded in the same - // format as a box file used in training. Returned string must be freed with - // the delete [] operator. - // Constructs coordinates in the original image - not just the rectangle. - // page_number is a 0-base page index that will appear in the box file. + /** + * The recognized text is returned as a char* which is coded in the same + * format as a box file used in training. Returned string must be freed with + * the delete [] operator. + * Constructs coordinates in the original image - not just the rectangle. + * page_number is a 0-base page index that will appear in the box file. + */ char* GetBoxText(int page_number); - // The recognized text is returned as a char* which is coded - // as UNLV format Latin-1 with specific reject and suspect codes - // and must be freed with the delete [] operator. + /** + * The recognized text is returned as a char* which is coded + * as UNLV format Latin-1 with specific reject and suspect codes + * and must be freed with the delete [] operator. + */ char* GetUNLVText(); - // Returns the (average) confidence value between 0 and 100. + /** Returns the (average) confidence value between 0 and 100. */ int MeanTextConf(); - // Returns all word confidences (between 0 and 100) in an array, terminated - // by -1. The calling function must delete [] after use. - // The number of confidences should correspond to the number of space- - // delimited words in GetUTF8Text. + /** + * Returns all word confidences (between 0 and 100) in an array, terminated + * by -1. The calling function must delete [] after use. + * The number of confidences should correspond to the number of space- + * delimited words in GetUTF8Text. + */ int* AllWordConfidences(); - // Free up recognition results and any stored image data, without actually - // freeing any recognition data that would be time-consuming to reload. - // Afterwards, you must call SetImage or TesseractRect before doing - // any Recognize or Get* operation. + /** + * Free up recognition results and any stored image data, without actually + * freeing any recognition data that would be time-consuming to reload. + * Afterwards, you must call SetImage or TesseractRect before doing + * any Recognize or Get* operation. + */ void Clear(); - // Close down tesseract and free up all memory. End() is equivalent to - // destructing and reconstructing your TessBaseAPI. - // Once End() has been used, none of the other API functions may be used - // other than Init and anything declared above it in the class definition. + /** + * Close down tesseract and free up all memory. End() is equivalent to + * destructing and reconstructing your TessBaseAPI. + * Once End() has been used, none of the other API functions may be used + * other than Init and anything declared above it in the class definition. + */ void End(); - // Check whether a word is valid according to Tesseract's language model - // returns 0 if the word is invalid, non-zero if valid. - // WARNING: temporary! This function will be removed from here and placed - // in a separate API at some future time. + /** + * Check whether a word is valid according to Tesseract's language model + * @return 0 if the word is invalid, non-zero if valid. + * @warning temporary! This function will be removed from here and placed + * in a separate API at some future time. + */ int IsValidWord(const char *word); bool GetTextDirection(int* out_offset, float* out_slope); - // Set the letter_is_okay function to point somewhere else. + /** Set the letter_is_okay function to point somewhere else. */ void SetDictFunc(DictFunc f); - // Estimates the Orientation And Script of the image. - // Returns true if the image was processed successfully. + /** + * Estimates the Orientation And Script of the image. + * @return true if the image was processed successfully. + */ bool DetectOS(OSResults*); - // This method returns the features associated with the input image. + /** This method returns the features associated with the input image. */ void GetFeatures(INT_FEATURE_ARRAY int_features, int* num_features); - // Return the pointer to the i-th dawg loaded into tesseract_ object. + /** Return the pointer to the i-th dawg loaded into tesseract_ object. */ const Dawg *GetDawg(int i) const; - // Return the number of dawgs loaded into tesseract_ object. + /** Return the number of dawgs loaded into tesseract_ object. */ int NumDawgs() const; - // Return the language used in the last valid initialization. + /** Return the language used in the last valid initialization. */ const char* GetLastInitLanguage() const; + /* @} */ + protected: - // Common code for setting the image. Returns true if Init has been called. + /** Common code for setting the image. Returns true if Init has been called. */ bool InternalSetImage(); - // Run the thresholder to make the thresholded image. If pix is not NULL, - // the source is thresholded to pix instead of the internal IMAGE. + /** + * Run the thresholder to make the thresholded image. If pix is not NULL, + * the source is thresholded to pix instead of the internal IMAGE. + */ virtual void Threshold(Pix** pix); - // Find lines from the image making the BLOCK_LIST. - // Returns 0 on success. + /** + * Find lines from the image making the BLOCK_LIST. + * @return 0 on success. + */ int FindLines(); - // Delete the pageres and block list ready for a new page. + /** Delete the pageres and block list ready for a new page. */ void ClearResults(); - // Return the length of the output text string, as UTF8, assuming - // one newline per line and one per block, with a terminator, - // and assuming a single character reject marker for each rejected character. - // Also return the number of recognized blobs in blob_count. + /** + * Return the length of the output text string, as UTF8, assuming + * one newline per line and one per block, with a terminator, + * and assuming a single character reject marker for each rejected character. + * Also return the number of recognized blobs in blob_count. + */ int TextLength(int* blob_count); - // __________________________ ocropus add-ons ___________________________ + /** @defgroup ocropusAddOns ocropus add-ons */ - // Find lines from the image making the BLOCK_LIST. + /* @{ */ + /** Find lines from the image making the BLOCK_LIST. */ BLOCK_LIST* FindLinesCreateBlockList(); - // Delete a block list. - // This is to keep BLOCK_LIST pointer opaque - // and let go of including the other headers. + /** + * Delete a block list. + * This is to keep BLOCK_LIST pointer opaque + * and let go of including the other headers. + */ static void DeleteBlockList(BLOCK_LIST* block_list); - // Adapt to recognize the current image as the given character. - // The image must be preloaded and be just an image of a single character. + /** + * Adapt to recognize the current image as the given character. + * The image must be preloaded and be just an image of a single character. + */ void AdaptToCharacter(const char *unichar_repr, int length, float baseline, @@ -385,13 +464,15 @@ class TESSDLL_API TessBaseAPI { float descender, float ascender); - // Recognize text doing one pass only, using settings for a given pass. + /** Recognize text doing one pass only, using settings for a given pass. */ /*static*/ PAGE_RES* RecognitionPass1(BLOCK_LIST* block_list); /*static*/ PAGE_RES* RecognitionPass2(BLOCK_LIST* block_list, PAGE_RES* pass1_result); - // Extract the OCR results, costs (penalty points for uncertainty), - // and the bounding boxes of the characters. + /** + * Extract the OCR results, costs (penalty points for uncertainty), + * and the bounding boxes of the characters. + */ static int TesseractExtractResult(char** text, int** lengths, float** costs, @@ -401,66 +482,79 @@ class TESSDLL_API TessBaseAPI { int** y1, PAGE_RES* page_res); - // Call the Cube OCR engine. Takes the Region, line and word segmentation - // information from Tesseract as inputs. Makes changes or populates the - // output PAGE_RES object which contains the recogntion results. - // The behavior of this function depends on the - // current language and the value of the tessedit_accuracyvspeed: - // For English (and other Latin based scripts): - // If the accuracyvspeed flag is set to any value other than AVS_FASTEST, - // Cube uses the word information passed by Tesseract. - // Cube will run on a subset of the words segmented and recognized by - // Tesseract. The value of the accuracyvspeed and the Tesseract - // confidence of a word determines whether Cube runs on it or not and - // whether Cube's results override Tesseract's - // For Arabic & Hindi: - // Cube uses the Region information passed by Tesseract. It then performs - // its own line segmentation. This will change once Tesseract's line - // segmentation works for Arabic. Cube then segments each line into - // phrases. Each phrase is then recognized in phrase mode which allows - // spaces in the results. - // Note that at this point, the line segmentation algorithm might have - // some problems with ill spaced Arabic document. + /** + * Call the Cube OCR engine. Takes the Region, line and word segmentation + * information from Tesseract as inputs. Makes changes or populates the + * output PAGE_RES object which contains the recogntion results. + * The behavior of this function depends on the + * current language and the value of the tessedit_accuracyvspeed: + * For English (and other Latin based scripts): + * If the accuracyvspeed flag is set to any value other than AVS_FASTEST, + * Cube uses the word information passed by Tesseract. + * Cube will run on a subset of the words segmented and recognized by + * Tesseract. The value of the accuracyvspeed and the Tesseract + * confidence of a word determines whether Cube runs on it or not and + * whether Cube's results override Tesseract's + * For Arabic & Hindi: + * Cube uses the Region information passed by Tesseract. It then performs + * its own line segmentation. This will change once Tesseract's line + * segmentation works for Arabic. Cube then segments each line into + * phrases. Each phrase is then recognized in phrase mode which allows + * spaces in the results. + * Note that at this point, the line segmentation algorithm might have + * some problems with ill spaced Arabic document. + */ int Cube(); - // Run Cube on the lines extracted by Tesseract. + /** Run Cube on the lines extracted by Tesseract. */ int RunCubeOnLines(); - // Run Cube on a subset of the words already present in the page_res_ object - // The subset, and whether Cube overrides the results is determined by - // the SpeedVsAccuracy flag + /** + * Run Cube on a subset of the words already present in the page_res_ object + * The subset, and whether Cube overrides the results is determined by + * the SpeedVsAccuracy flag + */ int CubePostProcessWords(); - // Create a Cube line object for each line + /** Create a Cube line object for each line */ CubeLineObject **CreateLineObjects(Pixa* pixa_lines); - // Create a TBox array corresponding to the phrases in the array of - // line objects + /** + * Create a TBox array corresponding to the phrases in the array of + * line objects + */ TBOX *CreatePhraseBoxes(Boxa* boxa_lines, CubeLineObject **line_objs, int *phrase_cnt); - // Recognize the phrases saving the results to the page_res_ object + /** Recognize the phrases saving the results to the page_res_ object */ bool RecognizePhrases(int line_cnt, int phrase_cnt, CubeLineObject **line_objs, TBOX *phrase_boxes); - // Recognize a single phrase saving the results to the page_res_ object + /** Recognize a single phrase saving the results to the page_res_ object */ bool RecognizePhrase(CubeObject *phrase, PAGE_RES_IT *result); - // Create the necessary Cube Objects + /** Create the necessary Cube Objects */ bool CreateCubeObjects(); + /* @} */ protected: - Tesseract* tesseract_; // The underlying data object. - ImageThresholder* thresholder_; // Image thresholding module. - bool threshold_done_; // Image has been passed to page_image. - BLOCK_LIST* block_list_; // The page layout. - PAGE_RES* page_res_; // The page-level data. - STRING* input_file_; // Name used by training code. - STRING* output_file_; // Name used by debug code. - STRING* datapath_; // Current location of tessdata. - STRING* language_; // Last initialized language. - // Parameters saved from the Thresholder. Needed to rebuild coordinates. + Tesseract* tesseract_; ///< The underlying data object. + ImageThresholder* thresholder_; ///< Image thresholding module. + bool threshold_done_; ///< Image has been passed to page_image. + BLOCK_LIST* block_list_; ///< The page layout. + PAGE_RES* page_res_; ///< The page-level data. + STRING* input_file_; ///< Name used by training code. + STRING* output_file_; ///< Name used by debug code. + STRING* datapath_; ///< Current location of tessdata. + STRING* language_; ///< Last initialized language. + + /** + * @defgroup ThresholderParams + * Parameters saved from the Thresholder. Needed to rebuild coordinates. + */ + /* @{ */ int rect_left_; int rect_top_; int rect_width_; int rect_height_; int image_width_; int image_height_; + /* @} */ }; -} // namespace tesseract. +} * namespace tesseract. -#endif // TESSERACT_CCMAIN_BASEAPI_H__ +#endif * TESSERACT_CCMAIN_BASEAPI_H__ diff --git a/api/tesseractmain.h b/api/tesseractmain.h index 508d8bb51b..f6c2bbcaa7 100644 --- a/api/tesseractmain.h +++ b/api/tesseractmain.h @@ -34,33 +34,52 @@ extern BOOL_VAR_H(tessedit_write_images, FALSE, "Capture the image from the IPE"); extern BOOL_VAR_H(tessedit_debug_to_screen, FALSE, "Dont use debug file"); -inT32 api_main( //run from api - const char *arg0, //program name - uinT16 lang //language - ); -inT16 setup_info( //setup dummy engine info - uinT16 lang, //user language - const char *name, //of engine - const char *version //of engine - ); -inT16 read_image( //read dummy image info - IMAGE *im_out //output image - ); +/** + * run from api + * @param arg0 program name + * @param lang language + */ +inT32 api_main(const char *arg0, + uinT16 lang); +/** + * setup dummy engine info + * @param lang user language + * @param name of engine + * @param version of engine + */ +inT16 setup_info(uinT16 lang, + const char *name, + const char *version); +/** + * read dummy image info + * @param im_out read dummy image info + */ +inT16 read_image(IMAGE *im_out); #ifdef __MSW32__ -int WINAPI WinMain( //main for windows //command line - HINSTANCE hInstance, +/** + * main for windows command line + */ +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow); -LONG WINAPI WndProc( //message handler - HWND hwnd, //window with message - UINT msg, //message typ +/** + * message handler + * @param hwnd window with message + * @param msg message type + */ +LONG WINAPI WndProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam); -int parse_args ( /*refine arg list */ -int argc, /*no of input args */ -char *argv[], /*input args */ -char *arglist[] /*output args */ -); +/** + * refine argument list + * @param argc number of input arguments + * @param argv input arguments + * @param arglist output arguments + */ +int parse_args (int argc, + char *argv[], + char *arglist[]); #endif #endif diff --git a/ccmain/callnet.h b/ccmain/callnet.h index 528bd96c75..ea5ab51d64 100644 --- a/ccmain/callnet.h +++ b/ccmain/callnet.h @@ -21,8 +21,11 @@ #define CALLNET_H // extern "C" { -void init_net(); /* Initialise net */ -void callnet( /* Apply image to net */ +/** Initialise net */ +void init_net(); + +/** Apply image to net */ +void callnet( float *input_vector, char *top, float *top_score, diff --git a/ccmain/charcut.h b/ccmain/charcut.h index 6f7996d49d..0b791bd14a 100644 --- a/ccmain/charcut.h +++ b/ccmain/charcut.h @@ -16,6 +16,14 @@ ** limitations under the License. * **********************************************************************/ +/** + * @file charcut.h + * @note Formerly charclip.h + * @brief Code for character clipping + * @author Phil Cheatle + * @date Created Wed Nov 11 08:35:15 GMT 1992 + * + */ #ifndef CHARCUT_H #define CHARCUT_H @@ -25,8 +33,8 @@ #include "notdll.h" class ScrollView; -/************************************************************************* - * CLASS PIXROW +/** + * @class PIXROW * * This class describes the pixels occupied by a blob. It uses two arrays, (min * and max), each with one element per row, to identify the min and max x @@ -34,28 +42,29 @@ class ScrollView; * The number of rows used to describe the blob is held in row_count - note that * some rows may be unoccupied - signified by max < min. The page coordinate of * the row defined by min[0] and max[0] is held in row_offset. - *************************************************************************/ + */ class PIXROW:public ELIST_LINK { public: - inT16 row_offset; //y coord of min[0] - inT16 row_count; //length of arrays - inT16 *min; //array of min x - inT16 *max; //array of max x - - PIXROW() { //empty constructor + inT16 row_offset; ///< y coord of min[0] + inT16 row_count; ///< length of arrays + inT16 *min; ///< array of min x + inT16 *max; ///< array of max x + /** empty constructor */ + PIXROW() { row_offset = 0; row_count = 0; min = NULL; max = NULL; } - PIXROW( //specified size + /** specified size */ + PIXROW( inT16 pos, inT16 count, PBLOB *blob); - - ~PIXROW () { //destructor + /** destructor */ + ~PIXROW () { if (min != NULL) free_mem(min); if (max != NULL) @@ -63,31 +72,56 @@ class PIXROW:public ELIST_LINK max = NULL; } - void plot( //use current settings - ScrollView* fd) const; //where to paint + /** + * use current settings + * @param fd where to paint + */ + void plot(ScrollView* fd) const; + + /** + * return bounding box + * @return true if box exceeds image + */ + TBOX bounding_box() const; - TBOX bounding_box() const; //return bounding box - //return true if box exceeds image bool bad_box(int xsize, int ysize) const; - void contract( //force end on black - IMAGELINE *imlines, //image array - inT16 x_offset, //of pixels[0] - inT16 foreground_colour); //0 or 1 + /** + * force end on black + * @param imlines image array + * @param x_offset of pixels[0] + * @param foreground_colour 0 or 1 + */ + void contract( + IMAGELINE *imlines, + inT16 x_offset, + inT16 foreground_colour); - //image array + /** + * @param imlines image array + * @param imbox image box + * @param prev for prev blob + * @param next for next blob + * @param foreground_colour 0 or 1 + */ BOOL8 extend(IMAGELINE *imlines, TBOX &imbox, - PIXROW *prev, //for prev blob - PIXROW *next, //for next blob - inT16 foreground_colour); //0 or 1 + PIXROW *prev, + PIXROW *next, + inT16 foreground_colour); - //box of imlines extnt + /** + * @param imlines box of imlines extnt + * @param imbox image box + * @param row row containing word + * @param clip_image unscaled char image + * @param baseline_pos baseline ht in image + */ void char_clip_image(IMAGELINE *imlines, TBOX &im_box, - ROW *row, //row containing word - IMAGE &clip_image, //unscaled char image - float &baseline_pos); //baseline ht in image + ROW *row, + IMAGE &clip_image, + float &baseline_pos); }; @@ -97,24 +131,27 @@ extern BOOL_VAR_H (show_char_clipping, TRUE, "Show clip image window?"); extern INT_VAR_H (net_image_width, 40, "NN input image width"); extern INT_VAR_H (net_image_height, 36, "NN input image height"); extern INT_VAR_H (net_image_x_height, 22, "NN input image x_height"); -void char_clip_word( // - WERD *word, //word to be processed - IMAGE &bin_image, //whole image - PIXROW_LIST *&pixrow_list, //pixrows built - IMAGELINE *&imlines, //lines cut from image - TBOX &pix_box //box defining imlines +void char_clip_word( + WERD *word, ///< word to be processed + IMAGE &bin_image, ///< whole image + PIXROW_LIST *&pixrow_list, ///< pixrows built + IMAGELINE *&imlines, ///< lines cut from image + TBOX &pix_box ///< box defining imlines ); -IMAGELINE *generate_imlines( //get some imagelines - IMAGE &bin_image, //from here +/** get some imagelines */ +IMAGELINE *generate_imlines( + IMAGE &bin_image, ///< from here TBOX &pix_box); - //word to be processed -ScrollView* display_clip_image(WERD *word, - IMAGE &bin_image, //whole image - PIXROW_LIST *pixrow_list, //pixrows built - TBOX &pix_box //box of subimage + +ScrollView* display_clip_image(WERD *word, ///< word to be processed + IMAGE &bin_image, ///< whole image + PIXROW_LIST *pixrow_list, ///< pixrows built + TBOX &pix_box ///< box of subimage ); void display_images(IMAGE &clip_image, IMAGE &scaled_image); -void plot_pixrows( //plot for all blobs + +/** plot for all blobs */ +void plot_pixrows( PIXROW_LIST *pixrow_list, ScrollView* win); #endif diff --git a/ccmain/control.h b/ccmain/control.h index c9072c7a3a..61e8e1d188 100644 --- a/ccmain/control.h +++ b/ccmain/control.h @@ -17,6 +17,11 @@ * **********************************************************************/ +/** + * @file control.h + * Module-independent matcher controller. + */ + #ifndef CONTROL_H #define CONTROL_H @@ -34,12 +39,12 @@ enum ACCEPTABLE_WERD_TYPE { - AC_UNACCEPTABLE, //Unacceptable word - AC_LOWER_CASE, //ALL lower case - AC_UPPER_CASE, //ALL upper case - AC_INITIAL_CAP, //ALL but initial lc - AC_LC_ABBREV, //a.b.c. - AC_UC_ABBREV //A.B.C. + AC_UNACCEPTABLE, ///< Unacceptable word + AC_LOWER_CASE, ///< ALL lower case + AC_UPPER_CASE, ///< ALL upper case + AC_INITIAL_CAP, ///< ALL but initial lc + AC_LC_ABBREV, ///< a.b.c. + AC_UC_ABBREV ///< A.B.C. }; typedef BOOL8 (*BLOB_REJECTOR) (PBLOB *, BLOB_CHOICE_IT *, void *); @@ -139,38 +144,57 @@ void classify_word_pass1( //recog one word */ //word to do void classify_word_pass2(WERD_RES *word, ROW *row); -void match_word_pass2( //recog one word - WERD_RES *word, //word to do +/** + * recognize one word + * @param word word to do + */ +void match_word_pass2( + WERD_RES *word, ROW *row, float x_height); -void fix_hyphens( //crunch double hyphens - WERD_CHOICE *choice, //string to fix - WERD *word, //word to do //char choices +/** + * crunch double hyphens + * @param choice string to fix + * @param word word to do + * @param blob_choices char choices + */ +void fix_hyphens( + WERD_CHOICE *choice, + WERD *word, BLOB_CHOICE_LIST_CLIST *blob_choices); -void merge_blobs( //combine 2 blobs - PBLOB *blob1, //dest blob - PBLOB *blob2 //source blob + +/** + * combine 2 blobs + * @param blob1 dest blob + * @param blob2 source blob + */ +void merge_blobs( + PBLOB *blob1, + PBLOB *blob2 ); -void choice_dump_tester( //dump chars in word - PBLOB *, //blob - DENORM *, //de-normaliser - BOOL8 correct, //ly segmented - char *text, //correct text - inT32 count, //chars in text - BLOB_CHOICE_LIST *ratings //list of results +/** dump chars in word */ +void choice_dump_tester( + PBLOB *, ///< blob + DENORM *, ///< de-normaliser + BOOL8 correct, ///< ly segmented + char *text, ///< correct text + inT32 count, ///< chars in text + BLOB_CHOICE_LIST *ratings ///< list of results ); WERD *make_bln_copy(WERD *src_word, ROW *row, BLOCK* block, float x_height, DENORM *denorm); BOOL8 check_debug_pt(WERD_RES *word, int location); -void add_in_one_row( //good chars in word - ROW_RES *row, //current row - STATS *fonts, //font stats - inT8 *italic, //output count - inT8 *bold //output count +/** good chars in word */ +void add_in_one_row( + ROW_RES *row, ///< current row + STATS *fonts, ///< font stats + inT8 *italic, ///< output count + inT8 *bold ///< output count ); -void find_modal_font( //good chars in word - STATS *fonts, //font stats - inT8 *font_out, //output font - inT8 *font_count //output count +/** good chars in word */ +void find_modal_font( + STATS *fonts, ///< font stats + inT8 *font_out, ///< output font + inT8 *font_count ///< output count ); #endif diff --git a/ccmain/fixspace.h b/ccmain/fixspace.h index 02385b219f..1d862b4a67 100644 --- a/ccmain/fixspace.h +++ b/ccmain/fixspace.h @@ -42,7 +42,7 @@ extern BOOL_VAR_H (tessedit_test_uniform_wd_spacing, FALSE, "Limit context word spacing"); extern BOOL_VAR_H (tessedit_prefer_joined_punct, FALSE, "Reward punctation joins"); -extern INT_VAR_H (fixsp_done_mode, 1, "What constitues done for spacing"); +extern INT_VAR_H (fixsp_done_mode, 1, "What constitutes done for spacing"); extern INT_VAR_H (debug_fix_space_level, 0, "Contextual fixspace debug"); extern STRING_VAR_H (numeric_punctuation, ".,", "Punct. chs expected WITHIN numbers"); diff --git a/ccmain/output.h b/ccmain/output.h index c71e50b446..4c923020df 100644 --- a/ccmain/output.h +++ b/ccmain/output.h @@ -56,46 +56,53 @@ extern BOOL_VAR_H (tessedit_word_for_word, FALSE, extern BOOL_VAR_H (tessedit_consistent_reps, TRUE, "Force all rep chars the same"); -void write_results( //output a word - PAGE_RES_IT &page_res_it, //full info - char newline_type, //type of newline - BOOL8 force_eol, //override tilde crunch? - BOOL8 write_to_shm //send to api +/** output a word */ +void write_results( + PAGE_RES_IT &page_res_it, ///< full info + char newline_type, ///< type of newline + BOOL8 force_eol, ///< override tilde crunch? + BOOL8 write_to_shm ///< send to api ); -WERD_CHOICE *make_epaper_choice( //convert one word - WERD_RES *word, //word to do - char newline_type //type of newline + +/** convert one word */ +WERD_CHOICE *make_epaper_choice( + WERD_RES *word, ///< word to do + char newline_type ///< type of newline ); -inT16 make_reject ( //make reject code -TBOX * inset_box, //bounding box -inT16 prevright, //previous char -inT16 nextleft, //next char -DENORM * denorm, //de-normalizer -char word_string[] //output string +/** make reject code */ +inT16 make_reject ( +TBOX * inset_box, ///< bounding box +inT16 prevright, ///< previous char +inT16 nextleft, ///< next char +DENORM * denorm, ///< de-normalizer +char word_string[] ///< output string ); -char determine_newline_type( //test line ends - WERD *word, //word to do - BLOCK *block, //current block - WERD *next_word, //next word - BLOCK *next_block //block of next word + +/** test line ends */ +char determine_newline_type(WERD *word, ///< word to do + BLOCK *block, ///< current block + WERD *next_word, ///< next word + BLOCK *next_block ///< block of next word ); -void write_cooked_text( //write output - WERD *word, //word to do - const STRING &text, //text to write - BOOL8 acceptable, //good stuff - BOOL8 pass2, //done on pass2 - FILE *fp //file to write +/** write output */ +void write_cooked_text(WERD *word, ///< word to do + const STRING &text, ///< text to write + BOOL8 acceptable, ///< good stuff + BOOL8 pass2, ///< done on pass2 + FILE *fp ///< file to write ); -void write_shm_text( //write output - WERD_RES *word, //word to do - BLOCK *block, //block it is from - ROW_RES *row, //row it is from - const STRING &text, //text to write +/** write output */ +void write_shm_text(WERD_RES *word, ///< word to do + BLOCK *block, ///< block it is from + ROW_RES *row, ///< row it is from + const STRING &text, ///< text to write const STRING &text_lengths ); -void write_map( //output a map file - FILE *mapfile, //mapfile to write to - WERD_RES *word); +/** output a map file */ +void write_map( + FILE *mapfile, ///< mapfile to write to + WERD_RES *word ///< word + ); /*FILE *open_outfile( //open .map & .unlv file const char *extension);*/ void write_unlv_text(WERD_RES *word); diff --git a/ccmain/tessio.h b/ccmain/tessio.h index a63e7a376a..c48ec0f6b7 100644 --- a/ccmain/tessio.h +++ b/ccmain/tessio.h @@ -24,87 +24,187 @@ #include "tessclas.h" #include "notdll.h" -TEXTROW *get_tess_row_file( //open read & close - const char *name, //file name - TPOINT *topright //corner +/** + * open read & close + * @param name file name + * @param topright corner + */ +TEXTROW *get_tess_row_file( + const char *name, + TPOINT *topright ); -TBLOB *get_tess_blob_file( //open read & close - const char *name, //file name - TPOINT *topright //corner +/** + * open read & close + * @param name file name + * @param topright corner + */ +TBLOB *get_tess_blob_file( + const char *name, + TPOINT *topright ); -TEXTROW *readrows( //read row file - int gphfd, /*file to read */ - int count, /*number expected */ - TPOINT *imagesize //size of image +/** + * read row file + * @param gphfd file to read + * @param count number expected + * @param imagesize size of image + */ +TEXTROW *readrows( + int gphfd, + int count, + TPOINT *imagesize ); -TWERD *readwords( //read some words - int gphfd, /*file to read */ - int count, /*number expected */ - TEXTROW *row, /*row it comes from */ - TPOINT *imagesize /*size of image */ +/** + * read some words + * @param gphfd file to read + * @param count number expected + * @param row row it comes from + * @param imagesize size of image + */ +TWERD *readwords( + int gphfd, + int count, + TEXTROW *row, + TPOINT *imagesize ); -TBLOB *readblobs( //read some blobs - int gphfd, /*file to read */ - int count, /*number expected */ - TPOINT *imagesize /*size of image */ +/** + * read some blobs + * @param gphfd file to read + * @param count number expected + * @param imagesize size of image + */ +TBLOB *readblobs( + int gphfd, + int count, + TPOINT *imagesize ); -char *readratings( //get a string - int gphfd, /*file to read */ - int ratingspace /*size to read */ +/** + * get a string + * @param gphfd file to read + * @param ratingspace size to read + */ +char *readratings( + int gphfd, + int ratingspace ); -void readoutlines( //read some outlines - int gphfd, /*file to read */ - TESSLINE **outlines, /*array of ptrs */ - int outlinecount /*no to read */ +/** + * read some outlines + * @param gphfd file to read + * @param outlines array of ptrs + * @param outlinecount no to read + */ +void readoutlines( + int gphfd, + TESSLINE **outlines, + int outlinecount ); -int readgph( //read with testing - int fd, /*file to read */ - void *start, /*buffer to write */ - int size, /*amount to write */ - int checkeof /*give error on eof? */ +/** + * read with testing + * @param fd file to read + * @param start buffer to write + * @param size amount to write + * @param checkeof give error on eof? + */ +int readgph( + int fd, + void *start, + int size, + int checkeof ); -void write_row( //write a row - FILE *name, //file to write - TEXTROW *row /*row to write */ +/** + * write a row + * @param name file name + * @param row row to write + */ +void write_row( + FILE *name, + TEXTROW *row ); -void write_error_row( //write special row - FILE *name, /*file name */ - TEXTROW *row, /*row to write */ - int wordcount /*no of words to go */ +/** + * write special row + * @param name file name + * @param row row to write + * @param wordcount number of words to go + */ +void write_error_row( + FILE *name, + TEXTROW *row, + int wordcount ); -void write_error_blob( //write special blob - FILE *name, /*file name */ - TBLOB *blob, /*blob to write */ - char *charlist, /*true chars */ - int charcount /*no of true chars */ +/** + * write special blob + * @param name file name + * @param blob blob to write + * @param charlist true chars + * @param charcount number of true chars + */ +void write_error_blob( + FILE *name, + TBLOB *blob, + char *charlist, + int charcount ); -void write_error_word( //write special word - FILE *name, /*file name */ - TWERD *word, /*word to write */ - char *charlist, /*true chars */ - int charcount /*no of true chars */ +/** + * write special word + * @param name file name + * @param word word to write + * @param charlist true chars + * @param charcount number of true chars + */ +void write_error_word( + FILE *name, + TWERD *word, + char *charlist, + int charcount ); -void writeblob( //write a blob - FILE *name, /*file to write */ - TBLOB *blob /*blob to write */ +/** + * write a blob + * @param name file to write + * @param blob blob to write + */ +void writeblob( + FILE *name, + TBLOB *blob ); -void serial_outlines( //serialize - FILE *name, /*file to write to */ - TBLOB *blob, /*current blob */ - register TESSLINE *outline, /*current outline */ - int *outlineno /*current serial no */ +/** + * serialize + * @param name file to write to + * @param blob current blob + * @param outline current outline + * @param outlineno current serial no + */ +void serial_outlines( + FILE *name, + TBLOB *blob, + register TESSLINE *outline, + int *outlineno ); -int countloop( //count loopsize - register BYTEVEC *vector /*vectors to count */ +/** + * count loopsize + * @param vector vectors to count + */ +int countloop( + register BYTEVEC *vector ); -int outlineserial( //get serial no - register TESSLINE *outline, /*start of serach */ - register TESSLINE *target, /*outline to find */ - int serial /*serial no so far */ +/** + * get serial no + * @param outline start of search + * @param target outline to find + * @param serial serial no so far + */ +int outlineserial( + register TESSLINE *outline, + register TESSLINE *target, + int serial ); -void writegph( //interface to fwrite - FILE *name, /*file to write */ - void *start, /*buffer to write */ - int size /*amount to write */ +/** + * Interface to fwrite + * @param name file to write + * @param start buffer to write + * @param size amount to write + */ +void writegph( + FILE *name, + void *start, + int size ); #endif diff --git a/ccmain/thresholder.h b/ccmain/thresholder.h index 69635df606..7022a46b17 100644 --- a/ccmain/thresholder.h +++ b/ccmain/thresholder.h @@ -25,81 +25,81 @@ struct Pix; namespace tesseract { -// Base class for all tesseract image thresholding classes. -// Specific classes can add new thresholding methods by -// overriding ThresholdToIMAGE and/or ThresholdToPix. -// Each instance deals with a single image, but the design is intended to -// be useful for multiple calls to SetRectangle and ThresholdTo* if -// desired. +/// Base class for all tesseract image thresholding classes. +/// Specific classes can add new thresholding methods by +/// overriding ThresholdToIMAGE and/or ThresholdToPix. +/// Each instance deals with a single image, but the design is intended to +/// be useful for multiple calls to SetRectangle and ThresholdTo* if +/// desired. class ImageThresholder { public: ImageThresholder(); virtual ~ImageThresholder(); - // Destroy the Pix if there is one, freeing memory. + /// Destroy the Pix if there is one, freeing memory. virtual void Clear(); - // Return true if no image has been set. + /// Return true if no image has been set. bool IsEmpty() const; - // SetImage makes a copy of only the metadata, not the underlying - // image buffer. It promises to treat the source as read-only in either case, - // but in return assumes that the Pix or image buffer remain valid - // throughout the life of the ImageThresholder. - // Greyscale of 8 and color of 24 or 32 bits per pixel may be given. - // Palette color images will not work properly and must be converted to - // 24 bit. - // Binary images of 1 bit per pixel may also be given but they must be - // byte packed with the MSB of the first byte being the first pixel, and a - // one pixel is WHITE. For binary images set bytes_per_pixel=0. + /// SetImage makes a copy of only the metadata, not the underlying + /// image buffer. It promises to treat the source as read-only in either case, + /// but in return assumes that the Pix or image buffer remain valid + /// throughout the life of the ImageThresholder. + /// Greyscale of 8 and color of 24 or 32 bits per pixel may be given. + /// Palette color images will not work properly and must be converted to + /// 24 bit. + /// Binary images of 1 bit per pixel may also be given but they must be + /// byte packed with the MSB of the first byte being the first pixel, and a + /// one pixel is WHITE. For binary images set bytes_per_pixel=0. void SetImage(const unsigned char* imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line); - // Store the coordinates of the rectangle to process for later use. - // Doesn't actually do any thresholding. + /// Store the coordinates of the rectangle to process for later use. + /// Doesn't actually do any thresholding. void SetRectangle(int left, int top, int width, int height); - // Get enough parameters to be able to rebuild bounding boxes in the - // original image (not just within the rectangle). - // Left and top are enough with top-down coordinates, but - // the height of the rectangle and the image are needed for bottom-up. + /// Get enough parameters to be able to rebuild bounding boxes in the + /// original image (not just within the rectangle). + /// Left and top are enough with top-down coordinates, but + /// the height of the rectangle and the image are needed for bottom-up. virtual void GetImageSizes(int* left, int* top, int* width, int* height, int* imagewidth, int* imageheight); - // Return true if HAVE_LIBLEPT and this thresholder implements the Pix - // interface. + /// Return true if HAVE_LIBLEPT and this thresholder implements the Pix + /// interface. virtual bool HasThresholdToPix() const; - // Return true if the source image is color. + /// Return true if the source image is color. bool IsColor() const { return image_bytespp_ >= 3; } - // Threshold the source image as efficiently as possible to the output - // tesseract IMAGE class. + /// Threshold the source image as efficiently as possible to the output + /// tesseract IMAGE class. virtual void ThresholdToIMAGE(IMAGE* image); #ifdef HAVE_LIBLEPT - // Pix vs raw, which to use? - // Implementations should provide the ability to source and target Pix - // where possible. A future version of Tesseract may choose to use Pix - // as its internal representation and discard IMAGE altogether. - // Because of that, an implementation that sources and targets Pix may end up - // with less copies than an implementation that does not. - // NOTE: Opposite to SetImage for raw images, SetImage for Pix clones its - // input, so the source pix may be pixDestroyed immediately after. + /// Pix vs raw, which to use? + /// Implementations should provide the ability to source and target Pix + /// where possible. A future version of Tesseract may choose to use Pix + /// as its internal representation and discard IMAGE altogether. + /// Because of that, an implementation that sources and targets Pix may end up + /// with less copies than an implementation that does not. + /// NOTE: Opposite to SetImage for raw images, SetImage for Pix clones its + /// input, so the source pix may be pixDestroyed immediately after. void SetImage(const Pix* pix); - // Threshold the source image as efficiently as possible to the output Pix. - // Creates a Pix and sets pix to point to the resulting pointer. - // Caller must use pixDestroy to free the created Pix. + /// Threshold the source image as efficiently as possible to the output Pix. + /// Creates a Pix and sets pix to point to the resulting pointer. + /// Caller must use pixDestroy to free the created Pix. virtual void ThresholdToPix(Pix** pix); - // Get a clone/copy of the source image rectangle. - // The returned Pix must be pixDestroyed. - // This function will be used in the future by the page layout analysis, and - // the layout analysis that uses it will only be available with Leptonica, - // so there is no raw equivalent. + /// Get a clone/copy of the source image rectangle. + /// The returned Pix must be pixDestroyed. + /// This function will be used in the future by the page layout analysis, and + /// the layout analysis that uses it will only be available with Leptonica, + /// so there is no raw equivalent. Pix* GetPixRect(); #endif @@ -107,66 +107,66 @@ class ImageThresholder { // ---------------------------------------------------------------------- // Utility functions that may be useful components for other thresholders. - // Common initialization shared between SetImage methods. + /// Common initialization shared between SetImage methods. virtual void Init(); - // Return true if we are processing the full image. + /// Return true if we are processing the full image. bool IsFullImage() const { return rect_left_ == 0 && rect_top_ == 0 && rect_width_ == image_width_ && rect_height_ == image_height_; } - // Otsu threshold the rectangle, taking everything except the image buffer - // pointer from the class, to the output IMAGE. + /// Otsu threshold the rectangle, taking everything except the image buffer + /// pointer from the class, to the output IMAGE. void OtsuThresholdRectToIMAGE(const unsigned char* imagedata, int bytes_per_pixel, int bytes_per_line, IMAGE* image) const; - // Threshold the rectangle, taking everything except the image buffer pointer - // from the class, using thresholds/hi_values to the output IMAGE. + /// Threshold the rectangle, taking everything except the image buffer pointer + /// from the class, using thresholds/hi_values to the output IMAGE. void ThresholdRectToIMAGE(const unsigned char* imagedata, int bytes_per_pixel, int bytes_per_line, const int* thresholds, const int* hi_values, IMAGE* image) const; - // Cut out the requested rectangle of the source raw binary image to the - // output IMAGE. + /// Cut out the requested rectangle of the source raw binary image to the + /// output IMAGE. void CopyBinaryRectRawToIMAGE(IMAGE* image) const; #ifdef HAVE_LIBLEPT - // Otsu threshold the rectangle, taking everything except the image buffer - // pointer from the class, to the output Pix. + /// Otsu threshold the rectangle, taking everything except the image buffer + /// pointer from the class, to the output Pix. void OtsuThresholdRectToPix(const unsigned char* imagedata, int bytes_per_pixel, int bytes_per_line, Pix** pix) const; - // Threshold the rectangle, taking everything except the image buffer pointer - // from the class, using thresholds/hi_values to the output IMAGE. + /// Threshold the rectangle, taking everything except the image buffer pointer + /// from the class, using thresholds/hi_values to the output IMAGE. void ThresholdRectToPix(const unsigned char* imagedata, int bytes_per_pixel, int bytes_per_line, const int* thresholds, const int* hi_values, Pix** pix) const; - // Copy the raw image rectangle, taking all data from the class, to the Pix. + /// Copy the raw image rectangle, taking all data from the class, to the Pix. void RawRectToPix(Pix** pix) const; - // Cut out the requested rectangle of the binary image to the output IMAGE. + /// Cut out the requested rectangle of the binary image to the output IMAGE. void CopyBinaryRectPixToIMAGE(IMAGE* image) const; #endif protected: #ifdef HAVE_LIBLEPT - // Clone or other copy of the source Pix. - // The pix will always be PixDestroy()ed on destruction of the class. + /// Clone or other copy of the source Pix. + /// The pix will always be PixDestroy()ed on destruction of the class. Pix* pix_; #endif - // Exactly one of pix_ and image_data_ is not NULL. - const unsigned char* image_data_; // Raw source image. + /// Exactly one of pix_ and image_data_ is not NULL. + const unsigned char* image_data_; //< Raw source image. - int image_width_; // Width of source image/pix. - int image_height_; // Height of source image/pix. - int image_bytespp_; // Bytes per pixel of source image/pix. - int image_bytespl_; // Bytes per line of source image/pix. + int image_width_; //< Width of source image/pix. + int image_height_; //< Height of source image/pix. + int image_bytespp_; //< Bytes per pixel of source image/pix. + int image_bytespl_; //< Bytes per line of source image/pix. // Limits of image rectangle to be processed. int rect_left_; int rect_top_; @@ -178,3 +178,4 @@ class ImageThresholder { #endif // TESSERACT_CCMAIN_THRESHOLDER_H__ + diff --git a/ccmain/varabled.h b/ccmain/varabled.h index 26b19faeda..0a5a034900 100644 --- a/ccmain/varabled.h +++ b/ccmain/varabled.h @@ -16,9 +16,12 @@ // limitations under the License. // /////////////////////////////////////////////////////////////////////// -// -// The variables editor is used to edit all the variables used within -// tesseract from the ui. + +/** + * @file varabled.h + * The variables editor is used to edit all the variables used within + * tesseract from the ui. + */ #ifndef GRAPHICS_DISABLED #ifndef VARABLED_H #define VARABLED_H @@ -30,7 +33,7 @@ class SVMenuNode; -// A list of all possible variable types used. +/** A list of all possible variable types used. */ enum VarType { VT_INTEGER, VT_BOOLEAN, @@ -38,20 +41,22 @@ enum VarType { VT_DOUBLE }; -// A rather hackish helper structure which can take any kind of variable input -// (defined by VarType) and do a couple of common operations on them, like -// comparisond or getting its value. It is used in the context of the -// VariablesEditor as a bridge from the internal tesseract variables to the -// ones displayed by the ScrollView server. +/** + * A rather hackish helper structure which can take any kind of variable input + * (defined by VarType) and do a couple of common operations on them, like + * comparisond or getting its value. It is used in the context of the + * VariablesEditor as a bridge from the internal tesseract variables to the + * ones displayed by the ScrollView server. + */ class VariableContent : public ELIST_LINK { public: - // Compare two VC objects by their name. + /** Compare two VC objects by their name. */ static int Compare(const void* v1, const void* v2); - // Gets a VC object identified by its ID. + /** Gets a VC object identified by its ID. */ static VariableContent* GetVariableContentById(int id); - // Constructors for the various VarTypes. + /** Constructors for the various VarTypes. */ VariableContent() { } VariableContent(STRING_VARIABLE* it); @@ -60,7 +65,7 @@ class VariableContent : public ELIST_LINK { VariableContent(double_VARIABLE* it); - // Getters and Setters. + /** Getters and Setters. */ void SetValue(const char* val); const char* GetValue() const; const char* GetName() const; @@ -70,11 +75,11 @@ class VariableContent : public ELIST_LINK { bool HasChanged() { return changed_; } private: - // The unique ID of this VC object. + /** The unique ID of this VC object. */ int my_id_; - // Whether the variable was changed_ and thus needs to be rewritten. + /** Whether the variable was changed_ and thus needs to be rewritten. */ bool changed_; - // The actual vartype of this VC object. + /** The actual vartype of this VC object. */ VarType var_type_; STRING_VARIABLE* sIt; @@ -85,36 +90,46 @@ class VariableContent : public ELIST_LINK { ELISTIZEH(VariableContent) -// The variables editor enables the user to edit all the variables used within -// tesseract. It can be invoked on its own, but is supposed to be invoked by -// the program editor. +/** + * The variables editor enables the user to edit all the variables used within + * tesseract. It can be invoked on its own, but is supposed to be invoked by + * the program editor. + */ class VariablesEditor : public SVEventHandler { public: - // Integrate the variables editor as popupmenu into the existing scrollview - // window (usually the pg editor). If sv == null, create a new empty - // empty window and attach the variables editor to that window (ugly). + /** + * Integrate the variables editor as popupmenu into the existing scrollview + * window (usually the pg editor). If sv == null, create a new empty + * empty window and attach the variables editor to that window (ugly). + */ VariablesEditor(const tesseract::Tesseract*, ScrollView* sv = NULL); - // Event listener. Waits for SVET_POPUP events and processes them. + /** Event listener. Waits for SVET_POPUP events and processes them. */ void Notify(const SVEvent* sve); private: - // Gets the up to the first 3 prefixes from s (split by _). - // For example, tesseract_foo_bar will be split into tesseract,foo and bar. + /** + * Gets the up to the first 3 prefixes from s (split by _). + * For example, tesseract_foo_bar will be split into tesseract, foo, and bar. + */ void GetPrefixes(const char* s, STRING* level_one, STRING* level_two, STRING* level_three); - // Gets the first n words (split by _) and puts them in t. - // For example, tesseract_foo_bar with N=2 will yield tesseract_foo_. + /** + * Gets the first n words (split by _) and puts them in t. + * For example, tesseract_foo_bar with N=2 will yield tesseract_foo_. + */ void GetFirstWords(const char *s, // source string int n, // number of words char *t); // target string - // Find all editable variables used within tesseract and create a - // SVMenuNode tree from it. + /** + * Find all editable variables used within tesseract and create a + * SVMenuNode tree from it. + */ SVMenuNode *BuildListOfAllLeaves(); - // Write all (changed_) variables to a config file. + /** Write all (changed_) variables to a config file. */ void WriteVars(char* filename, bool changes_only); ScrollView* sv_window_; diff --git a/ccstruct/ratngs.cpp b/ccstruct/ratngs.cpp index 72f4dfb638..30e4db2a8a 100644 --- a/ccstruct/ratngs.cpp +++ b/ccstruct/ratngs.cpp @@ -29,16 +29,16 @@ extern FILE *matcher_fp; ELISTIZE (BLOB_CHOICE) CLISTIZE (BLOB_CHOICE_LIST) CLISTIZE (WERD_CHOICE) //extern FILE* matcher_fp; -/********************************************************************** +/** * BLOB_CHOICE::BLOB_CHOICE * * Constructor to build a BLOB_CHOICE from a char, rating and certainty. - **********************************************************************/ -BLOB_CHOICE::BLOB_CHOICE(UNICHAR_ID src_unichar_id, // character id - float src_rating, // rating - float src_cert, // certainty - inT8 src_config, // config (font) - int src_script_id // script + */ +BLOB_CHOICE::BLOB_CHOICE(UNICHAR_ID src_unichar_id, //< character id + float src_rating, //< rating + float src_cert, //< certainty + inT8 src_config, //< config (font) + int src_script_id //< script ) { unichar_id_ = src_unichar_id; rating_ = src_rating; @@ -47,11 +47,11 @@ BLOB_CHOICE::BLOB_CHOICE(UNICHAR_ID src_unichar_id, // character id script_id_ = src_script_id; } -/********************************************************************** +/** * BLOB_CHOICE::BLOB_CHOICE * * Constructor to build a BLOB_CHOICE from another BLOB_CHOICE. - **********************************************************************/ + */ BLOB_CHOICE::BLOB_CHOICE(const BLOB_CHOICE &other) { unichar_id_ = other.unichar_id(); rating_ = other.rating(); @@ -60,12 +60,12 @@ BLOB_CHOICE::BLOB_CHOICE(const BLOB_CHOICE &other) { script_id_ = other.script_id(); } -/********************************************************************** +/** * WERD_CHOICE::WERD_CHOICE * * Constructor to build a WERD_CHOICE from the given string. * The function assumes that src_string is not NULL. - **********************************************************************/ + */ WERD_CHOICE::WERD_CHOICE(const char *src_string, const UNICHARSET &unicharset) { STRING src_lengths; @@ -83,7 +83,7 @@ WERD_CHOICE::WERD_CHOICE(const char *src_string, } } -/********************************************************************** +/** * WERD_CHOICE::init * * Helper function to build a WERD_CHOICE from the given string, @@ -92,7 +92,7 @@ WERD_CHOICE::WERD_CHOICE(const char *src_string, * The function assumes that src_string is not NULL. * src_lengths argument could be NULL, in which case the unichars * in src_string are assumed to all be of length 1. - **********************************************************************/ + */ void WERD_CHOICE::init(const char *src_string, const char *src_lengths, float src_rating, @@ -119,9 +119,9 @@ void WERD_CHOICE::init(const char *src_string, permuter_ = src_permuter; } -/********************************************************************** +/** * WERD_CHOICE::~WERD_CHOICE - **********************************************************************/ + */ WERD_CHOICE::~WERD_CHOICE() { delete[] unichar_ids_; delete[] fragment_lengths_; @@ -129,12 +129,12 @@ WERD_CHOICE::~WERD_CHOICE() { } -/********************************************************************** +/** * WERD_CHOICE::set_blob_choices * * Delete current blob_choices. Set the blob_choices to the given new * list. - **********************************************************************/ + */ void WERD_CHOICE::set_blob_choices(BLOB_CHOICE_LIST_CLIST *blob_choices) { if (blob_choices_ != blob_choices) { delete_blob_choices(); @@ -143,11 +143,11 @@ void WERD_CHOICE::set_blob_choices(BLOB_CHOICE_LIST_CLIST *blob_choices) { } -/********************************************************************** +/** * contains_unichar_id * * Returns true if unichar_ids_ contain the given unichar_id, false otherwise. - ************************************************************************/ + */ bool WERD_CHOICE::contains_unichar_id(UNICHAR_ID unichar_id) const { for (int i = 0; i < length_; ++i) { if (unichar_ids_[i] == unichar_id) { @@ -157,13 +157,13 @@ bool WERD_CHOICE::contains_unichar_id(UNICHAR_ID unichar_id) const { return false; } -/********************************************************************** +/** * remove_unichar_ids * * Removes num unichar ids starting from index start from unichar_ids_ * and updates length_ and fragment_lengths_ to reflect this change. * Note: this function does not modify rating_ and certainty_. - ***********************************************************************/ + */ void WERD_CHOICE::remove_unichar_ids(int start, int num) { ASSERT_HOST(start >= 0 && start + num <= length_); for (int i = start; i+num < length_; ++i) { @@ -173,13 +173,13 @@ void WERD_CHOICE::remove_unichar_ids(int start, int num) { length_ -= num; } -/********************************************************************** +/** * string_and_lengths * * Populates the given word_str with unichars from unichar_ids and * and word_lengths_str with the corresponding unichar lengths. * Uses current_unicharset to make unichar id -> unichar conversions. - **********************************************************************/ + */ void WERD_CHOICE::string_and_lengths(const UNICHARSET ¤t_unicharset, STRING *word_str, STRING *word_lengths_str) const { @@ -194,12 +194,12 @@ void WERD_CHOICE::string_and_lengths(const UNICHARSET ¤t_unicharset, } } -/********************************************************************** +/** * append_unichar_id * * Make sure there is enough space in the word for the new unichar id * and call append_unichar_id_space_allocated(). - **********************************************************************/ + */ void WERD_CHOICE::append_unichar_id( UNICHAR_ID unichar_id, char fragment_length, float rating, float certainty) { @@ -210,13 +210,13 @@ void WERD_CHOICE::append_unichar_id( rating, certainty); } -/********************************************************************** +/** * WERD_CHOICE::operator+= * * Cat a second word rating on the end of this current one. * The ratings are added and the confidence is the min. * If the permuters are NOT the same the permuter is set to COMPOUND_PERM - **********************************************************************/ + */ WERD_CHOICE & WERD_CHOICE::operator+= (const WERD_CHOICE & second) { // TODO(daria): find out why the choice was cleared this way if any // of the pieces are empty. Add the description of this behavior @@ -276,12 +276,12 @@ WERD_CHOICE & WERD_CHOICE::operator+= (const WERD_CHOICE & second) { } -/********************************************************************** +/** * WERD_CHOICE::operator= * * Allocate enough memory to hold a copy of source and copy over * all the information from source to this WERD_CHOICE. - **********************************************************************/ + */ WERD_CHOICE& WERD_CHOICE::operator=(const WERD_CHOICE& source) { while (reserved_ < source.length()) { this->double_the_size(); @@ -341,11 +341,11 @@ void WERD_CHOICE::delete_blob_choices() { } } -/********************************************************************** +/** * WERD_CHOICE::print * * Print WERD_CHOICE to stdout. - **********************************************************************/ + */ const void WERD_CHOICE::print(const char *msg) const { tprintf("%s WERD_CHOICE:\n", msg); tprintf("length_ %d reserved_ %d permuter_ %d\n", @@ -372,17 +372,19 @@ const void WERD_CHOICE::print(const char *msg) const { fflush(stdout); } -/********************************************************************** +/** * print_ratings_list * * Send all the ratings out to the logfile. - **********************************************************************/ -void print_ratings_list( - const char *msg, // intro message - BLOB_CHOICE_LIST *ratings, // list of results - const UNICHARSET ¤t_unicharset // unicharset that can be used - // for id-to-unichar conversion - ) { + * + * @param msg intro message + * @param ratings list of ratings + * @param current_unicharset unicharset that can be used + * for id-to-unichar conversion + */ +void print_ratings_list(const char *msg, + BLOB_CHOICE_LIST *ratings, + const UNICHARSET ¤t_unicharset) { if (ratings->length() == 0) { tprintf("%s:\n", msg); return; @@ -405,11 +407,11 @@ void print_ratings_list( fflush(stdout); } -/********************************************************************** +/** * print_ratings_list * * Print ratings list (unichar ids only). - **********************************************************************/ + */ void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings) { if (ratings->length() == 0) { tprintf("%s:\n", msg); @@ -431,17 +433,19 @@ void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings) { fflush(stdout); } -/********************************************************************** +/** * print_ratings_info * * Send all the ratings out to the logfile. - **********************************************************************/ -void print_ratings_info( - FILE *fp, // file to use - BLOB_CHOICE_LIST *ratings, // list of results - const UNICHARSET ¤t_unicharset // unicharset that can be used - // for id-to-unichar conversion - ) { + * + * @param fp file to use + * @param ratings list of results + * @param current_unicharset unicharset that can be used + * for id-to-unichar conversion + */ +void print_ratings_info(FILE *fp, + BLOB_CHOICE_LIST *ratings, + const UNICHARSET ¤t_unicharset) { inT32 index; // to list inT32 best_index; // to list FLOAT32 best_rat; // rating @@ -498,9 +502,9 @@ void print_ratings_info( sec_rat, sec_cert); } -/********************************************************************** +/** * print_char_choices_list - **********************************************************************/ + */ void print_char_choices_list(const char *msg, const BLOB_CHOICE_LIST_VECTOR &char_choices, const UNICHARSET ¤t_unicharset, diff --git a/ccstruct/ratngs.h b/ccstruct/ratngs.h index 9efc786ef5..d5e58c0e15 100644 --- a/ccstruct/ratngs.h +++ b/ccstruct/ratngs.h @@ -182,7 +182,7 @@ class WERD_CHOICE { } void set_blob_choices(BLOB_CHOICE_LIST_CLIST *blob_choices); - // Make more space in unichar_id_ and fragment_lengths_ arrays. + /// Make more space in unichar_id_ and fragment_lengths_ arrays. inline void double_the_size() { unichar_ids_ = GenericVector::double_the_size_memcpy( reserved_, unichar_ids_); @@ -191,8 +191,8 @@ class WERD_CHOICE { reserved_ *= 2; } - // Initializes WERD_CHOICE - reseves length slots in unichar_ids_ and - // fragment_length_ arrays. Sets other values to default (blank) values. + /// Initializes WERD_CHOICE - reseves length slots in unichar_ids_ and + /// fragment_length_ arrays. Sets other values to default (blank) values. inline void init(int reserved) { reserved_ = reserved; unichar_ids_ = new UNICHAR_ID[reserved]; @@ -207,16 +207,16 @@ class WERD_CHOICE { unichar_lengths_ = ""; } - // Helper function to build a WERD_CHOICE from the given string, - // fragment lengths, rating, certainty and permuter. - // The function assumes that src_string is not NULL. - // src_lengths argument could be NULL, in which case the unichars - // in src_string are assumed to all be of length 1. + /// Helper function to build a WERD_CHOICE from the given string, + /// fragment lengths, rating, certainty and permuter. + /// The function assumes that src_string is not NULL. + /// src_lengths argument could be NULL, in which case the unichars + /// in src_string are assumed to all be of length 1. void init(const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uinT8 src_permuter, const UNICHARSET ¤t_unicharset); - // Set the fields in this choice to be default (bad) values. + /// Set the fields in this choice to be default (bad) values. inline void make_bad() { length_ = 0; rating_ = MAX_FLOAT32; @@ -226,9 +226,9 @@ class WERD_CHOICE { unichar_lengths_ = ""; } - // This function assumes that there is enough space reserved - // in the WERD_CHOICE for adding another unichar. - // This is an efficient alternative to append_unichar_id(). + /// This function assumes that there is enough space reserved + /// in the WERD_CHOICE for adding another unichar. + /// This is an efficient alternative to append_unichar_id(). inline void append_unichar_id_space_allocated( UNICHAR_ID unichar_id, char fragment_length, float rating, float certainty) { @@ -266,22 +266,22 @@ class WERD_CHOICE { } return word_str; } - // Since this function walks over the whole word to convert unichar ids - // to unichars, it is best to call it once, e.g. after all changes to - // unichar_ids_ in WERD_CHOICE are finished. + /// Since this function walks over the whole word to convert unichar ids + /// to unichars, it is best to call it once, e.g. after all changes to + /// unichar_ids_ in WERD_CHOICE are finished. void populate_unichars(const UNICHARSET ¤t_unicharset) { this->string_and_lengths(current_unicharset, &unichar_string_, &unichar_lengths_); } - // This function should only be called if populate_unichars() - // was called and WERD_CHOICE did not change since then. + /// This function should only be called if populate_unichars() + /// was called and WERD_CHOICE did not change since then. const STRING &unichar_string() const { assert(unichar_string_.length() <= 0 || unichar_string_.length() >= length_); // sanity check return unichar_string_; } - // This function should only be called if populate_unichars() - // was called and WERD_CHOICE did not change since then. + /// This function should only be called if populate_unichars() + /// was called and WERD_CHOICE did not change since then. const STRING &unichar_lengths() const { assert(unichar_lengths_.length() <= 0 || unichar_lengths_.length() == length_); // sanity check diff --git a/ccstruct/werd.cpp b/ccstruct/werd.cpp index b46a911304..32d7837d9a 100644 --- a/ccstruct/werd.cpp +++ b/ccstruct/werd.cpp @@ -27,10 +27,11 @@ #include "linlsq.h" #include "werd.h" -#define FIRST_COLOUR ScrollView::RED //first rainbow colour - //last rainbow colour +#define FIRST_COLOUR ScrollView::RED //< first rainbow colour + +/// last rainbow colour #define LAST_COLOUR ScrollView::AQUAMARINE -#define CHILD_COLOUR ScrollView::BROWN //colour of children +#define CHILD_COLOUR ScrollView::BROWN //< colour of children const ERRCODE CANT_SCALE_EDGESTEPS = "Attempted to scale an edgestep format word"; @@ -46,16 +47,16 @@ EXTERN double_VAR (bln_blshift_xfraction, 0.75, "Size fraction of xh before shifting"); ELISTIZE_S (WERD) -/********************************************************************** +/** * WERD::WERD * * Constructor to build a WERD from a list of C_BLOBs. * The C_BLOBs are not copied so the source list is emptied. - **********************************************************************/ + */ WERD::WERD ( //constructor -C_BLOB_LIST * blob_list, //in word order -uinT8 blank_count, //blanks in front -const char *text //correct text +C_BLOB_LIST * blob_list, //< in word order +uinT8 blank_count, //< blanks in front +const char *text //< correct text ): flags (0), correct(text) { @@ -125,17 +126,17 @@ correct(text) { } -/********************************************************************** +/** * WERD::WERD * * Constructor to build a WERD from a list of BLOBs. * The BLOBs are not copied so the source list is emptied. - **********************************************************************/ + */ WERD::WERD ( //constructor -PBLOB_LIST * blob_list, //in word order -uinT8 blank_count, //blanks in front -const char *text //correct text +PBLOB_LIST * blob_list, //< in word order +uinT8 blank_count, //< blanks in front +const char *text //< correct text ): flags (0), correct(text) { @@ -153,16 +154,16 @@ correct(text) { } -/********************************************************************** +/** * WERD::WERD * * Constructor to build a WERD from a list of BLOBs. * The BLOBs are not copied so the source list is emptied. - **********************************************************************/ + */ WERD::WERD ( //constructor -PBLOB_LIST * blob_list, //in word order -WERD * clone //sorce of flags +PBLOB_LIST * blob_list, //< in word order +WERD * clone //< sorce of flags ):flags (clone->flags), correct (clone->correct) { PBLOB_IT start_it = blob_list; //iterator PBLOB_IT end_it = blob_list; //another @@ -176,16 +177,16 @@ WERD * clone //sorce of flags } -/********************************************************************** +/** * WERD::WERD * * Constructor to build a WERD from a list of C_BLOBs. * The C_BLOBs are not copied so the source list is emptied. - **********************************************************************/ + */ WERD::WERD ( //constructor -C_BLOB_LIST * blob_list, //in word order -WERD * clone //sorce of flags +C_BLOB_LIST * blob_list, //< in word order +WERD * clone //< source of flags ):flags (clone->flags), correct (clone->correct) { C_BLOB_IT start_it = blob_list;//iterator C_BLOB_IT end_it = blob_list; //another @@ -199,15 +200,15 @@ WERD * clone //sorce of flags } -/********************************************************************** +/** * WERD::poly_copy * * Make a copy of a WERD in polygon format. * The source WERD is untouched. - **********************************************************************/ + */ WERD *WERD::poly_copy( //make a poly copy - float xheight //row height + float xheight //< row height ) { PBLOB *blob; //new blob WERD *result = new WERD; //output word @@ -269,7 +270,7 @@ WERD *WERD::poly_copy( //make a poly copy } -/********************************************************************** +/** * WERD::bounding_box * * Return the bounding box of the WERD. @@ -280,7 +281,7 @@ WERD *WERD::poly_copy( //make a poly copy * blobs in a word are rejected the BB for the word is NULL, causing the sort * to screw up, leading to the erroneous possibility of the first word in a * row being marked as FUZZY space. - **********************************************************************/ + */ TBOX WERD::bounding_box() { //bounding box TBOX box; //box being built @@ -311,15 +312,15 @@ TBOX WERD::bounding_box() { //bounding box } -/********************************************************************** +/** * WERD::move * * Reposition WERD by vector * NOTE!! REJECT CBLOBS ARE NOT MOVED - **********************************************************************/ + */ void WERD::move( // reposition WERD - const ICOORD vec // by vector + const ICOORD vec //< by vector ) { PBLOB_IT blob_it ((PBLOB_LIST *) & cblobs); // blob iterator @@ -342,14 +343,14 @@ void WERD::move( // reposition WERD } -/********************************************************************** +/** * WERD::scale * * Scale WERD by multiplier - **********************************************************************/ + */ void WERD::scale( // scale WERD - const float f // by multiplier + const float f //< by multiplier ) { PBLOB_IT blob_it ((PBLOB_LIST *) & cblobs); // blob iterator @@ -369,14 +370,14 @@ void WERD::scale( // scale WERD } -/********************************************************************** +/** * WERD::join_on * * Join other word onto this one. Delete the old word. - **********************************************************************/ + */ void WERD::join_on( // join WERD - WERD *&other //other word + WERD *&other //< other word ) { PBLOB_IT blob_it ((PBLOB_LIST *) & cblobs); // blob iterator @@ -395,14 +396,14 @@ void WERD::join_on( // join WERD } -/********************************************************************** +/** * WERD::copy_on * * Copy blobs from other word onto this one. - **********************************************************************/ + */ void WERD::copy_on( //copy blobs - WERD *&other //from other + WERD *&other //< from other ) { if (flags.bit (W_POLYGON)) { PBLOB_IT blob_it ((PBLOB_LIST *) & cblobs); @@ -432,25 +433,25 @@ void WERD::copy_on( //copy blobs } -/********************************************************************** +/** * WERD::baseline_normalise * * Baseline Normalise the word in Tesseract style. (I.e origin at centre of * word at bottom. x-height region scaled to region y = * (bln_baseline_offset)..(bln_baseline_offset + bln_x_height) * - usually 64..192) - **********************************************************************/ + */ void WERD::baseline_normalise( // Tess style BL Norm ROW *row, - DENORM *denorm //antidote + DENORM *denorm //< antidote ) { baseline_normalise_x (row, row->x_height (), denorm); //Use standard x ht } -/********************************************************************** +/** * WERD::baseline_normalise_x * * Baseline Normalise the word in Tesseract style. (I.e origin at centre of @@ -458,12 +459,12 @@ void WERD::baseline_normalise( // Tess style BL Norm * (bln_baseline_offset)..(bln_baseline_offset + bln_x_height) * - usually 64..192) * USE A SPECIFIED X-HEIGHT - NOT NECESSARILY THE ONE IN row - **********************************************************************/ + */ void WERD::baseline_normalise_x( // Tess style BL Norm ROW *row, - float x_height, //non standard value - DENORM *denorm //antidote + float x_height, //< non standard value + DENORM *denorm //< antidote ) { BOOL8 using_row; //as baseline float blob_x_centre; //middle of blob @@ -703,17 +704,17 @@ void WERD::baseline_normalise_x( // Tess style BL Norm } -/********************************************************************** +/** * WERD::baseline_denormalise * * Baseline DeNormalise the word in Tesseract style. (I.e origin at centre of * word at bottom. x-height region scaled to region y = * (bln_baseline_offset)..(bln_baseline_offset + bln_x_height) * - usually 64..192) - **********************************************************************/ + */ void WERD::baseline_denormalise( // Tess style BL Norm - const DENORM *denorm //antidote + const DENORM *denorm //< antidote ) { PBLOB_IT blob_it ((PBLOB_LIST *) & cblobs); // blob iterator @@ -743,14 +744,14 @@ void WERD::baseline_denormalise( // Tess style BL Norm } -/********************************************************************** +/** * WERD::print * * Display members - **********************************************************************/ + */ void WERD::print( //print - FILE * //file to print on + FILE * //< file to print on ) { tprintf ("Blanks= %d\n", blanks); bounding_box ().print (); @@ -777,11 +778,11 @@ void WERD::print( //print } -/********************************************************************** +/** * WERD::plot * * Draw the WERD in the given colour. - **********************************************************************/ + */ #ifndef GRAPHICS_DISABLED void WERD::plot( //draw it @@ -818,16 +819,16 @@ void WERD::plot( //draw it #endif -/********************************************************************** +/** * WERD::plot * * Draw the WERD in rainbow colours. - **********************************************************************/ + */ #ifndef GRAPHICS_DISABLED void WERD::plot( //draw it - ScrollView* window, //window to draw in - BOOL8 solid //draw larcs solid + ScrollView* window, //< window to draw in + BOOL8 solid //< draw larcs solid ) { ScrollView::Color colour = FIRST_COLOUR; //current colour if (flags.bit (W_POLYGON)) { @@ -868,16 +869,16 @@ void WERD::plot( //draw it #endif -/********************************************************************** +/** * WERD::plot_rej_blobs * * Draw the WERD rejected blobs - ALWAYS GREY - **********************************************************************/ + */ #ifndef GRAPHICS_DISABLED void WERD::plot_rej_blobs( //draw it - ScrollView* window, //window to draw in - BOOL8 solid //draw larcs solid + ScrollView* window, //< window to draw in + BOOL8 solid //< draw larcs solid ) { if (flags.bit (W_POLYGON)) { PBLOB_IT it = (PBLOB_LIST *) (&rej_cblobs); @@ -897,11 +898,11 @@ void WERD::plot_rej_blobs( //draw it #endif -/********************************************************************** +/** * WERD::shallow_copy() * * Make a shallow copy of a word - **********************************************************************/ + */ WERD *WERD::shallow_copy() { //shallow copy WERD *new_word = new WERD; @@ -914,11 +915,11 @@ WERD *WERD::shallow_copy() { //shallow copy } -/********************************************************************** +/** * WERD::operator= * * Assign a word, DEEP copying the blob list - **********************************************************************/ + */ WERD & WERD::operator= ( //assign words const WERD & source //from this @@ -952,16 +953,16 @@ const WERD & source //from this } -/********************************************************************** +/** * word_comparator() * * word comparator used to sort a word list so that words are in increasing * order of left edge. - **********************************************************************/ + */ int word_comparator( //sort blobs - const void *word1p, //ptr to ptr to word1 - const void *word2p //ptr to ptr to word2 + const void *word1p, //< ptr to ptr to word1 + const void *word2p //< ptr to ptr to word2 ) { WERD * word1 = *(WERD **) word1p; diff --git a/ccstruct/werd.h b/ccstruct/werd.h index 04f33105ef..eff12267a8 100644 --- a/ccstruct/werd.h +++ b/ccstruct/werd.h @@ -30,29 +30,29 @@ enum WERD_FLAGS { - W_SEGMENTED, //correctly segmented - W_ITALIC, //italic text - W_BOLD, //bold text - W_BOL, //start of line - W_EOL, //end of line - W_NORMALIZED, //flags - W_POLYGON, //approximation - W_LINEARC, //linearc approx - W_DONT_CHOP, //fixed pitch chopped - W_REP_CHAR, //repeated character - W_FUZZY_SP, //fuzzy space - W_FUZZY_NON, //fuzzy nonspace - W_INVERSE //white on black + W_SEGMENTED, //< correctly segmented + W_ITALIC, //< italic text + W_BOLD, //< bold text + W_BOL, //< start of line + W_EOL, //< end of line + W_NORMALIZED, //< flags + W_POLYGON, //< approximation + W_LINEARC, //< linearc approx + W_DONT_CHOP, //< fixed pitch chopped + W_REP_CHAR, //< repeated character + W_FUZZY_SP, //< fuzzy space + W_FUZZY_NON, //< fuzzy nonspace + W_INVERSE //< white on black }; enum DISPLAY_FLAGS { /* Display flags bit number allocations */ - DF_BOX, //Bounding box - DF_TEXT, //Correct ascii - DF_POLYGONAL, //Polyg approx - DF_EDGE_STEP, //Edge steps - DF_BN_POLYGONAL //BL normalisd polyapx + DF_BOX, //< Bounding box + DF_TEXT, //< Correct ascii + DF_POLYGONAL, //< Polyg approx + DF_EDGE_STEP, //< Edge steps + DF_BN_POLYGONAL //< BL normalisd polyapx }; class ROW; //forward decl diff --git a/ccutil/tessdatamanager.h b/ccutil/tessdatamanager.h index 93ae43c245..51ed60d84d 100644 --- a/ccutil/tessdatamanager.h +++ b/ccutil/tessdatamanager.h @@ -67,8 +67,10 @@ enum TessdataType { TESSDATA_NUM_ENTRIES }; -// kTessdataFileSuffixes[i] indicates the file suffix for -// tessdata of type i (from TessdataType enum). +/** + * kTessdataFileSuffixes[i] indicates the file suffix for + * tessdata of type i (from TessdataType enum). + */ static const char * const kTessdataFileSuffixes[] = { kLangConfigFileSuffix, // 0 kUnicharsetFileSuffix, // 1 @@ -82,8 +84,10 @@ static const char * const kTessdataFileSuffixes[] = { kFreqDawgFileSuffix, // 9 }; -// If kTessdataFileIsText[i] is true - the tessdata component -// of type i (from TessdataType enum) is text, and is binary otherwise. +/** + * If kTessdataFileIsText[i] is true - the tessdata component + * of type i (from TessdataType enum) is text, and is binary otherwise. + */ static const bool kTessdataFileIsText[] = { true, // 0 true, // 1 @@ -97,11 +101,13 @@ static const bool kTessdataFileIsText[] = { false, // 9 }; -// TessdataType could be updated to contain more entries, however -// we do not expect that number to be astronomically high. -// In order to automatically detect endianness TessdataManager will -// flip the bits if actual_tessdata_num_entries_ is larger than -// kMaxNumTessdataEntries. +/** + * TessdataType could be updated to contain more entries, however + * we do not expect that number to be astronomically high. + * In order to automatically detect endianness TessdataManager will + * flip the bits if actual_tessdata_num_entries_ is larger than + * kMaxNumTessdataEntries. + */ static const int kMaxNumTessdataEntries = 1000; @@ -116,15 +122,17 @@ class TessdataManager { } ~TessdataManager() {} - // Opens the given data file and reads the offset table. + /** Opens the given data file and reads the offset table. */ void Init(const char *data_file_name); - // Returns data file pointer. + /** Returns data file pointer. */ inline FILE *GetDataFilePtr() const { return data_file_; } - // Returns false if there is no data of the given type. - // Otherwise does a seek on the data_file_ to position the pointer - // at the start of the data of the given type. + /** + * Returns false if there is no data of the given type. + * Otherwise does a seek on the data_file_ to position the pointer + * at the start of the data of the given type. + */ inline bool SeekToStart(TessdataType tessdata_type) { if (global_tessdata_manager_debug_level) { tprintf("TessdataManager: seek to offset %lld (start of tessdata" @@ -139,7 +147,7 @@ class TessdataManager { return true; } } - // Returns the end offset for the given tesseract data file type. + /** Returns the end offset for the given tesseract data file type. */ inline inT64 GetEndOffset(TessdataType tessdata_type) const { int index = tessdata_type + 1; while (index < actual_tessdata_num_entries_ && offset_table_[index] == -1) { @@ -153,7 +161,7 @@ class TessdataManager { } return (index == actual_tessdata_num_entries_) ? -1 : offset_table_[index] - 1; } - // Closes data_file_ (if it was opened by Init()). + /** Closes data_file_ (if it was opened by Init()). */ inline void End() { if (data_file_ != NULL) { fclose(data_file_); @@ -161,66 +169,82 @@ class TessdataManager { } } - // Writes the number of entries and the given offset table to output_file. + /** Writes the number of entries and the given offset table to output_file. */ static void WriteMetadata(inT64 *offset_table, FILE *output_file); - // Reads all the standard tesseract config and data files for a language - // at the given path and bundles them up into one binary data file. - // Returns true if the combined traineddata file was successfully written. + /** + * Reads all the standard tesseract config and data files for a language + * at the given path and bundles them up into one binary data file. + * Returns true if the combined traineddata file was successfully written. + */ static bool CombineDataFiles(const char *language_data_path_prefix, const char *output_filename); - // Gets the individual components from the data_file_ with which the class was - // initialized. Overwrites the components specified by component_filenames. - // Writes the updated traineddata file to new_traineddata_filename. + /** + * Gets the individual components from the data_file_ with which the class was + * initialized. Overwrites the components specified by component_filenames. + * Writes the updated traineddata file to new_traineddata_filename. + */ bool OverwriteComponents(const char *new_traineddata_filename, char **component_filenames, int num_new_components); - // Extracts tessdata component implied by the name of the input file from - // the combined traineddata loaded into TessdataManager. - // Writes the extracted component to the file indicated by the file name. - // E.g. if the filename given is somepath/somelang.unicharset, unicharset - // will be extracted from the data loaded into the TessdataManager and will - // be written to somepath/somelang.unicharset. - // Returns true if the component was successfully extracted, false if the - // component was not present in the traineddata loaded into TessdataManager. + /** + * Extracts tessdata component implied by the name of the input file from + * the combined traineddata loaded into TessdataManager. + * Writes the extracted component to the file indicated by the file name. + * E.g. if the filename given is somepath/somelang.unicharset, unicharset + * will be extracted from the data loaded into the TessdataManager and will + * be written to somepath/somelang.unicharset. + * @return true if the component was successfully extracted, false if the + * component was not present in the traineddata loaded into TessdataManager. + */ bool ExtractToFile(const char *filename); - // Copies data from the given input file to the output_file provided. - // If num_bytes_to_copy is >= 0, only num_bytes_to_copy is copied from - // the input file, otherwise all the data in the input file is copied. + /** + * Copies data from the given input file to the output_file provided. + * If num_bytes_to_copy is >= 0, only num_bytes_to_copy is copied from + * the input file, otherwise all the data in the input file is copied. + */ static void CopyFile(FILE *input_file, FILE *output_file, bool newline_end, inT64 num_bytes_to_copy); - // Fills type with TessdataType of the tessdata component represented by the - // given file name. E.g. tessdata/eng.unicharset -> TESSDATA_UNICHARSET. - // Sets *text_file to true if the component is in text format (e.g. - // unicharset, unichar ambigs, config, etc). - // Returns true if the tessdata component type could be determined - // from the given file name. + /** + * Fills type with TessdataType of the tessdata component represented by the + * given file name. E.g. tessdata/eng.unicharset -> TESSDATA_UNICHARSET. + * Sets *text_file to true if the component is in text format (e.g. + * unicharset, unichar ambigs, config, etc). + * @return true if the tessdata component type could be determined + * from the given file name. + */ static bool TessdataTypeFromFileSuffix(const char *suffix, TessdataType *type, bool *text_file); - // Tries to determine tessdata component file suffix from filename, - // returns true on success. + /** + * Tries to determine tessdata component file suffix from filename, + * returns true on success. + */ static bool TessdataTypeFromFileName(const char *filename, TessdataType *type, bool *text_file); private: - // Each offset_table_[i] contains a file offset in the combined data file - // where the data of TessdataFileType i is stored. + /** + * Each offset_table_[i] contains a file offset in the combined data file + * where the data of TessdataFileType i is stored. + */ inT64 offset_table_[TESSDATA_NUM_ENTRIES]; - // Actual number of entries in the tessdata table. This value can only be - // same or smaller than TESSDATA_NUM_ENTRIES, but can never be larger, - // since then it would be impossible to interpret the type of tessdata at - // indices same and higher than TESSDATA_NUM_ENTRIES. - // This parameter is used to allow for backward compatiblity - // when new tessdata types are introduced. + /** + * Actual number of entries in the tessdata table. This value can only be + * same or smaller than TESSDATA_NUM_ENTRIES, but can never be larger, + * since then it would be impossible to interpret the type of tessdata at + * indices same and higher than TESSDATA_NUM_ENTRIES. + * This parameter is used to allow for backward compatiblity + * when new tessdata types are introduced. + */ inT32 actual_tessdata_num_entries_; - FILE *data_file_; // pointer to the data file. + FILE *data_file_; ///< pointer to the data file. }; diff --git a/ccutil/unicity_table.h b/ccutil/unicity_table.h index 6923a90ee2..9bfe8e5d8d 100644 --- a/ccutil/unicity_table.h +++ b/ccutil/unicity_table.h @@ -33,57 +33,57 @@ template class UnicityTable { public: UnicityTable(); - // Clear the structures and deallocate internal structures. + /// Clear the structures and deallocate internal structures. ~UnicityTable(); - // Reserve some memory. If there is size or more elements, the table will - // then allocate size * 2 elements. + /// Reserve some memory. If there is size or more elements, the table will + /// then allocate size * 2 elements. void reserve(int size); - // Return the size used. + /// Return the size used. int size() const; - // Return the object from an id. + /// Return the object from an id. T get(int id) const; - // Return the id of the T object. - // This method NEEDS a compare_callback to be passed to - // set_compare_callback. + /// Return the id of the T object. + /// This method NEEDS a compare_callback to be passed to + /// set_compare_callback. int get_id(T object) const; - // Return true if T is in the table + /// Return true if T is in the table bool contains(T object) const; - // Return true if the id is valid + /// Return true if the id is valid T contains_id(int id) const; - // Add an element in the table + /// Add an element in the table int push_back(T object); - // Add a callback to be called to delete the elements when the table took - // their ownership. + /// Add a callback to be called to delete the elements when the table took + /// their ownership. void set_clear_callback(Callback1* cb); - // Add a callback to be called to compare the elements when needed (contains, - // get_id, ...) + /// Add a callback to be called to compare the elements when needed (contains, + /// get_id, ...) void set_compare_callback(ResultCallback2* cb); - // Clear the table, calling the callback function if any. - // All the owned Callbacks are also deleted. - // If you don't want the Callbacks to be deleted, before calling clear, set - // the callback to NULL. + /// Clear the table, calling the callback function if any. + /// All the owned Callbacks are also deleted. + /// If you don't want the Callbacks to be deleted, before calling clear, set + /// the callback to NULL. void clear(); - // This method clear the current object, then, does a shallow copy of - // its argument, and finally invalidate its argument. + /// This method clear the current object, then, does a shallow copy of + /// its argument, and finally invalidate its argument. void move(UnicityTable* from); - // Read/Write the table to a file. This does _NOT_ read/write the callbacks. - // The Callback given must be permanent since they will be called more than - // once. The given callback will be deleted at the end. - // Returns false on read/write error. + /// Read/Write the table to a file. This does _NOT_ read/write the callbacks. + /// The Callback given must be permanent since they will be called more than + /// once. The given callback will be deleted at the end. + /// Returns false on read/write error. bool write(FILE* f, ResultCallback2* cb); - // swap is used to switch the endianness. + /// swap is used to switch the endianness. bool read(FILE* f, ResultCallback3* cb, bool swap); private: diff --git a/classify/adaptmatch.cpp b/classify/adaptmatch.cpp index e729639e94..d0441a2302 100644 --- a/classify/adaptmatch.cpp +++ b/classify/adaptmatch.cpp @@ -1,8 +1,8 @@ /****************************************************************************** - ** Filename: adaptmatch.c - ** Purpose: High level adaptive matcher. - ** Author: Dan Johnson - ** History: Mon Mar 11 10:00:10 1991, DSJ, Created. + ** Filename: adaptmatch.c + ** Purpose: High level adaptive matcher. + ** Author: Dan Johnson + ** History: Mon Mar 11 10:00:10 1991, DSJ, Created. ** ** (c) Copyright Hewlett-Packard Company, 1988. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,9 +16,9 @@ ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ // Include automatically generated configuration file if running autoconf. #ifdef HAVE_CONFIG_H #include "config_auto.h" @@ -84,8 +84,8 @@ struct ADAPT_RESULTS uinT8 BestConfig; CLASS_PRUNER_RESULTS CPResults; - // Initializes data members to the default values. Sets the initial - // rating of each class to be the worst possible rating (1.0). + /// Initializes data members to the default values. Sets the initial + /// rating of each class to be the worst possible rating (1.0). inline void Initialize() { BlobLength = MAX_INT32; NumMatches = 0; @@ -111,9 +111,9 @@ typedef struct PROTO_KEY; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Macros -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #define MarginalMatch(Rating) \ ((Rating) > matcher_great_threshold) @@ -122,9 +122,9 @@ PROTO_KEY; #define InitIntFX() (FeaturesHaveBeenExtracted = FALSE) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ void AdaptToChar(TBLOB *Blob, LINE_STATS *LineStats, CLASS_ID ClassId, @@ -230,9 +230,9 @@ void ShowBestMatchFor(TBLOB *Blob, BOOL8 PreTrainedOn); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /* variables used to hold performance statistics */ static int AdaptiveMatcherCalls = 0; static int BaselineClassifierCalls = 0; @@ -256,11 +256,11 @@ static INT_FEATURE_ARRAY BaselineFeatures; static INT_FEATURE_ARRAY CharNormFeatures; static INT_FX_RESULT_STRUCT FXInfo; -/* use a global variable to hold onto the current ratings so that the +/** use a global variable to hold onto the current ratings so that the comparison function passes to qsort can get at them */ static FLOAT32 *CurrentRatings; -/* define globals to hold filenames of training data */ +/* define globals to hold filename of training data */ static CLASS_CUTOFF_ARRAY CharNormCutoffs; static CLASS_CUTOFF_ARRAY BaselineCutoffs; @@ -311,40 +311,47 @@ double_VAR(tessedit_class_miss_scale, 0.00390625, BOOL_VAR(tess_cn_matching, 0, "Character Normalized Matching"); BOOL_VAR(tess_bn_matching, 0, "Baseline Normalized Matching"); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ namespace tesseract { +/** + * This routine calls the adaptive matcher + * which returns (in an array) the class id of each + * class matched. + * + * It also returns the number of classes matched. + * For each class matched it places the best rating + * found for that class into the Ratings array. + * + * Bad matches are then removed so that they don't + * need to be sorted. The remaining good matches are + * then sorted and converted to choices. + * + * This routine also performs some simple speckle + * filtering. + * + * @note Exceptions: none + * @note History: Mon Mar 11 10:00:58 1991, DSJ, Created. + * + * @param Blob blob to be classified + * @param DotBlob (obsolete) + * @param Row row of text that word appears in + * @param[out] Choices List of choices found by adaptive matcher. + * @param[out] CPResults Array of CPResultStruct of size MAX_NUM_CLASSES is + * filled on return with the choices found by the + * class pruner and the ratings therefrom. Also + * contains the detailed results of the integer matcher. + * + * Globals: + * - CurrentRatings used by compare function for qsort + */ void Classify::AdaptiveClassifier(TBLOB *Blob, TBLOB *DotBlob, TEXTROW *Row, BLOB_CHOICE_LIST *Choices, CLASS_PRUNER_RESULTS CPResults) { -/* - ** Parameters: Blob blob to be classified - ** DotBlob (obsolete) - ** Row row of text that word appears in - ** Globals: CurrentRatings used by compare function for qsort - ** Operation: This routine calls the adaptive matcher - ** which returns (in an array) the class id of each - ** class matched. - ** It also returns the number of classes matched. - ** For each class matched it places the best rating - ** found for that class into the Ratings array. - ** Bad matches are then removed so that they don't - ** need to be sorted. The remaining good matches are - ** then sorted and converted to choices. - ** This routine also performs some simple speckle - ** filtering. - ** Return: Choices List of choices found by adaptive matcher. - ** CPResults Array of CPResultStruct of size MAX_NUM_CLASSES is - ** filled on return with the choices found by the - ** class pruner and the ratings therefrom. Also - ** contains the detailed results of the integer matcher. - ** Exceptions: none - ** History: Mon Mar 11 10:00:58 1991, DSJ, Created. - */ assert(Choices != NULL); ADAPT_RESULTS *Results = new ADAPT_RESULTS(); LINE_STATS LineStats; @@ -404,36 +411,35 @@ void Classify::AdaptiveClassifier(TBLOB *Blob, /*---------------------------------------------------------------------------*/ +/** + * This routine implements a preliminary + * version of the rules which are used to decide + * which characters to adapt to. + * + * A word is adapted to if it is in the dictionary or + * if it is a "good" number (no trailing units, etc.). + * It cannot contain broken or merged characters. + * + * Within that word, only letters and digits are + * adapted to (no punctuation). + * + * @param Word word to be adapted to + * @param Row row of text that word is found in + * @param BestChoice best choice for word found by system + * @param BestRawChoice best choice for word found by classifier only + * @param rejmap Reject map + * + * Globals: + * - #EnableLearning TRUE if learning is enabled + * + * @note Exceptions: none + * @note History: Thu Mar 14 07:40:36 1991, DSJ, Created. +*/ void Classify::AdaptToWord(TWERD *Word, TEXTROW *Row, const WERD_CHOICE& BestChoice, const WERD_CHOICE& BestRawChoice, const char *rejmap) { -/* - ** Parameters: - ** Word - ** word to be adapted to - ** Row - ** row of text that word is found in - ** BestChoice - ** best choice for word found by system - ** BestRawChoice - ** best choice for word found by classifier only - ** Globals: - ** EnableLearning - ** TRUE if learning is enabled - ** Operation: This routine implements a preliminary - ** version of the rules which are used to decide - ** which characters to adapt to. - ** A word is adapted to if it is in the dictionary or - ** if it is a "good" number (no trailing units, etc.). - ** It cannot contain broken or merged characters. - ** Within that word, only letters and digits are - ** adapted to (no punctuation). - ** Return: none - ** Exceptions: none - ** History: Thu Mar 14 07:40:36 1991, DSJ, Created. -*/ TBLOB *Blob; LINE_STATS LineStats; FLOAT32 Thresholds[MAX_ADAPTABLE_WERD_SIZE]; @@ -533,24 +539,21 @@ void Classify::AdaptToWord(TWERD *Word, /*---------------------------------------------------------------------------*/ +/** + * This routine performs cleanup operations + * on the adaptive classifier. It should be called + * before the program is terminated. Its main function + * is to save the adapted templates to a file. + * + * Globals: + * - #AdaptedTemplates current set of adapted templates + * - #classify_save_adapted_templates TRUE if templates should be saved + * - #classify_enable_adaptive_matcher TRUE if adaptive matcher is enabled + * + * @note Exceptions: none + * @note History: Tue Mar 19 14:37:06 1991, DSJ, Created. + */ void Classify::EndAdaptiveClassifier() { -/* - ** Parameters: none - ** Globals: - ** AdaptedTemplates - ** current set of adapted templates - ** classify_save_adapted_templates - ** TRUE if templates should be saved - ** classify_enable_adaptive_matcher - ** TRUE if adaptive matcher is enabled - ** Operation: This routine performs cleanup operations - ** on the adaptive classifier. It should be called - ** before the program is terminated. Its main function - ** is to save the adapted templates to a file. - ** Return: none - ** Exceptions: none - ** History: Tue Mar 19 14:37:06 1991, DSJ, Created. -*/ STRING Filename; FILE *File; @@ -600,33 +603,25 @@ void Classify::EndAdaptiveClassifier() { /*---------------------------------------------------------------------------*/ +/** + * This routine reads in the training + * information needed by the adaptive classifier + * and saves it into global variables. + * + * Globals: + * - BuiltInTemplatesFile file to get built-in temps from + * - BuiltInCutoffsFile file to get avg. feat per class from + * - #PreTrainedTemplates pre-trained configs and protos + * - #AdaptedTemplates templates adapted to current page + * - CharNormCutoffs avg # of features per class + * - #AllProtosOn dummy proto mask with all bits 1 + * - #AllConfigsOn dummy config mask with all bits 1 + * - #classify_use_pre_adapted_templates enables use of pre-adapted templates + * + * @note Exceptions: none + * @note History: Mon Mar 11 12:49:34 1991, DSJ, Created. + */ void Classify::InitAdaptiveClassifier() { -/* - ** Parameters: none - ** Globals: - ** BuiltInTemplatesFile - ** file to get built-in temps from - ** BuiltInCutoffsFile - ** file to get avg. feat per class from - ** PreTrainedTemplates - ** pre-trained configs and protos - ** AdaptedTemplates - ** templates adapted to current page - ** CharNormCutoffs - ** avg # of features per class - ** AllProtosOn - ** dummy proto mask with all bits 1 - ** AllConfigsOn - ** dummy config mask with all bits 1 - ** classify_use_pre_adapted_templates - ** enables use of pre-adapted templates - ** Operation: This routine reads in the training - ** information needed by the adaptive classifier - ** and saves it into global variables. - ** Return: none - ** Exceptions: none - ** History: Mon Mar 11 12:49:34 1991, DSJ, Created. -*/ if (!classify_enable_adaptive_matcher) return; if (AllProtosOn != NULL) @@ -713,18 +708,18 @@ void Classify::ResetAdaptiveClassifier() { /*---------------------------------------------------------------------------*/ namespace tesseract { +/** + * Print to File the statistics which have + * been gathered for the adaptive matcher. + * + * @param File open text file to print adaptive statistics to + * + * Globals: none + * + * @note Exceptions: none + * @note History: Thu Apr 18 14:37:37 1991, DSJ, Created. + */ void Classify::PrintAdaptiveStatistics(FILE *File) { -/* - ** Parameters: - ** File - ** open text file to print adaptive statistics to - ** Globals: none - ** Operation: Print to File the statistics which have - ** been gathered for the adaptive matcher. - ** Return: none - ** Exceptions: none - ** History: Thu Apr 18 14:37:37 1991, DSJ, Created. -*/ #ifndef SECURE_NAMES fprintf (File, "\nADAPTIVE MATCHER STATISTICS:\n"); @@ -756,20 +751,20 @@ void Classify::PrintAdaptiveStatistics(FILE *File) { /*---------------------------------------------------------------------------*/ +/** + * This routine prepares the adaptive + * matcher for the start + * of the first pass. Learning is enabled (unless it + * is disabled for the whole program). + * + * Globals: + * - #EnableLearning + * set to TRUE by this routine + * + * @note Exceptions: none + * @note History: Mon Apr 15 16:39:29 1991, DSJ, Created. + */ void Classify::SettupPass1() { -/* - ** Parameters: none - ** Globals: - ** EnableLearning - ** set to TRUE by this routine - ** Operation: This routine prepares the adaptive - ** matcher for the start - ** of the first pass. Learning is enabled (unless it - ** is disabled for the whole program). - ** Return: none - ** Exceptions: none - ** History: Mon Apr 15 16:39:29 1991, DSJ, Created. -*/ /* Note: this is somewhat redundant, it simply says that if learning is enabled then it will remain enabled on the first pass. If it is disabled, then it will remain disabled. This is only put here to @@ -783,19 +778,18 @@ void Classify::SettupPass1() { /*---------------------------------------------------------------------------*/ +/** + * This routine prepares the adaptive + * matcher for the start of the second pass. Further + * learning is disabled. + * + * Globals: + * - #EnableLearning set to FALSE by this routine + * + * @note Exceptions: none + * @note History: Mon Apr 15 16:39:29 1991, DSJ, Created. + */ void Classify::SettupPass2() { -/* - ** Parameters: none - ** Globals: - ** EnableLearning - ** set to FALSE by this routine - ** Operation: This routine prepares the adaptive - ** matcher for the start of the second pass. Further - ** learning is disabled. - ** Return: none - ** Exceptions: none - ** History: Mon Apr 15 16:39:29 1991, DSJ, Created. -*/ EnableLearning = FALSE; getDict().SettupStopperPass2(); @@ -803,37 +797,30 @@ void Classify::SettupPass2() { /*---------------------------------------------------------------------------*/ +/** + * This routine creates a new adapted + * class and uses Blob as the model for the first + * config in that class. + * + * @param Blob blob to model new class after + * @param LineStats statistics for text row blob is in + * @param ClassId id of the class to be initialized + * @param Class adapted class to be initialized + * @param Templates adapted templates to add new class to + * + * Globals: + * - #AllProtosOn dummy mask with all 1's + * - BaselineCutoffs kludge needed to get cutoffs + * - #PreTrainedTemplates kludge needed to get cutoffs + * + * @note Exceptions: none + * @note History: Thu Mar 14 12:49:39 1991, DSJ, Created. + */ void Classify::InitAdaptedClass(TBLOB *Blob, LINE_STATS *LineStats, CLASS_ID ClassId, ADAPT_CLASS Class, ADAPT_TEMPLATES Templates) { -/* - ** Parameters: - ** Blob - ** blob to model new class after - ** LineStats - ** statistics for text row blob is in - ** ClassId - ** id of the class to be initialized - ** Class - ** adapted class to be initialized - ** Templates - ** adapted templates to add new class to - ** Globals: - ** AllProtosOn - ** dummy mask with all 1's - ** BaselineCutoffs - ** kludge needed to get cutoffs - ** PreTrainedTemplates - ** kludge needed to get cutoffs - ** Operation: This routine creates a new adapted - ** class and uses Blob as the model for the first - ** config in that class. - ** Return: none - ** Exceptions: none - ** History: Thu Mar 14 12:49:39 1991, DSJ, Created. -*/ FEATURE_SET Features; int Fid, Pid; FEATURE Feature; @@ -902,33 +889,31 @@ void Classify::InitAdaptedClass(TBLOB *Blob, /*---------------------------------------------------------------------------*/ +/** + * This routine sets up the feature + * extractor to extract baseline normalized + * pico-features. + * + * The extracted pico-features are converted + * to integer form and placed in IntFeatures. The + * original floating-pt. features are returned in + * FloatFeatures. + * + * Globals: none + * @param Blob blob to extract features from + * @param LineStats statistics about text row blob is in + * @param[out] IntFeatures array to fill with integer features + * @param[out] FloatFeatures place to return actual floating-pt features + * + * @return Number of pico-features returned (0 if + * an error occurred) + * @note Exceptions: none + * @note History: Tue Mar 12 17:55:18 1991, DSJ, Created. + */ int GetAdaptiveFeatures(TBLOB *Blob, LINE_STATS *LineStats, INT_FEATURE_ARRAY IntFeatures, FEATURE_SET *FloatFeatures) { -/* - ** Parameters: - ** Blob - ** blob to extract features from - ** LineStats - ** statistics about text row blob is in - ** IntFeatures - ** array to fill with integer features - ** FloatFeatures - ** place to return actual floating-pt features - ** Globals: none - ** Operation: This routine sets up the feature - ** extractor to extract baseline normalized - ** pico-features. - ** The extracted pico-features are converted - ** to integer form and placed in IntFeatures. The - ** original floating-pt. features are returned in - ** FloatFeatures. - ** Return: Number of pico-features returned (0 if - ** an error occurred) - ** Exceptions: none - ** History: Tue Mar 12 17:55:18 1991, DSJ, Created. -*/ FEATURE_SET Features; int NumFeatures; @@ -949,29 +934,28 @@ int GetAdaptiveFeatures(TBLOB *Blob, } /* GetAdaptiveFeatures */ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ namespace tesseract { +/** + * Return TRUE if the specified word is + * acceptable for adaptation. + * + * Globals: none + * + * @param Word current word + * @param BestChoiceWord best overall choice for word with context + * @param RawChoiceWord best choice for word without context + * + * @return TRUE or FALSE + * @note Exceptions: none + * @note History: Thu May 30 14:25:06 1991, DSJ, Created. + */ int Classify::AdaptableWord(TWERD *Word, const WERD_CHOICE &BestChoiceWord, const WERD_CHOICE &RawChoiceWord) { -/* - ** Parameters: - ** Word - ** current word - ** BestChoice - ** best overall choice for word with context - ** BestRawChoice - ** best choice for word without context - ** Globals: none - ** Operation: Return TRUE if the specified word is - ** acceptable for adaptation. - ** Return: TRUE or FALSE - ** Exceptions: none - ** History: Thu May 30 14:25:06 1991, DSJ, Created. -*/ int BestChoiceLength = BestChoiceWord.length(); return ( // rules that apply in general - simplest to compute first BestChoiceLength > 0 && @@ -988,32 +972,25 @@ int Classify::AdaptableWord(TWERD *Word, } /*---------------------------------------------------------------------------*/ +/** + * @param Blob blob to add to templates for ClassId + * @param LineStats statistics about text line blob is in + * @param ClassId class to add blob to + * @param Threshold minimum match rating to existing template + * + * Globals: + * - AdaptedTemplates current set of adapted templates + * - AllProtosOn dummy mask to match against all protos + * - AllConfigsOn dummy mask to match against all configs + * + * @return none + * @note Exceptions: none + * @note History: Thu Mar 14 09:36:03 1991, DSJ, Created. + */ void Classify::AdaptToChar(TBLOB *Blob, LINE_STATS *LineStats, CLASS_ID ClassId, FLOAT32 Threshold) { -/* - ** Parameters: - ** Blob - blob to add to templates for ClassId -** LineStats - statistics about text line blob is in -** ClassId - class to add blob to -** Threshold - minimum match rating to existing template -** Globals: -** AdaptedTemplates - current set of adapted templates -** AllProtosOn - dummy mask to match against all protos -** AllConfigsOn - dummy mask to match against all configs -** Operation: -** Return: none -** Exceptions: none -** History: Thu Mar 14 09:36:03 1991, DSJ, Created. -*/ int NumFeatures; INT_FEATURE_ARRAY IntFeatures; INT_RESULT_STRUCT IntResult; @@ -1107,28 +1084,22 @@ int Classify::AdaptableWord(TWERD *Word, /*---------------------------------------------------------------------------*/ +/** + * @param Blob blob to add to templates for ClassId + * @param LineStats statistics about text line blob is in + * @param ClassId class to add blob to + * @param Threshold minimum match rating to existing template + * + * Globals: + * - PreTrainedTemplates current set of built-in templates + * + * @note Exceptions: none + * @note History: Thu Mar 14 09:36:03 1991, DSJ, Created. + */ void Classify::AdaptToPunc(TBLOB *Blob, LINE_STATS *LineStats, CLASS_ID ClassId, FLOAT32 Threshold) { -/* - ** Parameters: - ** Blob - blob to add to templates for ClassId -** LineStats - statistics about text line blob is in -** ClassId - class to add blob to -** Threshold - minimum match rating to existing template -** Globals: -** PreTrainedTemplates - current set of built-in templates -** Operation: -** Return: none -** Exceptions: none -** History: Thu Mar 14 09:36:03 1991, DSJ, Created. -*/ ADAPT_RESULTS *Results = new ADAPT_RESULTS(); int i; @@ -1159,36 +1130,32 @@ void Classify::AdaptToPunc(TBLOB *Blob, /*---------------------------------------------------------------------------*/ +/** + * This routine adds the result of a classification into + * Results. If the new rating is much worse than the current + * best rating, it is not entered into results because it + * would end up being stripped later anyway. If the new rating + * is better than the old rating for the class, it replaces the + * old rating. If this is the first rating for the class, the + * class is added to the list of matched classes in Results. + * If the new rating is better than the best so far, it + * becomes the best so far. + * + * Globals: + * - #matcher_bad_match_pad defines limits of an acceptable match + * + * @param[out] Results results to add new result to + * @param ClassId class of new result + * @param Rating rating of new result + * @param ConfigId config id of new result + * + * @note Exceptions: none + * @note History: Tue Mar 12 18:19:29 1991, DSJ, Created. + */ void Classify::AddNewResult(ADAPT_RESULTS *Results, CLASS_ID ClassId, FLOAT32 Rating, int ConfigId) { -/* - ** Parameters: - ** Results - results to add new result to -** ClassId - class of new result -** Rating - rating of new result -** ConfigId - config id of new result -** Globals: -** matcher_bad_match_pad - defines limits of an acceptable match -** Operation: This routine adds the result of a classification into -** Results. If the new rating is much worse than the current -** best rating, it is not entered into results because it -** would end up being stripped later anyway. If the new rating -** is better than the old rating for the class, it replaces the -** old rating. If this is the first rating for the class, the -** class is added to the list of matched classes in Results. -** If the new rating is better than the best so far, it -** becomes the best so far. -** Return: none -** Exceptions: none -** History: Tue Mar 12 18:19:29 1991, DSJ, Created. -*/ FLOAT32 OldRating; INT_CLASS_STRUCT* CharClass = NULL; @@ -1206,7 +1173,7 @@ void Classify::AddNewResult(ADAPT_RESULTS *Results, Results->Configs[ClassId] = ~0; if (Rating < Results->BestRating && - // Ensure that fragments do no affect best rating, class and config. + // Ensure that fragments do not affect best rating, class and config. // This is needed so that at least one non-fragmented character is // always present in the Results. // TODO(daria): verify that this helps accuracy and does not @@ -1225,36 +1192,30 @@ void Classify::AddNewResult(ADAPT_RESULTS *Results, /*---------------------------------------------------------------------------*/ +/** + * This routine is identical to CharNormClassifier() + * except that it does no class pruning. It simply matches + * the unknown blob against the classes listed in + * Ambiguities. + * + * Globals: + * - #AllProtosOn mask that enables all protos + * - #AllConfigsOn mask that enables all configs + * + * @param Blob blob to be classified + * @param LineStats statistics for text line Blob is in + * @param Templates built-in templates to classify against + * @param Ambiguities array of class id's to match against + * @param[out] Results place to put match results + * + * @note Exceptions: none + * @note History: Tue Mar 12 19:40:36 1991, DSJ, Created. + */ void Classify::AmbigClassifier(TBLOB *Blob, LINE_STATS *LineStats, INT_TEMPLATES Templates, UNICHAR_ID *Ambiguities, ADAPT_RESULTS *Results) { -/* - ** Parameters: - ** Blob - blob to be classified -** LineStats - statistics for text line Blob is in -** Templates - built-in templates to classify against -** Ambiguities - array of class id's to match against -** Results - place to put match results -** Globals: -** AllProtosOn - mask that enables all protos -** AllConfigsOn - mask that enables all configs -** Operation: This routine is identical to CharNormClassifier() -** except that it does no class pruning. It simply matches -** the unknown blob against the classes listed in -** Ambiguities. -** Return: none -** Exceptions: none -** History: Tue Mar 12 19:40:36 1991, DSJ, Created. -*/ int NumFeatures; INT_FEATURE_ARRAY IntFeatures; CLASS_NORMALIZATION_ARRAY CharNormArray; @@ -1299,8 +1260,8 @@ void Classify::AmbigClassifier(TBLOB *Blob, } /* AmbigClassifier */ /*---------------------------------------------------------------------------*/ -// Factored-out calls to IntegerMatcher based on class pruner results. -// Returns integer matcher results inside CLASS_PRUNER_RESULTS structure. +/// Factored-out calls to IntegerMatcher based on class pruner results. +/// Returns integer matcher results inside CLASS_PRUNER_RESULTS structure. void Classify::MasterMatcher(INT_TEMPLATES templates, inT16 num_features, INT_FEATURE_ARRAY features, @@ -1370,31 +1331,28 @@ void Classify::MasterMatcher(INT_TEMPLATES templates, /*---------------------------------------------------------------------------*/ namespace tesseract { +/** + * This routine extracts baseline normalized features + * from the unknown character and matches them against the + * specified set of templates. The classes which match + * are added to Results. + * + * Globals: + * - BaselineCutoffs expected num features for each class + * + * @param Blob blob to be classified + * @param LineStats statistics for text line Blob is in + * @param Templates current set of adapted templates + * @param Results place to put match results + * + * @return Array of possible ambiguous chars that should be checked. + * @note Exceptions: none + * @note History: Tue Mar 12 19:38:03 1991, DSJ, Created. + */ UNICHAR_ID *Classify::BaselineClassifier(TBLOB *Blob, LINE_STATS *LineStats, ADAPT_TEMPLATES Templates, ADAPT_RESULTS *Results) { -/* - ** Parameters: - ** Blob - blob to be classified -** LineStats - statistics for text line Blob is in -** Templates - current set of adapted templates -** Results - place to put match results -** Globals: -** BaselineCutoffs - expected num features for each class -** Operation: This routine extracts baseline normalized features -** from the unknown character and matches them against the -** specified set of templates. The classes which match -** are added to Results. -** Return: Array of possible ambiguous chars that should be checked. -** Exceptions: none -** History: Tue Mar 12 19:38:03 1991, DSJ, Created. -*/ int NumFeatures; int NumClasses; INT_FEATURE_ARRAY IntFeatures; @@ -1524,25 +1482,25 @@ void Classify::ClassifyAsNoise(ADAPT_RESULTS *Results) { /*---------------------------------------------------------------------------*/ -int CompareCurrentRatings( //CLASS_ID *Class1, - const void *arg1, - const void *arg2) { //CLASS_ID *Class2) -/* - ** Parameters: - ** Class1, Class2 - classes whose ratings are to be compared -** Globals: -** CurrentRatings - contains actual ratings for each class -** Operation: This routine gets the ratings for the 2 specified classes -** from a global variable (CurrentRatings) and returns: -** -1 if Rating1 < Rating2 -** 0 if Rating1 = Rating2 -** 1 if Rating1 > Rating2 -** Return: Order of classes based on their ratings (see above). -** Exceptions: none -** History: Tue Mar 12 14:18:31 1991, DSJ, Created. -*/ +/** + * This routine gets the ratings for the 2 specified classes + * from a global variable (CurrentRatings) and returns: + * - -1 if Rating1 < Rating2 + * - 0 if Rating1 = Rating2 + * - 1 if Rating1 > Rating2 + * + * @param arg1 + * @param arg2 classes whose ratings are to be compared + * + * Globals: + * - CurrentRatings contains actual ratings for each class + * + * @return Order of classes based on their ratings (see above). + * @note Exceptions: none + * @note History: Tue Mar 12 14:18:31 1991, DSJ, Created. + */ +int CompareCurrentRatings(const void *arg1, + const void *arg2) { FLOAT32 Rating1, Rating2; CLASS_ID *Class1 = (CLASS_ID *) arg1; CLASS_ID *Class2 = (CLASS_ID *) arg2; @@ -1561,13 +1519,13 @@ int CompareCurrentRatings( //CLASS_ID *Class1, /*---------------------------------------------------------------------------*/ -// The function converts the given match ratings to the list of blob -// choices with ratings and certainties (used by the context checkers). -// If character fragments are present in the results, this function also makes -// sure that there is at least one non-fragmented classification included. -// For each classificaiton result check the unicharset for "definite" -// ambiguities and modify the resulting Choices accordingly. namespace tesseract { +/// The function converts the given match ratings to the list of blob +/// choices with ratings and certainties (used by the context checkers). +/// If character fragments are present in the results, this function also makes +/// sure that there is at least one non-fragmented classification included. +/// For each classification result check the unicharset for "definite" +/// ambiguities and modify the resulting Choices accordingly. void Classify::ConvertMatchesToChoices(ADAPT_RESULTS *Results, BLOB_CHOICE_LIST *Choices) { assert(Choices != NULL); diff --git a/classify/adaptmatch.h b/classify/adaptmatch.h index 59c049110e..1c4f7a5be0 100644 --- a/classify/adaptmatch.h +++ b/classify/adaptmatch.h @@ -18,9 +18,9 @@ #ifndef ADAPTMATCH_H #define ADAPTMATCH_H -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "oldlist.h" #include "tessclas.h" #include "fxdefs.h" @@ -42,15 +42,15 @@ extern BOOL_VAR_H(tess_cn_matching, 0, "Character Normalized Matching"); extern BOOL_VAR_H(tess_bn_matching, 0, "Baseline Normalized Matching"); extern INT_VAR_H(classify_learning_debug_level, 0, "Learning Debug Level: "); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ int GetAdaptiveFeatures(TBLOB *Blob, LINE_STATS *LineStats, INT_FEATURE_ARRAY IntFeatures, FEATURE_SET *FloatFeatures); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #endif diff --git a/classify/extract.cpp b/classify/extract.cpp index 8293e4cdd8..23678a7394 100644 --- a/classify/extract.cpp +++ b/classify/extract.cpp @@ -15,9 +15,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "extract.h" #include "flexfx.h" #include "funcdefs.h" @@ -25,55 +25,54 @@ typedef CHAR_FEATURES (*CF_FUNC) (); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ void ExtractorStub(); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ -/* tables to keep track of the different low level feature extractors */ +-----------------------------------------------------------------------------*/ +/** tables to keep track of the different low level feature extractors */ #define NUM_FX 3 #define DEFAULT_FX 2 int CurrentFx = DEFAULT_FX; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -CHAR_DESC ExtractBlobFeatures(TBLOB *Blob, LINE_STATS *LineStats) { -/* - ** Parameters: - ** Blob blob to extract features from - ** LineStats statistics about line blob is in - ** Operation: Extract features from Blob by calling the feature - ** extractor which is currently being used. This routine - ** simply provides a high level interface to feature - ** extraction. The caller can extract any type of features - ** from a blob without understanding any lower level details. - ** Return: The character features extracted from Blob. - ** Exceptions: none - ** History: Sun Jan 21 10:07:28 1990, DSJ, Created. +/** + * Extract features from Blob by calling the feature + * extractor which is currently being used. This routine + * simply provides a high level interface to feature + * extraction. The caller can extract any type of features + * from a blob without understanding any lower level details. + * + * @param Blob blob to extract features from + * @param LineStats statistics about line blob is in + * + * @return The character features extracted from Blob. + * @note Exceptions: none + * @note History: Sun Jan 21 10:07:28 1990, DSJ, Created. */ +CHAR_DESC ExtractBlobFeatures(TBLOB *Blob, LINE_STATS *LineStats) { return (ExtractFlexFeatures (Blob, LineStats)); } /* ExtractBlobFeatures */ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ void ExtractorStub () -/* - ** Parameters: none - ** Globals: none - ** Operation: This routine is used to stub out feature extractors - ** that are no longer used. It simply calls DoError. - ** Return: none - ** Exceptions: none - ** History: Wed Jan 2 14:16:49 1991, DSJ, Created. +/** + * This routine is used to stub out feature extractors + * that are no longer used. It simply calls DoError. + * + * @note Exceptions: none + * @note History: Wed Jan 2 14:16:49 1991, DSJ, Created. */ #define DUMMY_ERROR 1 { diff --git a/classify/extract.h b/classify/extract.h index b986303d34..751c90cc1d 100644 --- a/classify/extract.h +++ b/classify/extract.h @@ -22,9 +22,9 @@ #include "featdefs.h" #include -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ CHAR_DESC ExtractBlobFeatures(TBLOB *Blob, LINE_STATS *LineStats); /*--------------------------------------------------------------------------- diff --git a/classify/featdefs.cpp b/classify/featdefs.cpp index 7d3e42ddc1..514a4273b8 100644 --- a/classify/featdefs.cpp +++ b/classify/featdefs.cpp @@ -15,9 +15,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "featdefs.h" #include "emalloc.h" #include "danerror.h" @@ -26,15 +26,15 @@ #include #include -/* define errors triggered by this module */ +/** define errors triggered by this module */ #define ILLEGAL_NUM_SETS 3001 #define PICO_FEATURE_LENGTH 0.05 #define MAX_OUTLINE_FEATURES 100 -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /* define all of the parameters for the MicroFeature type*/ StartParamDesc (MicroFeatureParams) DefineParam (0, 0, -0.5, 0.5) @@ -83,9 +83,9 @@ EndParamDesc DefineFeature (OutlineFeatDesc, 3, 1, 1, MAX_OUTLINE_FEATURES, "Outline", "of", OutlineFeatParams) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ FEATURE_DEFS_STRUCT FeatureDefs = { NUM_FEATURE_TYPES, { @@ -96,21 +96,23 @@ FEATURE_DEFS_STRUCT FeatureDefs = { } }; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -void FreeCharDescription(CHAR_DESC CharDesc) { -/* - ** Parameters: - ** CharDesc character description to be deallocated - ** Globals: none - ** Operation: Release the memory consumed by the specified character - ** description and all of the features in that description. - ** Return: none - ** Exceptions: none - ** History: Wed May 23 13:52:19 1990, DSJ, Created. +/** + * Release the memory consumed by the specified character + * description and all of the features in that description. + * + * @param CharDesc character description to be deallocated + * + * Globals: + * - none + * + * @note Exceptions: none + * @note History: Wed May 23 13:52:19 1990, DSJ, Created. */ +void FreeCharDescription(CHAR_DESC CharDesc) { int i; if (CharDesc) { @@ -122,16 +124,18 @@ void FreeCharDescription(CHAR_DESC CharDesc) { /*---------------------------------------------------------------------------*/ -CHAR_DESC NewCharDescription() { -/* - ** Parameters: none - ** Globals: none - ** Operation: Allocate a new character description, initialize its - ** feature sets to be empty, and return it. - ** Return: New character description structure. - ** Exceptions: none - ** History: Wed May 23 15:27:10 1990, DSJ, Created. +/** + * Allocate a new character description, initialize its + * feature sets to be empty, and return it. + * + * Globals: + * - none + * + * @return New character description structure. + * @note Exceptions: none + * @note History: Wed May 23 15:27:10 1990, DSJ, Created. */ +CHAR_DESC NewCharDescription() { CHAR_DESC CharDesc; int i; @@ -147,23 +151,26 @@ CHAR_DESC NewCharDescription() { /*---------------------------------------------------------------------------*/ -void WriteCharDescription(FILE *File, CHAR_DESC CharDesc) { -/* - ** Parameters: - ** File open text file to write CharDesc to - ** CharDesc character description to write to File - ** Globals: none - ** Operation: Write a textual representation of CharDesc to File. - ** The format used is to write out the number of feature - ** sets which will be written followed by a representation of - ** each feature set. - ** Each set starts with the short name for that feature followed - ** by a description of the feature set. Feature sets which are - ** not present are not written. - ** Return: none - ** Exceptions: none - ** History: Wed May 23 17:21:18 1990, DSJ, Created. +/** + * Write a textual representation of CharDesc to File. + * The format used is to write out the number of feature + * sets which will be written followed by a representation of + * each feature set. + * + * Each set starts with the short name for that feature followed + * by a description of the feature set. Feature sets which are + * not present are not written. + * + * Globals: + * - none + * + * @param File open text file to write CharDesc to + * @param CharDesc character description to write to File + * + * @note Exceptions: none + * @note History: Wed May 23 17:21:18 1990, DSJ, Created. */ +void WriteCharDescription(FILE *File, CHAR_DESC CharDesc) { int Type; int NumSetsToWrite = 0; @@ -181,22 +188,27 @@ void WriteCharDescription(FILE *File, CHAR_DESC CharDesc) { /*---------------------------------------------------------------------------*/ -CHAR_DESC ReadCharDescription(FILE *File) { -/* - ** Parameters: - ** File open text file to read character description from - ** Globals: none - ** Operation: Read a character description from File, and return - ** a data structure containing this information. The data - ** is formatted as follows: - ** NumberOfSets - ** ShortNameForSet1 Set1 - ** ShortNameForSet2 Set2 - ** ... - ** Return: Character description read from File. - ** Exceptions: ILLEGAL_NUM_SETS - ** History: Wed May 23 17:32:48 1990, DSJ, Created. +/** + * Read a character description from File, and return + * a data structure containing this information. The data + * is formatted as follows: + * @verbatim + NumberOfSets + ShortNameForSet1 Set1 + ShortNameForSet2 Set2 + ... + @endverbatim + * + * Globals: + * - none + * + * @param File open text file to read character description from + * @return Character description read from File. + * @note Exceptions: + * - ILLEGAL_NUM_SETS + * @note History: Wed May 23 17:32:48 1990, DSJ, Created. */ +CHAR_DESC ReadCharDescription(FILE *File) { int NumSetsToRead; char ShortName[FEAT_NAME_SIZE]; CHAR_DESC CharDesc; @@ -220,16 +232,19 @@ CHAR_DESC ReadCharDescription(FILE *File) { /*---------------------------------------------------------------------------*/ int ShortNameToFeatureType(const char *ShortName) { -/* - ** Parameters: - ** ShortName short name of a feature type - ** Globals: none - ** Operation: Search thru all features currently defined and return - ** the feature type for the feature with the specified short - ** name. Trap an error if the specified name is not found. - ** Return: Feature type which corresponds to ShortName. - ** Exceptions: ILLEGAL_SHORT_NAME - ** History: Wed May 23 15:36:05 1990, DSJ, Created. +/** + * Search thru all features currently defined and return + * the feature type for the feature with the specified short + * name. Trap an error if the specified name is not found. + * + * Globals: + * - none + * + * @param ShortName short name of a feature type + * @return Feature type which corresponds to ShortName. + * @note Exceptions: + * - ILLEGAL_SHORT_NAME + * @note History: Wed May 23 15:36:05 1990, DSJ, Created. */ int i; diff --git a/classify/float2int.cpp b/classify/float2int.cpp index edf8c3f9e8..0098b7a375 100644 --- a/classify/float2int.cpp +++ b/classify/float2int.cpp @@ -15,9 +15,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "float2int.h" #include "normmatch.h" #include "mfoutline.h" @@ -26,26 +26,28 @@ #define MAX_INT_CHAR_NORM (INT_CHAR_NORM_RANGE - 1) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ namespace tesseract { +/** + * For each class in Templates, clear the corresponding + * entry in CharNormArray. CharNormArray is indexed by class + * indicies (as obtained from Templates) rather than class id's. + * + * Globals: + * - none + * + * @param Templates specifies classes currently defined + * @param CharNormArray array to be cleared + * + * @note Exceptions: none + * @note History: Wed Feb 20 11:20:54 1991, DSJ, Created. + */ void ClearCharNormArray(INT_TEMPLATES Templates, CLASS_NORMALIZATION_ARRAY CharNormArray) { -/* - ** Parameters: - ** Templates specifies classes currently defined - ** CharNormArray array to be cleared - ** Globals: none - ** Operation: For each class in Templates, clear the corresponding - ** entry in CharNormArray. CharNormArray is indexed by class - ** indicies (as obtained from Templates) rather than class id's. - ** Return: none - ** Exceptions: none - ** History: Wed Feb 20 11:20:54 1991, DSJ, Created. - */ int i; for (i = 0; i < Templates->NumClasses; i++) { @@ -56,24 +58,26 @@ void ClearCharNormArray(INT_TEMPLATES Templates, /*---------------------------------------------------------------------------*/ +/** + * For each class in Templates, compute the match between + * NormFeature and the normalization protos for that class. + * Convert this number to the range from 0 - 255 and store it + * into CharNormArray. CharNormArray is indexed by class + * indicies (as obtained from Templates) rather than class id's. + * + * Globals: + * - none + * + * @param NormFeature character normalization feature + * @param Templates specifies classes currently defined + * @param[out] CharNormArray place to put results + * + * @note Exceptions: none + * @note History: Wed Feb 20 11:20:54 1991, DSJ, Created. + */ void Classify::ComputeIntCharNormArray( FEATURE NormFeature, INT_TEMPLATES Templates, CLASS_NORMALIZATION_ARRAY CharNormArray) { -/* - ** Parameters: - ** NormFeature character normalization feature - ** Templates specifies classes currently defined - ** CharNormArray place to put results - ** Globals: none - ** Operation: For each class in Templates, compute the match between - ** NormFeature and the normalization protos for that class. - ** Convert this number to the range from 0 - 255 and store it - ** into CharNormArray. CharNormArray is indexed by class - ** indicies (as obtained from Templates) rather than class id's. - ** Return: none (results are returned in CharNormArray) - ** Exceptions: none - ** History: Wed Feb 20 11:20:54 1991, DSJ, Created. - */ int i; int NormAdjust; @@ -92,19 +96,21 @@ void Classify::ComputeIntCharNormArray( } // namespace tesseract /*---------------------------------------------------------------------------*/ -void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures) { -/* - ** Parameters: - ** Features floating point pico-features to be converted - ** IntFeatures array to put converted features into - ** Globals: none - ** Operation: This routine converts each floating point pico-feature - ** in Features into integer format and saves it into - ** IntFeatures. - ** Return: none (results are returned in IntFeatures) - ** Exceptions: none - ** History: Wed Feb 20 10:58:45 1991, DSJ, Created. +/** + * This routine converts each floating point pico-feature + * in Features into integer format and saves it into + * IntFeatures. + * + * Globals: + * - none + * + * @param Features floating point pico-features to be converted + * @param[out] IntFeatures array to put converted features into + * + * @note Exceptions: none + * @note History: Wed Feb 20 10:58:45 1991, DSJ, Created. */ +void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures) { int Fid; FEATURE Feature; FLOAT32 YShift; diff --git a/classify/float2int.h b/classify/float2int.h index 0c6e42cce6..380c081351 100644 --- a/classify/float2int.h +++ b/classify/float2int.h @@ -18,18 +18,18 @@ #ifndef FLOAT2INT_H #define FLOAT2INT_H -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "intmatcher.h" #include "ocrfeatures.h" #define INT_FEAT_RANGE 256 #define BASELINE_Y_SHIFT (0.25) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ namespace tesseract { void ClearCharNormArray(INT_TEMPLATES Templates, CLASS_NORMALIZATION_ARRAY CharNormArray); diff --git a/classify/fxdefs.cpp b/classify/fxdefs.cpp index 166ace0803..a8c45c3f89 100644 --- a/classify/fxdefs.cpp +++ b/classify/fxdefs.cpp @@ -22,10 +22,10 @@ #include "picofeat.h" #include "normfeat.h" -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ -/* flag to control learn mode vs. classify mode */ +-----------------------------------------------------------------------------*/ +/** flag to control learn mode vs. classify mode */ int ExtractMode; // Definitions of extractors separated from feature definitions. @@ -42,27 +42,28 @@ FEATURE_EXT_STRUCT* ExtractorDefs[NUM_FEATURE_TYPES] = { }; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ void SetupExtractors() { for (int i = 0; i < NUM_FEATURE_TYPES; ++i) FeatureDefs.FeatureExtractors[i] = ExtractorDefs[i]; } -void GetLineStatsFromRow(TEXTROW *Row, LINE_STATS *LineStats) { -/* - ** Parameters: - ** Row text row to get line statistics from - ** LineStats place to put line statistics - ** Globals: none - ** Operation: This routine copies the relavent fields from the - ** Row struct to the LineStats struct. - ** Return: none (results are returned in LineStats) - ** Exceptions: none - ** History: Mon Mar 11 10:38:43 1991, DSJ, Created. +/** + * This routine copies the relavent fields from the + * Row struct to the LineStats struct. + * + * Globals: + * - none + * + * @param Row text row to get line statistics from + * @param[out] LineStats place to put line statistics + * + * @note History: Mon Mar 11 10:38:43 1991, DSJ, Created. */ +void GetLineStatsFromRow(TEXTROW *Row, LINE_STATS *LineStats) { LineStats->Baseline = &(Row->baseline); LineStats->XHeightLine = &(Row->xheight); LineStats->xheight = Row->lineheight; diff --git a/classify/fxdefs.h b/classify/fxdefs.h index 5b6fd47d93..41a624087b 100644 --- a/classify/fxdefs.h +++ b/classify/fxdefs.h @@ -18,9 +18,9 @@ #ifndef FXDEFS_H #define FXDEFS_H -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "tessclas.h" #include "general.h" @@ -28,35 +28,35 @@ #define LEARN_MODE 0 #define CLASSIFY_MODE 1 -/* define a data structure to hold line statistics. These line statistics +/** define a data structure to hold line statistics. These line statistics are used to normalize character outlines to a standard size and position relative to the baseline of the text. */ typedef struct { - SPLINE_SPEC *Baseline; /* collection of splines describing baseline */ - SPLINE_SPEC *XHeightLine; /* collection of splines describing x-height */ - FLOAT32 xheight; /* avg. distance from x-height to baseline */ - FLOAT32 AscRise; /* avg. distance from ascenders to x-height */ - FLOAT32 DescDrop; /* avg. distance from baseline to descenders */ + SPLINE_SPEC *Baseline; /**< collection of splines describing baseline */ + SPLINE_SPEC *XHeightLine; /**< collection of splines describing x-height */ + FLOAT32 xheight; /**< avg. distance from x-height to baseline */ + FLOAT32 AscRise; /**< avg. distance from ascenders to x-height */ + FLOAT32 DescDrop; /**< avg. distance from baseline to descenders */ /* always a negative number */ - TEXTROW *TextRow; /* kludge - only needed by fx for fast matcher */ + TEXTROW *TextRow; /**< kludge - only needed by fx for fast matcher */ /* should be removed later */ } LINE_STATS; -/* define a generic character description as a char pointer. In reality, +/** define a generic character description as a char pointer. In reality, it will be a pointer to some data structure. Paired feature extractors/matchers need to agree on the data structure to be used, however, the high level classifier does not need to know the details of this data structure. */ typedef char *CHAR_FEATURES; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Macros -----------------------------------------------------------------------------**/ -/* macro to change and monitor the mode of the feature extractor. +-----------------------------------------------------------------------------*/ +/** macro to change and monitor the mode of the feature extractor. In general, learn mode smears features which would otherwise be discrete in nature; classify mode does not.*/ #define SetExtractMode(M) (ExtractMode = (M)) @@ -85,9 +85,9 @@ void GetLineStatsFromRow #undef _ARGS */ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ -/* flag to control learn mode vs. classify mode */ +-----------------------------------------------------------------------------*/ +/** flag to control learn mode vs. classify mode */ extern int ExtractMode; #endif diff --git a/classify/fxid.h b/classify/fxid.h index 9db710fa29..79b3c35475 100644 --- a/classify/fxid.h +++ b/classify/fxid.h @@ -43,14 +43,14 @@ included in your top level program file. #include "tessclas.h" #include "oldlist.h" -#define FEATURE_MATCHER 1 /* Use micro-features */ +#define FEATURE_MATCHER 1 /**< Use micro-features */ -#define WO_UNSCALED 0 /*first square scaled fx */ -#define STATISTICAL_WO 1 /*new wo */ -#define MICRO_FEATURES 2 /*microfeature extractor */ -#define WO_SCALED 3 /*wiseowl scaled to baseline */ -#define MAX_FX 3 /*no of working fx-ers */ -#define NO_FUNCTION 0 /*special value for nothing */ +#define WO_UNSCALED 0 /**< first square scaled fx */ +#define STATISTICAL_WO 1 /**< new wo */ +#define MICRO_FEATURES 2 /**< microfeature extractor */ +#define WO_SCALED 3 /**< wiseowl scaled to baseline */ +#define MAX_FX 3 /**< no of working fx-ers */ +#define NO_FUNCTION 0 /**< special value for nothing */ /* This file contains declarations of the top-level feature extractor functions as used by the Classify process*/ diff --git a/classify/intproto.cpp b/classify/intproto.cpp index 4a28d980ce..597427f6b9 100644 --- a/classify/intproto.cpp +++ b/classify/intproto.cpp @@ -15,9 +15,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ // Include automatically generated configuration file if running autoconf. #ifdef HAVE_CONFIG_H #include "config_auto.h" @@ -112,9 +112,9 @@ FILL_SPEC; #define OLD_WERDS_PER_CONFIG_VEC ((OLD_MAX_NUM_CONFIGS + BITS_PER_WERD - 1) /\ BITS_PER_WERD) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Macros -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /* macro for performing circular increments of bucket indices */ #define CircularIncrement(i,r) (((i) < (r) - 1)?((i)++):((i) = 0)) @@ -173,18 +173,18 @@ void RenderIntProto(void *window, int TruncateParam(FLOAT32 Param, int Min, int Max, char *Id); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /* global display lists used to display proto and feature match information*/ ScrollView *IntMatchWindow = NULL; ScrollView *FeatureDisplayWindow = NULL; ScrollView *ProtoDisplayWindow = NULL; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Variables -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /* control knobs */ INT_VAR(classify_num_cp_levels, 3, "Number of Class Pruner Levels"); @@ -204,9 +204,9 @@ double_VAR(classify_pp_angle_pad, 45.0, "Proto Pruner Angle Pad"); double_VAR(classify_pp_end_pad, 0.5, "Proto Prune End Pad"); double_VAR(classify_pp_side_pad, 2.5, "Proto Pruner Side Pad"); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ void AddIntClass(INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class) { /* @@ -1288,9 +1288,9 @@ void Classify::WriteIntTemplates(FILE *File, INT_TEMPLATES Templates, } // namespace tesseract -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ FLOAT32 BucketStart(int Bucket, FLOAT32 Offset, int NumBuckets) { /* diff --git a/classify/kdtree.cpp b/classify/kdtree.cpp index cc36b132e2..04ebc9e52d 100644 --- a/classify/kdtree.cpp +++ b/classify/kdtree.cpp @@ -18,9 +18,9 @@ ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "kdtree.h" #include "const.h" #include "emalloc.h" @@ -33,9 +33,9 @@ #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define NodeFound(N,K,D) (( (N)->Key == (K) ) && ( (N)->Data == (D) )) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #define MINSEARCH -MAX_FLOAT32 #define MAXSEARCH MAX_FLOAT32 @@ -71,7 +71,7 @@ static int NextLevel(int level) { return level; } -// Helper function to find the previous essential dimension in a cycle. +/// Helper function to find the previous essential dimension in a cycle. static int PrevLevel(int level) { do { --level; @@ -81,37 +81,35 @@ static int PrevLevel(int level) { return level; } -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ +/** + * This routine allocates and returns a new K-D tree data + * structure. It also reallocates the small and large + * search region boxes if they are not large enough to + * accomodate the size of the new K-D tree. KeyDesc is + * an array of key descriptors that indicate which dimensions + * are circular and, if they are circular, what the range is. + * + * Globals: + * - MaxDimension largest # of dimensions in any K-D tree + * - SBMin small search region box + * - SBMax + * - LBMin large search region box + * - LBMax + * - Key description of key dimensions + * + * @param KeySize # of dimensions in the K-D tree + * @param KeyDesc array of params to describe key dimensions + * + * @return Pointer to new K-D tree + * @note Exceptions: None + * @note History: 3/13/89, DSJ, Created. + */ KDTREE * MakeKDTree (inT16 KeySize, PARAM_DESC KeyDesc[]) { -/* - ** Parameters: - ** KeySize # of dimensions in the K-D tree - ** KeyDesc array of params to describe key dimensions - ** Globals: - ** MaxDimension largest # of dimensions in any K-D tree - ** SBMin small search region box - ** SBMax - ** LBMin large search region box - ** LBMax - ** Key description of key dimensions - ** Operation: - ** This routine allocates and returns a new K-D tree data - ** structure. It also reallocates the small and large - ** search region boxes if they are not large enough to - ** accomodate the size of the new K-D tree. KeyDesc is - ** an array of key descriptors that indicate which dimensions - ** are circular and, if they are circular, what the range is. - ** Return: - ** Pointer to new K-D tree - ** Exceptions: - ** None - ** History: - ** 3/13/89, DSJ, Created. - */ int i; void *NewMemory; KDTREE *KDTree; @@ -157,24 +155,24 @@ MakeKDTree (inT16 KeySize, PARAM_DESC KeyDesc[]) { /*---------------------------------------------------------------------------*/ void KDStore(KDTREE *Tree, FLOAT32 *Key, void *Data) { -/* - ** Parameters: - ** Tree K-D tree in which data is to be stored - ** Key ptr to key by which data can be retrieved - ** Data ptr to data to be stored in the tree - ** Globals: - ** N dimension of the K-D tree - ** KeyDesc descriptions of tree dimensions - ** StoreCount debug variables for performance tests - ** StoreUniqueCount - ** StoreProbeCount - ** Operation: - ** This routine stores Data in the K-D tree specified by Tree - ** using Key as an access key. - ** Return: none - ** Exceptions: none - ** History: 3/10/89, DSJ, Created. - ** 7/13/89, DSJ, Changed return to void. +/** + * This routine stores Data in the K-D tree specified by Tree + * using Key as an access key. + * + * @param Tree K-D tree in which data is to be stored + * @param Key ptr to key by which data can be retrieved + * @param Data ptr to data to be stored in the tree + * + * Globals: + * - N dimension of the K-D tree + * - KeyDesc descriptions of tree dimensions + * - StoreCount debug variables for performance tests + * - StoreUniqueCount + * - StoreProbeCount + * + * @note Exceptions: none + * @note History: 3/10/89, DSJ, Created. + * 7/13/89, DSJ, Changed return to void. */ int Level; KDNODE *Node; @@ -205,47 +203,46 @@ void KDStore(KDTREE *Tree, FLOAT32 *Key, void *Data) { /*---------------------------------------------------------------------------*/ +/** + * This routine deletes a node from Tree. The node to be + * deleted is specified by the Key for the node and the Data + * contents of the node. These two pointers must be identical + * to the pointers that were used for the node when it was + * originally stored in the tree. A node will be deleted from + * the tree only if its key and data pointers are identical + * to Key and Data respectively. The empty space left in the tree + * is filled by pulling a leaf up from the bottom of one of + * the subtrees of the node being deleted. The leaf node will + * be pulled from left subtrees whenever possible (this was + * an arbitrary decision). No attempt is made to pull the leaf + * from the deepest subtree (to minimize length). The branch + * point for the replacement node is changed to be the same as + * the branch point of the deleted node. This keeps us from + * having to rearrange the tree every time we delete a node. + * Also, the LeftBranch and RightBranch numbers of the + * replacement node are set to be the same as the deleted node. + * The makes the delete easier and more efficient, but it may + * make searches in the tree less efficient after many nodes are + * deleted. If the node specified by Key and Data does not + * exist in the tree, then nothing is done. + * + * Globals: + * - N dimension of the K-D tree + * - KeyDesc description of each dimension + * - DeleteCount debug variables for performance tests + * - DeleteProbeCount + * + * @param Tree K-D tree to delete node from + * @param Key key of node to be deleted + * @param Data data contents of node to be deleted + * + * @note Exceptions: none + * + * @note History: 3/13/89, DSJ, Created. + * 7/13/89, DSJ, Specify node indirectly by key and data. + */ void KDDelete (KDTREE * Tree, FLOAT32 Key[], void *Data) { -/* - ** Parameters: - ** Tree K-D tree to delete node from - ** Key key of node to be deleted - ** Data data contents of node to be deleted - ** Globals: - ** N dimension of the K-D tree - ** KeyDesc description of each dimension - ** DeleteCount debug variables for performance tests - ** DeleteProbeCount - ** Operation: - ** This routine deletes a node from Tree. The node to be - ** deleted is specified by the Key for the node and the Data - ** contents of the node. These two pointers must be identical - ** to the pointers that were used for the node when it was - ** originally stored in the tree. A node will be deleted from - ** the tree only if its key and data pointers are identical - ** to Key and Data respectively. The empty space left in the tree - ** is filled by pulling a leaf up from the bottom of one of - ** the subtrees of the node being deleted. The leaf node will - ** be pulled from left subtrees whenever possible (this was - ** an arbitrary decision). No attempt is made to pull the leaf - ** from the deepest subtree (to minimize length). The branch - ** point for the replacement node is changed to be the same as - ** the branch point of the deleted node. This keeps us from - ** having to rearrange the tree every time we delete a node. - ** Also, the LeftBranch and RightBranch numbers of the - ** replacement node are set to be the same as the deleted node. - ** The makes the delete easier and more efficient, but it may - ** make searches in the tree less efficient after many nodes are - ** deleted. If the node specified by Key and Data does not - ** exist in the tree, then nothing is done. - ** Return: none - ** None - ** Exceptions: none - ** None - ** History: 3/13/89, DSJ, Created. - ** 7/13/89, DSJ, Specify node indirectly by key and data. - */ int Level; KDNODE *Current; KDNODE *Father; @@ -440,9 +437,9 @@ void FreeKDTree(KDTREE *Tree) { } /* FreeKDTree */ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ int Equal (FLOAT32 Key1[], FLOAT32 Key2[]) { diff --git a/classify/kdtree.h b/classify/kdtree.h index 93c7903d38..2f4f237a58 100644 --- a/classify/kdtree.h +++ b/classify/kdtree.h @@ -19,14 +19,14 @@ #ifndef KDTREE_H #define KDTREE_H -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "general.h" #include "cutil.h" #include "ocrfeatures.h" -/* +/** NOTE: All circular parameters of all keys must be in the range Min <= Param < Max @@ -38,13 +38,13 @@ correctly if circular parameters outside the specified range are used. typedef struct kdnode { - FLOAT32 *Key; /* search key */ - char *Data; /* data that corresponds to key */ - FLOAT32 BranchPoint; /* needed to make deletes work efficiently */ - FLOAT32 LeftBranch; /* used to optimize search pruning */ - FLOAT32 RightBranch; /* used to optimize search pruning */ - struct kdnode *Left; /* ptrs for KD tree structure */ - struct kdnode *Right; + FLOAT32 *Key; /**< search key */ + char *Data; /**< data that corresponds to key */ + FLOAT32 BranchPoint; /**< needed to make deletes work efficiently */ + FLOAT32 LeftBranch; /**< used to optimize search pruning */ + FLOAT32 RightBranch; /**< used to optimize search pruning */ + struct kdnode *Left; /**< ptr for KD tree structure */ + struct kdnode *Right; /**< ptr for KD tree structure */ } @@ -60,7 +60,8 @@ typedef struct KDTREE; -typedef enum { /* used for walking thru KD trees */ +/** used for walking thru KD trees */ +typedef enum { preorder, postorder, endorder, leaf } @@ -72,9 +73,9 @@ VISIT; -----------------------------------------------------------------------------*/ #define RootOf(T) ((T)->Root.Left->Data) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ KDTREE *MakeKDTree (inT16 KeySize, PARAM_DESC KeyDesc[]); void KDStore(KDTREE *Tree, FLOAT32 *Key, void *Data); @@ -91,9 +92,9 @@ void KDWalk(KDTREE *Tree, void_proc Action); void FreeKDTree(KDTREE *Tree); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Private Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ int Equal (FLOAT32 Key1[], FLOAT32 Key2[]); KDNODE *MakeKDNode (FLOAT32 Key[], char *Data, int Index); diff --git a/classify/protos.cpp b/classify/protos.cpp index 8cfd566469..8c2350697e 100644 --- a/classify/protos.cpp +++ b/classify/protos.cpp @@ -53,12 +53,14 @@ STRING_VAR(classify_training_file, "MicroFeatures", "Training file"); /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * AddConfigToClass +/** + * @name AddConfigToClass * * Add a new config to this class. Malloc new space and copy the * old configs if necessary. Return the config id for the new config. - **********************************************************************/ + * + * @param Class The class to add to + */ int AddConfigToClass(CLASS_TYPE Class) { int NewNumConfigs; int NewConfig; @@ -87,12 +89,14 @@ int AddConfigToClass(CLASS_TYPE Class) { } -/********************************************************************** - * AddProtoToClass +/** + * @name AddProtoToClass * * Add a new proto to this class. Malloc new space and copy the * old protos if necessary. Return the proto id for the new proto. - **********************************************************************/ + * + * @param Class The class to add to + */ int AddProtoToClass(CLASS_TYPE Class) { int i; int Bit; @@ -128,11 +132,14 @@ int AddProtoToClass(CLASS_TYPE Class) { } -/********************************************************************** - * ClassConfigLength +/** + * @name ClassConfigLength * * Return the length of all the protos in this class. - **********************************************************************/ + * + * @param Class The class to add to + * @param Config FIXME + */ FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config) { inT16 Pid; FLOAT32 TotalLength = 0; @@ -147,11 +154,13 @@ FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config) { } -/********************************************************************** - * ClassProtoLength +/** + * @name ClassProtoLength * * Return the length of all the protos in this class. - **********************************************************************/ + * + * @param Class The class to use + */ FLOAT32 ClassProtoLength(CLASS_TYPE Class) { inT16 Pid; FLOAT32 TotalLength = 0; @@ -163,11 +172,14 @@ FLOAT32 ClassProtoLength(CLASS_TYPE Class) { } -/********************************************************************** - * CopyProto +/** + * @name CopyProto * * Copy the first proto into the second. - **********************************************************************/ + * + * @param Src Source + * @param Dest Destination + */ void CopyProto(PROTO Src, PROTO Dest) { Dest->X = Src->X; Dest->Y = Src->Y; @@ -272,13 +284,13 @@ void PrintProtos(CLASS_TYPE Class) { } -/********************************************************************** - * ReadClassFile +namespace tesseract { +/** + * @name ReadClassFile * * Read in the training data from a file. All of the classes are read * in. The results are stored in the global variable, 'TrainingData'. - **********************************************************************/ -namespace tesseract { + */ void Classify::ReadClassFile() { FILE *File; char TextLine[CHARS_PER_LINE]; @@ -301,12 +313,12 @@ void Classify::ReadClassFile() { } } // namespace tesseract -/********************************************************************** +/** * ReadClassFromFile * * Read in a class description (protos and configs) from a file. Update * the class structure record. - **********************************************************************/ + */ void ReadClassFromFile(FILE *File, UNICHAR_ID unichar_id) { CLASS_TYPE Class; @@ -317,12 +329,12 @@ void ReadClassFromFile(FILE *File, UNICHAR_ID unichar_id) { ReadConfigs(File, Class); } -/********************************************************************** +/** * ReadConfigs * * Read the prototype configurations for this class from a file. Read * the requested number of lines. - **********************************************************************/ + */ void ReadConfigs(register FILE *File, CLASS_TYPE Class) { inT16 Cid; register inT16 Wid; @@ -347,12 +359,12 @@ void ReadConfigs(register FILE *File, CLASS_TYPE Class) { } -/********************************************************************** +/** * ReadProtos * * Read in all the prototype information from a file. Read the number * of lines requested. - **********************************************************************/ + */ void ReadProtos(register FILE *File, CLASS_TYPE Class) { register inT16 Pid; register PROTO Proto; @@ -376,15 +388,15 @@ void ReadProtos(register FILE *File, CLASS_TYPE Class) { } -/********************************************************************** - * SplitProto +/** + * @name SplitProto * * Add a new proto to this class. Malloc new space and copy the * old protos if necessary. Return the proto id for the new proto. * Update all configurations so that each config which contained the * specified old proto will also contain the new proto. The caller * is responsible for actually filling in the appropriate proto params. - **********************************************************************/ + */ int SplitProto(CLASS_TYPE Class, int OldPid) { int i; int NewPid; @@ -401,12 +413,16 @@ int SplitProto(CLASS_TYPE Class, int OldPid) { } -/********************************************************************** - * WriteOldConfigFile +/** + * @deprecated + * @nameWriteOldConfigFile * * Write the configs in the given class to the specified file in the * old config format. - **********************************************************************/ + * + * @param File The file to write to + * @param Class The class to write + */ void WriteOldConfigFile(FILE *File, CLASS_TYPE Class) { int Cid, Pid; BIT_VECTOR Config; @@ -429,12 +445,16 @@ void WriteOldConfigFile(FILE *File, CLASS_TYPE Class) { } -/********************************************************************** - * WriteOldProtoFile +/** + * @deprecated + * @name WriteOldProtoFile * * Write the protos in the given class to the specified file in the * old proto format. - **********************************************************************/ + * + * @param File The file to write to + * @param Class The class to write + */ void WriteOldProtoFile(FILE *File, CLASS_TYPE Class) { int Pid; PROTO Proto; diff --git a/classify/protos.h b/classify/protos.h index 5e92b7ff3d..80bf655a7e 100644 --- a/classify/protos.h +++ b/classify/protos.h @@ -81,51 +81,51 @@ extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file"); /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** +/** * AddProtoToConfig * * Set a single proto bit in the specified configuration. - **********************************************************************/ + */ #define AddProtoToConfig(Pid,Config) \ (SET_BIT (Config, Pid)) -/********************************************************************** +/** * RemoveProtoFromConfig * * Clear a single proto bit in the specified configuration. - **********************************************************************/ + */ #define RemoveProtoFromConfig(Pid,Config) \ (reset_bit (Config, Pid)) -/********************************************************************** +/** * ClassOfChar * * Return the class of a particular ASCII character value. - **********************************************************************/ + */ #define ClassOfChar(Char) \ ((TrainingData [Char].NumProtos) ? \ (& TrainingData [Char]) : \ NO_CLASS) -/********************************************************************** +/** * ProtoIn * * Choose the selected prototype in this class record. Return the * pointer to it (type PROTO). - **********************************************************************/ + */ #define ProtoIn(Class,Pid) \ (& (Class)->Prototypes [Pid]) -/********************************************************************** +/** * PrintProto * * Print out the contents of a prototype. The 'Proto' argument is of * type 'PROTO'. - **********************************************************************/ + */ #define PrintProto(Proto) \ (cprintf ("X=%4.2f, Y=%4.2f, Angle=%4.2f", \ @@ -135,12 +135,12 @@ extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file"); Proto->Angle)) \ -/********************************************************************** +/** * PrintProtoLine * * Print out the contents of a prototype. The 'Proto' argument is of * type 'PROTO'. - **********************************************************************/ + */ #define PrintProtoLine(Proto) \ (cprintf ("A=%4.2f, B=%4.2f, C=%4.2f", \ diff --git a/classify/speckle.cpp b/classify/speckle.cpp index ddfe2f83cf..cd79af803f 100644 --- a/classify/speckle.cpp +++ b/classify/speckle.cpp @@ -15,19 +15,19 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "speckle.h" #include "blobs.h" #include "ratngs.h" #include "varable.h" -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ -/* define control knobs for adjusting definition of speckle*/ +-----------------------------------------------------------------------------*/ +/** define control knobs for adjusting definition of speckle*/ double_VAR(speckle_large_max_size, 0.30, "Max large speckle size"); double_VAR(speckle_small_penalty, 10.0, "Small speckle penalty"); @@ -36,27 +36,30 @@ double_VAR(speckle_large_penalty, 10.0, "Large speckle penalty"); double_VAR(speckle_small_certainty, -1.0, "Small speckle certainty"); -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -void AddLargeSpeckleTo(BLOB_CHOICE_LIST *Choices) { -/* - ** Parameters: - ** Choices choices to add a speckle choice to - ** Globals: - ** speckle_small_penalty rating for a small speckle - ** speckle_large_penalty rating penalty for a large speckle - ** speckle_small_certainty certainty for a small speckle - ** Operation: This routine adds a null choice to Choices with a - ** rating equal to the worst rating in Choices plus a pad. - ** The certainty of the new choice is the same as the - ** certainty of the worst choice in Choices. The new choice - ** is added to the end of Choices. - ** Return: New Choices list with null choice added to end. - ** Exceptions: none - ** History: Mon Mar 11 11:08:11 1991, DSJ, Created. +/** + * This routine adds a null choice to Choices with a + * rating equal to the worst rating in Choices plus a pad. + * The certainty of the new choice is the same as the + * certainty of the worst choice in Choices. The new choice + * is added to the end of Choices. + * + * Globals: + * - #speckle_small_penalty rating for a small speckle + * - #speckle_large_penalty rating penalty for a large speckle + * - #speckle_small_certainty certainty for a small speckle + * + * @param Choices choices to add a speckle choice to + * + * @return New Choices list with null choice added to end. + * + * Exceptions: none + * History: Mon Mar 11 11:08:11 1991, DSJ, Created. */ +void AddLargeSpeckleTo(BLOB_CHOICE_LIST *Choices) { assert(Choices != NULL); BLOB_CHOICE *blob_choice; BLOB_CHOICE_IT temp_it; @@ -83,19 +86,22 @@ void AddLargeSpeckleTo(BLOB_CHOICE_LIST *Choices) { /*---------------------------------------------------------------------------*/ -BOOL8 LargeSpeckle(TBLOB *Blob, TEXTROW *Row) { -/* - ** Parameters: - ** Blob blob to test against speckle criteria - ** Row text row that blob is in - ** Globals: - ** MaxLargeSpeckleSize largest allowed speckle - ** Operation: This routine returns TRUE if both the width of height - ** of Blob are less than the MaxLargeSpeckleSize. - ** Return: TRUE if Blob is speckle, FALSE otherwise. - ** Exceptions: none - ** History: Mon Mar 11 10:06:49 1991, DSJ, Created. +/** + * This routine returns TRUE if both the width of height + * of Blob are less than the MaxLargeSpeckleSize. + * + * Globals: + * - #speckle_large_max_size largest allowed speckle + * + * Exceptions: none + * History: Mon Mar 11 10:06:49 1991, DSJ, Created. + * + * @param Blob blob to test against speckle criteria + * @param Row text row that blob is in + * + * @return TRUE if Blob is speckle, FALSE otherwise. */ +BOOL8 LargeSpeckle(TBLOB *Blob, TEXTROW *Row) { double speckle_size; TPOINT TopLeft; TPOINT BottomRight; diff --git a/classify/speckle.h b/classify/speckle.h index 8f896587e3..f3b01bd514 100644 --- a/classify/speckle.h +++ b/classify/speckle.h @@ -18,24 +18,24 @@ #ifndef SPECKLE_H #define SPECKLE_H -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "baseline.h" #include "ratngs.h" -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Macros -----------------------------------------------------------------------------**/ -/* macro for getting the height of a row of text */ +-----------------------------------------------------------------------------*/ +/** macro for getting the height of a row of text */ #define RowHeight(R) ((classify_baseline_normalized)? \ (BASELINE_SCALE): \ ((R)->lineheight)) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ void AddLargeSpeckleTo(BLOB_CHOICE_LIST *Choices); BOOL8 LargeSpeckle(TBLOB *Blob, TEXTROW *Row); diff --git a/cutil/bitvec.cpp b/cutil/bitvec.cpp index 1a2c04981d..10d2bc5ed8 100644 --- a/cutil/bitvec.cpp +++ b/cutil/bitvec.cpp @@ -16,9 +16,9 @@ ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "bitvec.h" #include @@ -27,27 +27,30 @@ #include "freelist.h" #include "tprintf.h" -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ static int BitVectorCount = 0; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits) { -/* - ** Parameters: - ** Vector bit vector to be expanded - ** NewNumBits new size of bit vector - ** Globals: none - ** Operation: This routine uses realloc to increase the size of - ** the specified bit vector. - ** Return: New expanded bit vector. - ** Exceptions: none - ** History: Fri Nov 16 10:11:16 1990, DSJ, Created. +/** + * This routine uses realloc to increase the size of + * the specified bit vector. + * + * Globals: + * - none + * + * @param Vector bit vector to be expanded + * @param NewNumBits new size of bit vector + * + * @return New expanded bit vector. + * @note Exceptions: none + * @note History: Fri Nov 16 10:11:16 1990, DSJ, Created. */ +BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits) { return ((BIT_VECTOR) Erealloc(Vector, sizeof(Vector[0]) * WordsInVectorOfSize(NewNumBits))); } /* ExpandBitVector */ @@ -55,18 +58,19 @@ BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits) { /*---------------------------------------------------------------------------*/ void FreeBitVector(BIT_VECTOR BitVector) { -/* - ** Parameters: - ** BitVector bit vector to be freed - ** Globals: - ** BitVectorCount count of number of bit vectors allocated - ** Operation: This routine frees a bit vector. It also decrements - ** the global counter that keeps track of the number of - ** bit vectors allocated. If BitVector is NULL, then - ** the count is printed to stderr. - ** Return: none - ** Exceptions: none - ** History: Tue Oct 23 16:46:09 1990, DSJ, Created. +/** + * This routine frees a bit vector. It also decrements + * the global counter that keeps track of the number of + * bit vectors allocated. If BitVector is NULL, then + * the count is printed to stderr. + * + * Globals: + * - BitVectorCount count of number of bit vectors allocated + * + * @param BitVector bit vector to be freed + * + * @note Exceptions: none + * @note History: Tue Oct 23 16:46:09 1990, DSJ, Created. */ if (BitVector) { Efree(BitVector); @@ -97,18 +101,20 @@ int hamming_distance(uinT32* array1, uinT32* array2, int length) { /*---------------------------------------------------------------------------*/ -BIT_VECTOR NewBitVector(int NumBits) { -/* - ** Parameters: - ** NumBits number of bits in new bit vector - ** Globals: - ** BitVectorCount number of bit vectors allocated - ** Operation: Allocate and return a new bit vector large enough to - ** hold the specified number of bits. - ** Return: New bit vector. - ** Exceptions: none - ** History: Tue Oct 23 16:51:27 1990, DSJ, Created. +/** + * Allocate and return a new bit vector large enough to + * hold the specified number of bits. + * + * Globals: + * - BitVectorCount number of bit vectors allocated + * + * @param NumBits number of bits in new bit vector + * + * @return New bit vector. + * @note Exceptions: none + * @note History: Tue Oct 23 16:51:27 1990, DSJ, Created. */ +BIT_VECTOR NewBitVector(int NumBits) { BitVectorCount++; return ((BIT_VECTOR) Emalloc(sizeof(uinT32) * WordsInVectorOfSize(NumBits))); diff --git a/cutil/bitvec.h b/cutil/bitvec.h index 77f80c1f5e..25c806769c 100644 --- a/cutil/bitvec.h +++ b/cutil/bitvec.h @@ -20,15 +20,15 @@ #include "host.h" -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ -#define BITSINLONG 32 /*no of bits in a long */ +-----------------------------------------------------------------------------*/ +#define BITSINLONG 32 /**< no of bits in a long */ typedef uinT32 *BIT_VECTOR; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #define zero_all_bits(array,length) \ {\ register int index; /*temporary index*/\ diff --git a/cutil/oldheap.cpp b/cutil/oldheap.cpp index 4a381ad80d..708d425240 100644 --- a/cutil/oldheap.cpp +++ b/cutil/oldheap.cpp @@ -15,9 +15,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "oldheap.h" #include "freelist.h" #include "danerror.h" @@ -28,28 +28,25 @@ #define LEFTSON(N) ((N)<<1) #define RIGHTSON(N) ((N)<<1 + 1) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -HEAP *MakeHeap(int Size) { -/* - ** Parameters: - ** Size maximum number of entries in the heap - ** Globals: - ** None - ** Operation: - ** This routine creates and initializes a new heap data - ** structure containing Size elements. In actuality, Size + 1 - ** elements are allocated. The first element, element 0, is - ** unused, this makes the index arithmetic easier. - ** Return: - ** Pointer to the new heap. - ** Exceptions: - ** None - ** History: - ** 3/13/89, DSJ, Created. +/** + * This routine creates and initializes a new heap data + * structure containing Size elements. In actuality, Size + 1 + * elements are allocated. The first element, element 0, is + * unused, this makes the index arithmetic easier. + * + * Globals: + * - None + * + * @param Size maximum number of entries in the heap + * @return Pointer to the new heap. + * @note Exceptions: None + * @note History: 3/13/89, DSJ, Created. */ +HEAP *MakeHeap(int Size) { HEAP *NewHeap; NewHeap = (HEAP *) Emalloc (sizeof (HEAP) + Size * sizeof (HEAPENTRY)); @@ -61,24 +58,22 @@ HEAP *MakeHeap(int Size) { /*---------------------------------------------------------------------------*/ -int HeapPop(HEAP *Heap, FLOAT32 *Key, void *out_ptr) { -/* - ** Parameters: - ** Heap ptr to heap whose top is to be removed and returned - ** Key place to put key of top heap item - ** Data place to put data of top heap item - ** Globals: - ** None - ** Operation: - ** This routine removes the top item on the heap and places - ** its contents into Key and Data. - ** Return: - ** OK if top entry returned, EMPTY if heap is empty - ** Exceptions: - ** None - ** History: - ** 5/10/91, DSJ, Created (Modified from GetTopOfHeap). +/** + * This routine removes the top item on the heap and places + * its contents into Key and Data. + * + * Globals: + * - None + * + * @param Heap ptr to heap whose top is to be removed and returned + * @param Key place to put key of top heap item + * @param Data place to put data of top heap item + * + * @return OK if top entry returned, EMPTY if heap is empty + * @note Exceptions: None + * @note History: 5/10/91, DSJ, Created (Modified from GetTopOfHeap). */ +int HeapPop(HEAP *Heap, FLOAT32 *Key, void *out_ptr) { inT32 Hole; FLOAT32 HoleKey; inT32 Son; @@ -117,18 +112,16 @@ int HeapPop(HEAP *Heap, FLOAT32 *Key, void *out_ptr) { } /* HeapPop */ -/********************************************************************** +/** * HeapPopWorst * * Remove the largest item from the heap. - **********************************************************************/ -int HeapPopWorst(HEAP *Heap, FLOAT32 *Key, void *out_ptr) { -/* - ** Parameters: - ** Heap ptr to heap whose top is to be removed and returned - ** Key place to put key of top heap item - ** Data place to put data of top heap item + * + * @param Heap ptr to heap whose top is to be removed and returned + * @param Key place to put key of top heap item + * @param Data place to put data of top heap item */ +int HeapPopWorst(HEAP *Heap, FLOAT32 *Key, void *out_ptr) { inT32 Index; /*current index */ inT32 Hole; FLOAT32 HoleKey; @@ -173,26 +166,25 @@ int HeapPopWorst(HEAP *Heap, FLOAT32 *Key, void *out_ptr) { /*---------------------------------------------------------------------------*/ -void HeapPush(HEAP *Heap, FLOAT32 Key, void *Data) { -/* - ** Parameters: - ** Heap ptr to heap to store new item in - ** Key numeric key associated with new item - ** Data ptr to data contents of new item - ** Globals: - ** None - ** Operation: - ** This routine stores Data into Heap and associates it - ** with Key. The heap is - ** maintained in such a way that the item with the lowest key - ** is always at the top of the heap. - ** Return: - ** None - ** Exceptions: - ** HEAPFULL error if heap size is exceeded - ** History: - ** 5/10/91, DSJ, Created (Modified version of HeapStore). +/** + * This routine stores Data into Heap and associates it + * with Key. The heap is + * maintained in such a way that the item with the lowest key + * is always at the top of the heap. + * + * Globals: + * - None + * + * @param Heap ptr to heap to store new item in + * @param Key numeric key associated with new item + * @param Data ptr to data contents of new item + * + * @note Exceptions: + * - HEAPFULL error if heap size is exceeded + * + * @note History: 5/10/91, DSJ, Created (Modified version of HeapStore). */ +void HeapPush(HEAP *Heap, FLOAT32 Key, void *Data) { inT32 Item; inT32 Father; @@ -217,24 +209,21 @@ void HeapPush(HEAP *Heap, FLOAT32 Key, void *Data) { /*---------------------------------------------------------------------------*/ -void HeapStore(HEAP *Heap, HEAPENTRY *Entry) { -/* - ** Parameters: - ** Heap ptr to heap to store new item in - ** Entry ptr to item to be stored in Heap - ** Globals: - ** None - ** Operation: - ** This routine stores Entry into Heap. The heap is - ** maintained in such a way that the item with the lowest key - ** is always at the top of the heap. - ** Return: - ** None - ** Exceptions: - ** HEAPFULL error if heap size is exceeded - ** History: - ** 3/13/89, DSJ, Created. +/** + * This routine stores Entry into Heap. The heap is + * maintained in such a way that the item with the lowest key + * is always at the top of the heap. + * + * Globals: + * - None + * + * @param Heap ptr to heap to store new item in + * @param Entry ptr to item to be stored in Heap + * @note Exceptions: + * - HEAPFULL error if heap size is exceeded + * @note History: 3/13/89, DSJ, Created. */ +void HeapStore(HEAP *Heap, HEAPENTRY *Entry) { inT32 Item; inT32 Father; @@ -259,23 +248,21 @@ void HeapStore(HEAP *Heap, HEAPENTRY *Entry) { /*---------------------------------------------------------------------------*/ -int GetTopOfHeap(HEAP *Heap, HEAPENTRY *Entry) { -/* - ** Parameters: - ** Heap ptr to heap whose top is to be removed and returned - ** Entry ptr to heap entry to be filled with top entry on Heap - ** Globals: - ** None - ** Operation: - ** This routine removes the top item on the heap and copies its - ** contents into Entry. - ** Return: - ** OK if top entry returned, EMPTY if heap is empty - ** Exceptions: - ** None - ** History: - ** 3/13/89, DSJ, Created. +/** + * This routine removes the top item on the heap and copies its + * contents into Entry. + * + * @param Heap ptr to heap whose top is to be removed and returned + * @param Entry ptr to heap entry to be filled with top entry on Heap + * + * Globals: + * - None + * + * @return OK if top entry returned, EMPTY if heap is empty + * @note Exceptions: None + * @note History: 3/13/89, DSJ, Created. */ +int GetTopOfHeap(HEAP *Heap, HEAPENTRY *Entry) { inT32 Hole; FLOAT32 HoleKey; inT32 Son; @@ -314,20 +301,22 @@ int GetTopOfHeap(HEAP *Heap, HEAPENTRY *Entry) { /*---------------------------------------------------------------------------*/ -void FreeHeapData(HEAP *Heap, void_dest destructor) { -/* - ** Parameters: - ** Heap heap whose data is to be freed - ** Deallocator function to be used to deallocate data - ** Globals: none - ** Operation: This routine is similar to FreeHeap in that it - ** deallocates the memory consumed by the heap. However, it - ** also calls Deallocator for each item in the heap so that - ** this data is also deallocated. - ** Return: none - ** Exceptions: none - ** History: Tue May 15 08:52:04 1990, DSJ, Created. +/** + * This routine is similar to FreeHeap in that it + * deallocates the memory consumed by the heap. However, it + * also calls Deallocator for each item in the heap so that + * this data is also deallocated. + * + * @param Heap heap whose data is to be freed + * @param Deallocator function to be used to deallocate data + * + * Globals: + * - None + * + * @note Exceptions: none + * @note History: Tue May 15 08:52:04 1990, DSJ, Created. */ +void FreeHeapData(HEAP *Heap, void_dest destructor) { HEAPENTRY Entry; while (GetTopOfHeap (Heap, &Entry) != EMPTY) diff --git a/cutil/oldheap.h b/cutil/oldheap.h index e9f1cf9d49..5ada445646 100644 --- a/cutil/oldheap.h +++ b/cutil/oldheap.h @@ -18,9 +18,9 @@ #ifndef HEAP_H #define HEAP_H -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "general.h" #include "cutil.h" @@ -48,9 +48,9 @@ typedef struct HEAP; -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Macros -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #define FreeHeap(H) memfree(H) #define MaxSizeOfHeap(H) (H->Size) #define SizeOfHeap(H) (H->FirstFree - 1) @@ -66,9 +66,9 @@ HEAP; #define HeapKeyFor(H,E) ((H)->Entry[(E)+1].Key) #define HeapDataFor(H,E) ((H)->Entry[(E)+1].Data) -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ HEAP *MakeHeap(int Size); int HeapPop(HEAP *Heap, FLOAT32 *Key, void *out_ptr); diff --git a/dict/choices.cpp b/dict/choices.cpp index 5e6a7d6cfd..9b206e13ea 100644 --- a/dict/choices.cpp +++ b/dict/choices.cpp @@ -44,7 +44,7 @@ freechoice, CHOICEBLOCK, "A_CHOICE", choicecount) /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** +/** * append_char_choice * * Create a new choice record. Store the string value in a safe place. @@ -52,7 +52,7 @@ freechoice, CHOICEBLOCK, "A_CHOICE", choicecount) * * NB - This is only used by matchers, so permuter is always NO_PERM * SPC 16/9/92 - **********************************************************************/ + */ CHOICES append_char_choice(CHOICES ratings, const char *string, const char *lengths, @@ -68,12 +68,12 @@ CHOICES append_char_choice(CHOICES ratings, return (ratings); } -/********************************************************************** +/** * copy_choices * * Copy a list of choices. This means that there will be two copies * in memory. - **********************************************************************/ + */ CHOICES copy_choices(CHOICES choices) { CHOICES l; CHOICES result = NIL; @@ -94,12 +94,12 @@ CHOICES copy_choices(CHOICES choices) { return (reverse_d (result)); } -/********************************************************************** +/** * clone_choice * * Copy the contents of the given values to the corresponding values in * a given choice replacing any previous values it might have had. - **********************************************************************/ + */ void clone_choice(A_CHOICE *choice, const char *string, const char *lengths, float rating, float certainty, inT8 permuter, bool fragment_mark, @@ -118,11 +118,11 @@ void clone_choice(A_CHOICE *choice, const char *string, fragment_lengths ? strsave(fragment_lengths) : NULL; } -/********************************************************************** +/** * clear_choice * * Set the fields in this choice to be defaulted bad initial values. - **********************************************************************/ + */ void clear_choice(A_CHOICE *choice) { choice->string = NULL; choice->lengths = NULL; @@ -133,11 +133,11 @@ void clear_choice(A_CHOICE *choice) { } -/********************************************************************** +/** * free_choice * * Free up the memory taken by one choice rating. - **********************************************************************/ + */ void free_choice(void *arg) { //LIST choice) A_CHOICE *this_choice; LIST choice = (LIST) arg; @@ -154,13 +154,13 @@ void free_choice(void *arg) { //LIST choice) } } -/********************************************************************** +/** * get_best_free_other * * Returns the best of two choices and frees the other (worse) choice. * A choice is better if it has a non-NULL string and has a lower rating * than the other choice. - **********************************************************************/ + */ A_CHOICE *get_best_free_other(A_CHOICE *choice_1, A_CHOICE *choice_2) { if (!choice_1) return choice_2; if (!choice_2) return choice_1; @@ -174,11 +174,11 @@ A_CHOICE *get_best_free_other(A_CHOICE *choice_1, A_CHOICE *choice_2) { } } -/********************************************************************** +/** * new_choice * * Create a new choice record. Store the string value in a safe place. - **********************************************************************/ + */ A_CHOICE *new_choice(const char *string, const char *lengths, float rating, @@ -216,11 +216,11 @@ A_CHOICE *new_choice(const char *string, } -/********************************************************************** +/** * print_choices * * Print the rating for a particular blob or word. - **********************************************************************/ + */ namespace tesseract { void Dict::print_choices(const char *label, CHOICES choices) { // List of (A_CHOICE*). @@ -235,11 +235,11 @@ void Dict::print_choices(const char *label, tprintf("\n"); } -/********************************************************************** +/** * print_word_choice * * Print the string in a human-readable format and ratings for a word. - **********************************************************************/ + */ void Dict::print_word_choice(const char *label, A_CHOICE* choice) { tprintf("%s : ", label); if (choice == NULL) { @@ -251,12 +251,12 @@ void Dict::print_word_choice(const char *label, A_CHOICE* choice) { } } -/********************************************************************** +/** * print_word_string * * Print the string in a human-readable format. * The output is not newline terminated. - **********************************************************************/ + */ void Dict::print_word_string(const char* str) { int step = 1; for (int i = 0; str[i] != '\0'; i += step) { diff --git a/dict/choices.h b/dict/choices.h index e65c0426f9..b733fb379d 100644 --- a/dict/choices.h +++ b/dict/choices.h @@ -56,119 +56,123 @@ typedef struct choicestruct char permuter; inT8 config; char *string; - char *lengths; // length of each unichar in the string + char *lengths; //< length of each unichar in the string int script_id; - char *fragment_lengths; // length of fragments for each unichar in string - bool fragment_mark; // if true, indicates that this choice - // was chosen over a better one that - // contained a fragment + char *fragment_lengths; //< length of fragments for each unichar in string + /** + * if true, indicates that this choice + * was chosen over a better one that + * contained a fragment + */ + bool fragment_mark; + } A_CHOICE; /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** +/** * best_string * * Return the string corresponding to the best choice. - **********************************************************************/ + */ #define best_string(choices) \ (first_node (choices) ? ((A_CHOICE*) (first_node (choices)))->string : NULL) -/********************************************************************** +/** * best_lengths * * Return the lengths corresponding to the best choice. - **********************************************************************/ + */ #define best_lengths(choices) \ (first_node (choices) ? ((A_CHOICE*) (first_node (choices)))->lengths : NULL) -/********************************************************************** +/** * best_rating * * Return the rating of the best choice. - **********************************************************************/ + */ #define best_rating(choices) \ (((A_CHOICE*) (first_node (choices)))->rating) -/********************************************************************** +/** * best_certainty * * Return the certainty of the best choice. - **********************************************************************/ + */ #define best_certainty(choices) \ (((A_CHOICE*) (first_node (choices)))->certainty) -/********************************************************************** +/** * class_rating * * Return the rating of a given character class. - **********************************************************************/ + */ #define class_rating(choice) \ (((A_CHOICE*) (choice))->rating) -/********************************************************************** +/** * class_certainty * * Return the certainty of a given character class. - **********************************************************************/ + */ #define class_certainty(choice) \ (((A_CHOICE*) (choice))->certainty) -/********************************************************************** +/** * class_string * * Return the string of a given character class. - **********************************************************************/ + */ #define class_string(choice) \ (((A_CHOICE*) (choice))->string) -/********************************************************************** +/** * class_lengths * * Return the lengths of a given character class. - **********************************************************************/ + */ #define class_lengths(choice) \ (((A_CHOICE*) (choice))->lengths) -/********************************************************************** +/** * class_permuter * * Return the permuter of a given character class. - **********************************************************************/ + */ #define class_permuter(choice) \ (((A_CHOICE*) (choice))->permuter) -/********************************************************************** +/** * class_config * * Return the config of a given character class. - **********************************************************************/ + */ #define class_config(choice) \ (((A_CHOICE*) (choice))->config) -/********************************************************************** +/** * class_script * * Return the script of a given character class. - **********************************************************************/ + */ #define class_script_id(choice) \ (((A_CHOICE*) (choice))->script_id) -/********************************************************************** +/** * free_choices * * Free a list of choices. - **********************************************************************/ + */ #define free_choices(c) \ destroy_nodes ((c), free_choice) -/********************************************************************** +/** * print_bold * * Print a string in bold type by using escape sequences. This only * works for certain output devices. - **********************************************************************/ + */ #define print_bold(string) \ cprintf ("\033&dB%s\033&d@", string) @@ -177,17 +181,17 @@ cprintf ("\033&dB%s\033&d@", string) F u n c t i o n s ----------------------------------------------------------------------*/ -// Returns true if fragment_mark is set for the given choice. +/// Returns true if fragment_mark is set for the given choice. inline bool class_fragment_mark(A_CHOICE *choice) { return choice->fragment_mark; } -// Sets fragment_mark of choice to the given value. +/// Sets fragment_mark of choice to the given value. inline void set_class_fragment_mark(A_CHOICE *choice, bool mark) { choice->fragment_mark = mark; } -// Returns fragment_lengths of the given class. +/// Returns fragment_lengths of the given class. inline const char *class_fragment_lengths(A_CHOICE *choice) { return choice->fragment_lengths; } @@ -202,13 +206,13 @@ CHOICES append_char_choice(CHOICES ratings, CHOICES copy_choices(CHOICES choices); -// Copy the given values into corresponding fields of choice. +/// Copy the given values into corresponding fields of choice. void clone_choice(A_CHOICE *choice, const char *string, const char *lengths, float rating, float certainty, inT8 permuter, bool fragment_mark, const char *fragment_lengths); -// Copy the contents of choice_1 into choice_2. +/// Copy the contents of choice_1 into choice_2. inline void clone_choice(A_CHOICE *choice_2, A_CHOICE *choice_1) { clone_choice(choice_2, class_string(choice_1), class_lengths(choice_1), class_rating(choice_1), class_certainty(choice_1), diff --git a/dict/dawg.h b/dict/dawg.h index da0c57b464..f711021f52 100644 --- a/dict/dawg.h +++ b/dict/dawg.h @@ -117,23 +117,23 @@ static const char kWildcard[] = "*"; C l a s s e s a n d S t r u c t s ----------------------------------------------------------------------*/ // -// Abstract class (an interface) that declares methods needed by the -// various tesseract classes to operate on SquishedDawg and Trie objects. -// -// This class initializes all the edge masks (since their usage by -// SquishedDawg and Trie is identical) and implements simple accessors -// for each of the fields encoded in an EDGE_RECORD. -// This class also implements word_in_dawg() and check_for_words() -// (since they use only the public methods of SquishedDawg and Trie -// classes that are inherited from the Dawg base class). +/// Abstract class (an interface) that declares methods needed by the +/// various tesseract classes to operate on SquishedDawg and Trie objects. +/// +/// This class initializes all the edge masks (since their usage by +/// SquishedDawg and Trie is identical) and implements simple accessors +/// for each of the fields encoded in an EDGE_RECORD. +/// This class also implements word_in_dawg() and check_for_words() +/// (since they use only the public methods of SquishedDawg and Trie +/// classes that are inherited from the Dawg base class). // class Dawg { public: - // Magic number to determine endianness when reading the Dawg from file. + /// Magic number to determine endianness when reading the Dawg from file. static const inT16 kDawgMagicNumber = 42; - // A special unichar id that indicates that any appropriate pattern - // (e.g.dicitonary word, 0-9 digit, etc) can be inserted instead - // Used for expressing patterns in punctuation and number Dawgs. + /// A special unichar id that indicates that any appropriate pattern + /// (e.g.dicitonary word, 0-9 digit, etc) can be inserted instead + /// Used for expressing patterns in punctuation and number Dawgs. static const UNICHAR_ID kPatternUnicharID = 0; inline DawgType type() const { return type_; } @@ -142,78 +142,78 @@ class Dawg { virtual ~Dawg() {}; - // Returns true if the given word is in the Dawg. + /// Returns true if the given word is in the Dawg. bool word_in_dawg(const WERD_CHOICE &word) const; - // Checks the Dawg for the words that are listed in the requested file. - // Returns the number of words in the given file missing from the Dawg. + /// Checks the Dawg for the words that are listed in the requested file. + /// Returns the number of words in the given file missing from the Dawg. int check_for_words(const char *filename, const UNICHARSET &unicharset, bool enable_wildcard) const; // Pure virtual function that should be implemented by the derived classes. - // Returns the edge that corresponds to the letter out of this node. + /// Returns the edge that corresponds to the letter out of this node. virtual EDGE_REF edge_char_of(NODE_REF node, UNICHAR_ID unichar_id, bool word_end) const = 0; - // Fills the given NodeChildVector with all the unichar ids (and the - // corresponding EDGE_REFs) for which there is an edge out of this node. + /// Fills the given NodeChildVector with all the unichar ids (and the + /// corresponding EDGE_REFs) for which there is an edge out of this node. virtual void unichar_ids_of(NODE_REF node, NodeChildVector *vec) const = 0; - // Returns the next node visited by following the edge - // indicated by the given EDGE_REF. + /// Returns the next node visited by following the edge + /// indicated by the given EDGE_REF. virtual NODE_REF next_node(EDGE_REF edge_ref) const = 0; - // Returns true if the edge indicated by the given EDGE_REF - // marks the end of a word. + /// Returns true if the edge indicated by the given EDGE_REF + /// marks the end of a word. virtual bool end_of_word(EDGE_REF edge_ref) const = 0; - // Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. + /// Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. virtual UNICHAR_ID edge_letter(EDGE_REF edge_ref) const = 0; - // Prints the contents of the node indicated by the given NODE_REF. - // At most max_num_edges will be printed. + /// Prints the contents of the node indicated by the given NODE_REF. + /// At most max_num_edges will be printed. virtual void print_node(NODE_REF node, int max_num_edges) const = 0; protected: Dawg() {} - // Returns the next node visited by following this edge. + /// Returns the next node visited by following this edge. inline NODE_REF next_node_from_edge_rec(const EDGE_RECORD &edge_rec) const { return ((edge_rec & next_node_mask_) >> next_node_start_bit_); } - // Returns the direction flag of this edge. + /// Returns the direction flag of this edge. inline int direction_from_edge_rec(const EDGE_RECORD &edge_rec) const { return ((edge_rec & (DIRECTION_FLAG << flag_start_bit_))) ? BACKWARD_EDGE : FORWARD_EDGE; } - // Returns true if this edge marks the end of a word. + /// Returns true if this edge marks the end of a word. inline bool end_of_word_from_edge_rec(const EDGE_RECORD &edge_rec) const { return (edge_rec & (WERD_END_FLAG << flag_start_bit_)) != 0; } - // Returns UNICHAR_ID recorded in this edge. + /// Returns UNICHAR_ID recorded in this edge. inline UNICHAR_ID unichar_id_from_edge_rec( const EDGE_RECORD &edge_rec) const { return ((edge_rec & letter_mask_) >> LETTER_START_BIT); } - // Sets the next node link for this edge in the Dawg. + /// Sets the next node link for this edge in the Dawg. inline void set_next_node_in_edge_rec( EDGE_RECORD *edge_rec, EDGE_REF value) { *edge_rec &= (~next_node_mask_); *edge_rec |= ((value << next_node_start_bit_) & next_node_mask_); } - // Sets this edge record to be the last one in a sequence of edges. + /// Sets this edge record to be the last one in a sequence of edges. inline void set_last_flag_in_edge_rec(EDGE_RECORD *edge_rec) { *edge_rec |= (LAST_FLAG << flag_start_bit_); } - // Sequentially compares the given values of unichar ID, next node - // and word end marker with the values in the given EDGE_RECORD. - // Returns: 1 if at any step the given input value exceeds - // that of edge_rec (and all the values already - // checked are the same) - // 0 if edge_rec_match() returns true - // -1 otherwise + /// Sequentially compares the given values of unichar ID, next node + /// and word end marker with the values in the given EDGE_RECORD. + /// Returns: 1 if at any step the given input value exceeds + /// that of edge_rec (and all the values already + /// checked are the same) + /// 0 if edge_rec_match() returns true + /// -1 otherwise inline int given_greater_than_edge_rec(NODE_REF next_node, bool word_end, UNICHAR_ID unichar_id, @@ -232,9 +232,9 @@ class Dawg { } return -1; } - // Returns true if all the values are equal (any value matches - // next_node if next_node == NO_EDGE, any value matches word_end - // if word_end is false). + /// Returns true if all the values are equal (any value matches + /// next_node if next_node == NO_EDGE, any value matches word_end + /// if word_end is false). inline bool edge_rec_match(NODE_REF next_node, bool word_end, UNICHAR_ID unichar_id, @@ -246,23 +246,23 @@ class Dawg { (!word_end || (word_end == other_word_end))); } - // Sets type_, lang_, perm_, unicharset_size_. - // Initializes the values of various masks from unicharset_size_. + /// Sets type_, lang_, perm_, unicharset_size_. + /// Initializes the values of various masks from unicharset_size_. void init(DawgType type, const STRING &lang, PermuterType perm, int unicharset_size); - // Matches all of the words that are represented by this string. - // If wilcard is set to something other than INVALID_UNICHAR_ID, - // the *'s in this string are interpreted as wildcards. - // WERD_CHOICE param is not passed by const so that wildcard searches - // can modify it and work without having to copy WERD_CHOICEs. + /// Matches all of the words that are represented by this string. + /// If wilcard is set to something other than INVALID_UNICHAR_ID, + /// the *'s in this string are interpreted as wildcards. + /// WERD_CHOICE param is not passed by const so that wildcard searches + /// can modify it and work without having to copy WERD_CHOICEs. bool match_words(WERD_CHOICE *word, inT32 index, NODE_REF node, UNICHAR_ID wildcard) const; // Member Variables. DawgType type_; STRING lang_; - // Permuter code that should be used if the word is found in this Dawg. + /// Permuter code that should be used if the word is found in this Dawg. PermuterType perm_; // Variables to construct various edge masks. Formerly: // #define NEXT_EDGE_MASK (inT64) 0xfffffff800000000i64 @@ -277,8 +277,8 @@ class Dawg { }; // -// DawgInfo struct and DawgInfoVector class are used for -// storing information about the current Dawg search state. +/// DawgInfo struct and DawgInfoVector class are used for +/// storing information about the current Dawg search state. // struct DawgInfo { DawgInfo() : dawg_index(-1), ref(NO_EDGE) {} @@ -292,7 +292,7 @@ struct DawgInfo { }; class DawgInfoVector : public GenericVector { public: - // Overload destructor, since clear() does not delete data_[] any more. + /// Overload destructor, since clear() does not delete data_[] any more. ~DawgInfoVector() { if (size_reserved_ > 0) { delete[] data_; @@ -300,12 +300,12 @@ class DawgInfoVector : public GenericVector { size_reserved_ = 0; } } - // Overload clear() in order to avoid allocating/deallocating memory - // when clearing the vector and re-inserting entries into it later. + /// Overload clear() in order to avoid allocating/deallocating memory + /// when clearing the vector and re-inserting entries into it later. void clear() { size_used_ = 0; } - // Adds an entry for the given dawg_index with the given node to the vec. - // Returns false if the same entry already exists in the vector, - // true otherwise. + /// Adds an entry for the given dawg_index with the given node to the vec. + /// Returns false if the same entry already exists in the vector, + /// true otherwise. inline bool add_unique(const DawgInfo &new_info, const char *debug_msg) { for (int i = 0; i < size_used_; ++i) { if (data_[i] == new_info) return false; @@ -317,9 +317,9 @@ class DawgInfoVector : public GenericVector { } return true; } - // Removes an entry that equals to the given DawgInfo. - // This function assumes that the entries in the vector are unique. - // Returns true if an entry was found and removed. + /// Removes an entry that equals to the given DawgInfo. + /// This function assumes that the entries in the vector are unique. + /// Returns true if an entry was found and removed. inline bool remove(const DawgInfo &info) { for (int i = 0; i < size_used_; ++i) { if (data_[i] == info) { @@ -335,12 +335,12 @@ class DawgInfoVector : public GenericVector { }; // -// Concrete class that can operate on a compacted (squished) Dawg (read, -// search and write to file). This class is read-only in the sense that -// new words can not be added to an instance of SquishedDawg. -// The underlying representation of the nodes and edges in SquishedDawg -// is stored as a contiguous EDGE_ARRAY (read from file or given as an -// argument to the constructor). +/// Concrete class that can operate on a compacted (squished) Dawg (read, +/// search and write to file). This class is read-only in the sense that +/// new words can not be added to an instance of SquishedDawg. +/// The underlying representation of the nodes and edges in SquishedDawg +/// is stored as a contiguous EDGE_ARRAY (read from file or given as an +/// argument to the constructor). // class SquishedDawg : public Dawg { public: @@ -369,12 +369,12 @@ class SquishedDawg : public Dawg { } ~SquishedDawg(); - // Returns the edge that corresponds to the letter out of this node. + /// Returns the edge that corresponds to the letter out of this node. EDGE_REF edge_char_of(NODE_REF node, UNICHAR_ID unichar_id, bool word_end) const; - // Fills the given NodeChildVector with all the unichar ids (and the - // corresponding EDGE_REFs) for which there is an edge out of this node. + /// Fills the given NodeChildVector with all the unichar ids (and the + /// corresponding EDGE_REFs) for which there is an edge out of this node. void unichar_ids_of(NODE_REF node, NodeChildVector *vec) const { EDGE_REF edge = node; if (!edge_occupied(edge) || edge == NO_EDGE) return; @@ -384,83 +384,83 @@ class SquishedDawg : public Dawg { } while (!last_edge(edge++)); } - // Returns the next node visited by following the edge - // indicated by the given EDGE_REF. + /// Returns the next node visited by following the edge + /// indicated by the given EDGE_REF. NODE_REF next_node(EDGE_REF edge) const { return next_node_from_edge_rec((edges_[edge])); } - // Returns true if the edge indicated by the given EDGE_REF - // marks the end of a word. + /// Returns true if the edge indicated by the given EDGE_REF + /// marks the end of a word. bool end_of_word(EDGE_REF edge_ref) const { return end_of_word_from_edge_rec((edges_[edge_ref])); } - // Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. + /// Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. UNICHAR_ID edge_letter(EDGE_REF edge_ref) const { return unichar_id_from_edge_rec((edges_[edge_ref])); } - // Prints the contents of the node indicated by the given NODE_REF. - // At most max_num_edges will be printed. + /// Prints the contents of the node indicated by the given NODE_REF. + /// At most max_num_edges will be printed. void print_node(NODE_REF node, int max_num_edges) const; - // Writes the squished/reduced Dawg to a file. + /// Writes the squished/reduced Dawg to a file. void write_squished_dawg(const char *filename); private: - // Sets the next node link for this edge. + /// Sets the next node link for this edge. inline void set_next_node(EDGE_REF edge_ref, EDGE_REF value) { set_next_node_in_edge_rec(&(edges_[edge_ref]), value); } - // Sets the edge to be empty. + /// Sets the edge to be empty. inline void set_empty_edge(EDGE_REF edge_ref) { (edges_[edge_ref] = next_node_mask_); } - // Goes through all the edges and clears each one out. + /// Goes through all the edges and clears each one out. inline void clear_all_edges() { for (int edge = 0; edge < num_edges_; edge++) set_empty_edge(edge); } - // Clears the last flag of this edge. + /// Clears the last flag of this edge. inline void clear_last_flag(EDGE_REF edge_ref) { (edges_[edge_ref] &= ~(LAST_FLAG << flag_start_bit_)); } - // Returns true if this edge is in the forward direction. + /// Returns true if this edge is in the forward direction. inline bool forward_edge(EDGE_REF edge_ref) const { return (edge_occupied(edge_ref) && (FORWARD_EDGE == direction_from_edge_rec(edges_[edge_ref]))); } - // Returns true if this edge is in the backward direction. + /// Returns true if this edge is in the backward direction. inline bool backward_edge(EDGE_REF edge_ref) const { return (edge_occupied(edge_ref) && (BACKWARD_EDGE == direction_from_edge_rec(edges_[edge_ref]))); } - // Returns true if the edge spot in this location is occupied. + /// Returns true if the edge spot in this location is occupied. inline bool edge_occupied(EDGE_REF edge_ref) const { return (edges_[edge_ref] != next_node_mask_); } - // Returns true if this edge is the last edge in a sequence. + /// Returns true if this edge is the last edge in a sequence. inline bool last_edge(EDGE_REF edge_ref) const { return (edges_[edge_ref] & (LAST_FLAG << flag_start_bit_)) != 0; } - // Counts and returns the number of forward edges in this node. + /// Counts and returns the number of forward edges in this node. inT32 num_forward_edges(NODE_REF node) const; - // Reads SquishedDawg from a file. + /// Reads SquishedDawg from a file. void read_squished_dawg(FILE *file, DawgType type, const STRING &lang, PermuterType perm); - // Prints the contents of an edge indicated by the given EDGE_REF. + /// Prints the contents of an edge indicated by the given EDGE_REF. void print_edge(EDGE_REF edge) const; - // Prints the contents of the SquishedDawg. + /// Prints the contents of the SquishedDawg. void print_all(const char* msg) { tprintf("\n__________________________\n%s\n", msg); for (int i = 0; i < num_edges_; ++i) print_edge(i); tprintf("__________________________\n"); } - // Constructs a mapping from the memory node indices to disk node indices. + /// Constructs a mapping from the memory node indices to disk node indices. NODE_MAP build_node_map(inT32 *num_nodes) const; diff --git a/dict/dict.h b/dict/dict.h index 6e7b01ea98..edf5c795e8 100644 --- a/dict/dict.h +++ b/dict/dict.h @@ -39,7 +39,7 @@ extern INT_VAR_H(hyphen_debug_level, 0, "Debug level for hyphenated words."); #define GOOD_WERD 1.1 #define OK_WERD 1.3125 -// Struct used to hold temporary information about fragments. +/** Struct used to hold temporary information about fragments. */ struct CHAR_FRAGMENT_INFO { UNICHAR_ID unichar_id; const CHAR_FRAGMENT *fragment; @@ -67,7 +67,7 @@ struct DawgArgs { DawgInfoVector *updated_active_dawgs; DawgInfoVector *updated_constraints; PermuterType permuter; - float rating_margin; // prunning margin ratio + float rating_margin; /**< pruning margin ratio */ float rating_array[MAX_WERD_LENGTH]; }; @@ -87,78 +87,79 @@ class Dict { /* hyphen.cpp ************************************************************/ - // Returns true if we've recorded the beginning of a hyphenated word. + /// Returns true if we've recorded the beginning of a hyphenated word. inline bool hyphenated() { return !last_word_on_line_ && hyphen_word_; } - // Size of the base word (the part on the line before) of a hyphenated word. + /// Size of the base word (the part on the line before) of a hyphenated word. inline int hyphen_base_size() { return this->hyphenated() ? hyphen_word_->length() : 0; } - // If this word is hyphenated copy the base word (the part on - // the line before) of a hyphenated word into the given word. - // This function assumes that word is not NULL. + /// If this word is hyphenated copy the base word (the part on + /// the line before) of a hyphenated word into the given word. + /// This function assumes that word is not NULL. inline void copy_hyphen_info(WERD_CHOICE *word) { if (this->hyphenated()) { *word = *hyphen_word_; if (hyphen_debug_level) word->print("copy_hyphen_info: "); } } - // Erase the unichar ids corresponding to the portion of the word - // from the previous line. The word is not changed if it is not - // split between lines and hyphenated. + /// Erase the unichar ids corresponding to the portion of the word + /// from the previous line. The word is not changed if it is not + /// split between lines and hyphenated. inline void remove_hyphen_head(WERD_CHOICE *word) { if (this->hyphenated()) { word->remove_unichar_ids(0, hyphen_word_->length()); if (hyphen_debug_level) hyphen_word_->print("remove_hyphen_head: "); } } - // Check whether the word has a hyphen at the end. + /// Check whether the word has a hyphen at the end. inline bool has_hyphen_end(const WERD_CHOICE &word) { int word_index = word.length() - 1; return (last_word_on_line_ && word_index > 0 && word.unichar_id(word_index) == hyphen_unichar_id_); } - // Unless the previous word was the last one on the line, and the current - // one is not (thus it is the first one on the line), erase hyphen_word_, - // clear hyphen_active_dawgs_, hyphen_constraints_ update last_word_on_line_. + /// Unless the previous word was the last one on the line, and the current + /// one is not (thus it is the first one on the line), erase hyphen_word_, + /// clear hyphen_active_dawgs_, hyphen_constraints_ update last_word_on_line_. void reset_hyphen_vars(bool last_word_on_line); - // Update hyphen_word_, and copy the given DawgInfoVectors into - // hyphen_active_dawgs_ and hyphen_constraints_. + /// Update hyphen_word_, and copy the given DawgInfoVectors into + /// hyphen_active_dawgs_ and hyphen_constraints_. void set_hyphen_word(const WERD_CHOICE &word, const DawgInfoVector &active_dawgs, const DawgInfoVector &constraints); /* permdawg.cpp ************************************************************/ - // If new_rating < best_choice->rating(), copy word int best_choice - // and update rating and permuter of best_choice to the new given values. + /// If new_rating < best_choice->rating(), copy word int best_choice + /// and update rating and permuter of best_choice to the new given values. inline void update_best_choice( const WERD_CHOICE &word, WERD_CHOICE *best_choice) { if (word.rating() < best_choice->rating()) { *best_choice = word; } } - // Fill the given active_dawgs vector with dawgs that could contain the - // beginning of the word. If hyphenated() returns true, copy the entries - // from hyphen_active_dawgs_ instead. + /// Fill the given active_dawgs vector with dawgs that could contain the + /// beginning of the word. If hyphenated() returns true, copy the entries + /// from hyphen_active_dawgs_ instead. void init_active_dawgs(DawgInfoVector *active_dawgs); - // If hyphenated() returns true, copy the entries from hyphen_constraints_ - // into the given constraints vector. + /// If hyphenated() returns true, copy the entries from hyphen_constraints_ + /// into the given constraints vector. void init_constraints(DawgInfoVector *constraints); - // Recursively explore all the possible character combinations in - // the given char_choices. Use go_deeper_dawg_fxn() to explore all the - // dawgs in the dawgs_ vector in parallel and discard invalid words. - // - // Allocate and return a WERD_CHOICE with the best valid word found. + /// Recursively explore all the possible character combinations in + /// the given char_choices. Use go_deeper_dawg_fxn() to explore all the + /// dawgs in the dawgs_ vector in parallel and discard invalid words. + /// + /// Allocate and return a WERD_CHOICE with the best valid word found. WERD_CHOICE *dawg_permute_and_select( const BLOB_CHOICE_LIST_VECTOR &char_choices, float rating_limit); void adjust_word(WERD_CHOICE *best_choice, float *certainty_array); - // If the choice being composed so far could be a dictionary word - // and we have not reached the end of the word keep exploring the - // char_choices further. - // Also: - // -- set hyphen word if needed - // -- if word_ending is true and word is better than best_choice - // copy word to best_choice log new word choice + /// If the choice being composed so far could be a dictionary word + /// and we have not reached the end of the word keep exploring the + /// char_choices further. + /// + /// Also: + /// - set hyphen word if needed + /// - if word_ending is true and word is better than best_choice + /// copy word to best_choice log new word choice void go_deeper_dawg_fxn( const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info, @@ -173,17 +174,19 @@ class Dict { float* rating_limit, WERD_CHOICE *raw_choice, BOOL8 *any_alpha); - const char* choose_il1(const char *first_char, //first choice - const char *second_char, //second choice - const char *third_char, //third choice - const char *prev_char, //prev in word - const char *next_char, //next in word - const char *next_next_char); //after next next in word + const char* choose_il1(const char *first_char, //< first choice + const char *second_char, //< second choice + const char *third_char, //< third choice + const char *prev_char, //< prev in word + const char *next_char, //< next in word + const char *next_next_char); //< after next next in word + /// @return NO_PERM for words with digits int valid_word(const WERD_CHOICE &word) { - return valid_word(word, false); // return NO_PERM for words with digits + return valid_word(word, false); } + /// @return NUMBER_PERM for valid numbers int valid_word_or_number(const WERD_CHOICE &word) { - return valid_word(word, true); // return NUMBER_PERM for valid numbers + return valid_word(word, true); } int valid_word(const WERD_CHOICE &word, bool numbers_ok); bool valid_punctuation(const WERD_CHOICE &word); @@ -204,29 +207,29 @@ class Dict { WERD_CHOICE *permute_compound_words( const BLOB_CHOICE_LIST_VECTOR &char_choices, float rating_limit); - // checks if the dominant word script, if there is one, is same as target. + /// checks if the dominant word script, if there is one, is same as target. bool word_script_eq(const BLOB_CHOICE_LIST_VECTOR &char_choices, int target_script_id); - // Incoporate segmentation cost into word rating + /// Incoporate segmentation cost into word rating void incorporate_segcost(WERD_CHOICE* word); - // checks for script-consistent permutations + /// checks for script-consistent permutations WERD_CHOICE *permute_script_words( const BLOB_CHOICE_LIST_VECTOR &char_choices); WERD_CHOICE *top_fragments_permute_and_select( const BLOB_CHOICE_LIST_VECTOR &char_choices, float rating_limit); - // If the choice being composed so far could be better - // than best_choice keep exploring char_choices. - // If we have reached the end of the word and word is better than - // best_choice, copy word to best_choice and log a new word choice. + /// If the choice being composed so far could be better + /// than best_choice keep exploring char_choices. + /// If we have reached the end of the word and word is better than + /// best_choice, copy word to best_choice and log a new word choice. void go_deeper_top_fragments_fxn( const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info, bool word_ending, WERD_CHOICE *word, float certainties[], float *limit, WERD_CHOICE *best_choice, void *more_args); - // Semi-generic functions used by multiple permuters. + /// Semi-generic functions used by multiple permuters. bool fragment_state_okay(UNICHAR_ID curr_unichar_id, float curr_rating, float curr_certainty, const CHAR_FRAGMENT_INFO *prev_char_frag_info, @@ -254,7 +257,7 @@ class Dict { float *limit, WERD_CHOICE *best_choice, void *more_args); - // Pointer to go_deeper function that will be modified by various permuters. + /// Pointer to go_deeper function that will be modified by various permuters. void (Dict::*go_deeper_fxn_)(const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, int char_choice_index, @@ -329,67 +332,68 @@ class Dict { const Dawg *dawg); /* dawg.cpp ****************************************************************/ - // Returns the maximal permuter code (from ccstruct/ratngs.h) if in light - // of the current state the letter at word_index in the given word - // is allowed according to at least one of the dawgs in dawgs_, - // otherwise returns NO_PERM. - // - // The state is described by void_dawg_args, which are interpreted as - // DawgArgs and contain two relevant input vectors: active_dawgs and - // constraints. Each entry in the active_dawgs vector contains an index - // into the dawgs_ vector and an EDGE_REF that indicates the last edge - // followed in the dawg. Each entry in the constraints vector contains - // an index into the dawgs_ vector and an EDGE_REF that indicates an edge - // in a pattern dawg followed to match a pattern. Currently constraints - // are used to save the state of punctuation dawgs after leading - // punctuation was found. - // - // Input: - // At word_index 0 dawg_args->active_dawgs should contain an entry for each - // dawg whose type has a bit set in kBeginningDawgsType, - // dawg_args->constraints should be empty. EDGE_REFs in active_dawgs and - // constraints vectors should be initialized to NO_EDGE. If hyphen state - // needs to be applied, initial dawg_args->active_dawgs and - // dawg_args->constrains can be copied from the saved hyphen state - // (maintained by Dict). - // For word_index > 0 the corresponding state (active_dawgs and constraints) - // can be obtained from dawg_args->updated_* passed to def_letter_is_okay - // for word_index-1. - // Note: the function assumes that active_dags, constraints and updated_* - // member variables of dawg_args are not NULL. - // - // Output: - // The function fills in dawg_args->updated_active_dawgs vector with the - // entries for dawgs that contain the word up to the letter at word_index. - // The new constraints (if any) are added to dawg_args->updated_constraints, - // the constraints from dawg_args->constraints are also copied into it. - // - // Detailed description: - // In order to determine whether the word is still valid after considering - // all the letters up to the one at word_index the following is done for - // each entry in dawg_args->active_dawgs: - // - // -- next starting node is obtained from entry.ref and edge_char_of() is - // called to obtain the next edge - // -- if a valid edge is found, the function returns the updated permuter - // code true and an entry [entry.dawg_index, edge] is inserted in - // dawg_args->updated_active_dawgs - // otherwise: - // -- if we are dealing with dawg of type DAWG_TYPE_PUNCTUATION, - // edge_char_of() is called again, but now with kPatternUnicharID - // as unichar_id; if a valid edge is found it is recorded in - // dawg_args->updated_constraints - // -- the function checks whether the word can end with the previous - // letter - // -- each successor of the dawg (e.g. dawgs with type DAWG_TYPE_WORD - // could be successors to dawgs with type DAWG_TYPE_PUNCTUATION; the - // successors are defined by successors_ vector) is explored and if - // a letter is found in the successor dawg, a new entry is inserted - // into dawg_args->updated_active_dawgs with EDGE_REF being either - // NO_EDGE or an EDGE_REF recorded in constraints vector for the - // corresponding dawg index + /** + * Returns the maximal permuter code (from ccstruct/ratngs.h) if in light + * of the current state the letter at word_index in the given word + * is allowed according to at least one of the dawgs in dawgs_, + * otherwise returns NO_PERM. + * + * The state is described by void_dawg_args, which are interpreted as + * DawgArgs and contain two relevant input vectors: active_dawgs and + * constraints. Each entry in the active_dawgs vector contains an index + * into the dawgs_ vector and an EDGE_REF that indicates the last edge + * followed in the dawg. Each entry in the constraints vector contains + * an index into the dawgs_ vector and an EDGE_REF that indicates an edge + * in a pattern dawg followed to match a pattern. Currently constraints + * are used to save the state of punctuation dawgs after leading + * punctuation was found. + * + * Input: + * At word_index 0 dawg_args->active_dawgs should contain an entry for each + * dawg whose type has a bit set in kBeginningDawgsType, + * dawg_args->constraints should be empty. EDGE_REFs in active_dawgs and + * constraints vectors should be initialized to NO_EDGE. If hyphen state + * needs to be applied, initial dawg_args->active_dawgs and + * dawg_args->constrains can be copied from the saved hyphen state + * (maintained by Dict). + * For word_index > 0 the corresponding state (active_dawgs and constraints) + * can be obtained from dawg_args->updated_* passed to def_letter_is_okay + * for word_index-1. + * Note: the function assumes that active_dags, constraints and updated_* + * member variables of dawg_args are not NULL. + * + * Output: + * The function fills in dawg_args->updated_active_dawgs vector with the + * entries for dawgs that contain the word up to the letter at word_index. + * The new constraints (if any) are added to dawg_args->updated_constraints, + * the constraints from dawg_args->constraints are also copied into it. + * + * Detailed description: + * In order to determine whether the word is still valid after considering + * all the letters up to the one at word_index the following is done for + * each entry in dawg_args->active_dawgs: + * + * - next starting node is obtained from entry.ref and edge_char_of() is + * called to obtain the next edge + * - if a valid edge is found, the function returns the updated permuter + * code true and an entry [entry.dawg_index, edge] is inserted in + * dawg_args->updated_active_dawgs + * otherwise: + * - if we are dealing with dawg of type DAWG_TYPE_PUNCTUATION, + * edge_char_of() is called again, but now with kPatternUnicharID + * as unichar_id; if a valid edge is found it is recorded in + * dawg_args->updated_constraints + * - the function checks whether the word can end with the previous + * letter + * - each successor of the dawg (e.g. dawgs with type DAWG_TYPE_WORD + * could be successors to dawgs with type DAWG_TYPE_PUNCTUATION; the + * successors are defined by successors_ vector) is explored and if + * a letter is found in the successor dawg, a new entry is inserted + * into dawg_args->updated_active_dawgs with EDGE_REF being either + * NO_EDGE or an EDGE_REF recorded in constraints vector for the + * corresponding dawg index + */ - // int def_letter_is_okay(void* void_dawg_args, int word_index, const void* word, bool word_end); @@ -397,15 +401,17 @@ class Dict { const void* word, bool word_end); int (Dict::*letter_is_okay_)(void* void_dawg_args, int word_index, const void *word, bool word_end); - // Return the number of dawgs in the dawgs_ vector. + /** Return the number of dawgs in the dawgs_ vector. */ inline const int NumDawgs() const { return dawgs_.size(); } - // Return i-th dawg pointer recorded in the dawgs_ vector. + /** Return i-th dawg pointer recorded in the dawgs_ vector. */ inline const Dawg *GetDawg(int index) const { return dawgs_[index]; } - // At word ending make sure all the recorded constraints are satisfied. - // Each constraint signifies that we found a beginning pattern in a - // pattern dawg. Check that this pattern can end here (e.g. if some - // leading punctuation is found this would ensure that we are not - // expecting any particular trailing punctuation after the word). + /** + * At word ending make sure all the recorded constraints are satisfied. + * Each constraint signifies that we found a beginning pattern in a + * pattern dawg. Check that this pattern can end here (e.g. if some + * leading punctuation is found this would ensure that we are not + * expecting any particular trailing punctuation after the word). + */ inline bool ConstraintsOk(const DawgInfoVector &constraints, int word_end, DawgType current_dawg_type) { if (!word_end) return true; @@ -423,7 +429,7 @@ class Dict { } return true; } - // Record the maximum of the two permuters in permuter. + /// Record the maximum of the two permuters in permuter. static inline void UpdatePermuter(PermuterType new_permuter, PermuterType *permuter) { if (dawg_debug_level >= 3) tprintf("Letter found\n"); @@ -440,23 +446,27 @@ class Dict { int valid_word(const char *string); private: - // Private member variables. + /** Private member variables. */ Image* image_ptr_; - // Table that stores ambiguities computed during training - // (loaded when NoDangerousAmbigs() is called for the first time). - // Each entry i in the table stores a set of amibiguities whose - // wrong ngram starts with unichar id i. + /** + * Table that stores ambiguities computed during training + * (loaded when NoDangerousAmbigs() is called for the first time). + * Each entry i in the table stores a set of amibiguities whose + * wrong ngram starts with unichar id i. + */ UnicharAmbigs *dang_ambigs_table_; - // Same as above, but for ambiguities with replace flag set. + /** Same as above, but for ambiguities with replace flag set. */ UnicharAmbigs *replace_ambigs_table_; - // Flag used to disable accumulation of word choices - // during compound word permutation. + /** + * Flag used to disable accumulation of word choices + * during compound word permutation. + */ BOOL8 keep_word_choices_; - // Additional certainty padding allowed before a word is rejected. + /** Additional certainty padding allowed before a word is rejected. */ FLOAT32 reject_offset_; - // Current word segmentation. + /** Current word segmentation. */ PIECES_STATE current_segmentation_; - // Variables to keep track of best/raw word choices. + /** Variables to keep track of best/raw word choices. */ VIABLE_CHOICE best_raw_choice_; LIST raw_choices_; LIST best_choices_; @@ -471,8 +481,8 @@ class Dict { SuccessorListsVector successors_; Dawg *freq_dawg_; Trie *pending_words_; - // The following pointers are only cached for convenience. - // The dawgs will be deleted when dawgs_ vector is destroyed. + /// The following pointers are only cached for convenience. + /// The dawgs will be deleted when dawgs_ vector is destroyed. // TODO(daria): need to support multiple languages in the future, // so maybe will need to maintain a list of dawgs of each kind. Trie *document_words_; diff --git a/dict/matchdefs.h b/dict/matchdefs.h index 4d19a94191..0f375f9cf4 100644 --- a/dict/matchdefs.h +++ b/dict/matchdefs.h @@ -31,17 +31,17 @@ #define MAX_NUM_CLASSES 8192 #define MAX_CLASS_ID (MAX_NUM_CLASSES - 1) -/* a CLASS_ID is the ascii character to be associated with a class */ +/** a CLASS_ID is the ascii character to be associated with a class */ typedef UNICHAR_ID CLASS_ID; #define NO_CLASS (0) -/* a PROTO_ID is the index of a prototype within it's class. Valid proto +/** a PROTO_ID is the index of a prototype within it's class. Valid proto id's are 0 to N-1 where N is the number of prototypes that make up the class. */ typedef inT16 PROTO_ID; #define NO_PROTO (-1) -/* FEATURE_ID is the index of a feature within a character description +/** FEATURE_ID is the index of a feature within a character description The feature id ranges from 0 to N-1 where N is the number of features in a character description. */ typedef uinT8 FEATURE_ID; @@ -51,17 +51,17 @@ typedef uinT8 FEATURE_ID; #define MAX_NUM_FEAT 40 #define MAX_FEATURE_ID 250 -/* a RATING is the match rating returned by a classifier. +/** a RATING is the match rating returned by a classifier. Higher is better. */ typedef FLOAT32 RATING; -/* a CERTAINTY is an indication of the degree of confidence of the +/** a CERTAINTY is an indication of the degree of confidence of the classifier. Higher is better. 0 means the match is as good as the mean of the matches seen in training. -1 means the match was one standard deviation worse than the training matches, etc. */ typedef FLOAT32 CERTAINTY; -/* define a data structure to hold a single match result */ +/** define a data structure to hold a single match result */ typedef struct { CLASS_ID Class; @@ -72,13 +72,13 @@ typedef struct MATCH_RESULT; -/* define a data structure for holding an array of match results */ +/** define a data structure for holding an array of match results */ typedef MATCH_RESULT SORTED_CLASSES[MAX_CLASS_ID + 1]; -/**---------------------------------------------------------------------------- +/*---------------------------------------------------------------------------- Public Function Prototypes -----------------------------------------------------------------------------**/ -/* +----------------------------------------------------------------------------*/ +/** all feature matchers that are to be used with the high level classifier must support the following interface. The names will, of course, be unique for each different matcher. Note also that @@ -107,7 +107,7 @@ _ARGS ((FILE * File, int N, MATCH_RESULT MatchResults[])); #undef _ARGS -/**---------------------------------------------------------------------------- +/*---------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +----------------------------------------------------------------------------*/ #endif diff --git a/dict/states.cpp b/dict/states.cpp index 98b27add52..1abf5cce80 100644 --- a/dict/states.cpp +++ b/dict/states.cpp @@ -40,13 +40,15 @@ freestate, STATEBLOCK, "STATE", statecount); /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * bin_to_chunks +/** + * @name bin_to_chunks * * Convert a representation of the search state in "STATE" form to one * in "SEARCH_STATE" form. Create the memory required to hold the * resultant state value. - **********************************************************************/ + * + * @param state The state to convert + */ SEARCH_STATE bin_to_chunks(STATE *state, int num_joints) { int x; unsigned int mask; @@ -90,13 +92,13 @@ SEARCH_STATE bin_to_chunks(STATE *state, int num_joints) { } -/********************************************************************** +/** * bin_to_pieces * * Convert the binary (bit vector) format of a search state to an array * of piece counts. This array has a zero element after the last valid * character. - **********************************************************************/ + */ void bin_to_pieces(STATE *state, int num_joints, PIECES_STATE pieces) { int x; unsigned int mask; /* Bit mask */ @@ -132,12 +134,12 @@ void bin_to_pieces(STATE *state, int num_joints, PIECES_STATE pieces) { } -/********************************************************************** +/** * insert_new_chunk * * Add a new chunk division into this state vector at the location * requested. - **********************************************************************/ + */ void insert_new_chunk(register STATE *state, register int index, register int num_joints) { @@ -165,12 +167,12 @@ void insert_new_chunk(register STATE *state, } -/********************************************************************** +/** * new_state * * Create a memory space for a new state variable. Set its initial * value according to the parameters. - **********************************************************************/ + */ STATE *new_state(STATE *oldstate) { STATE *this_state; @@ -181,11 +183,11 @@ STATE *new_state(STATE *oldstate) { } -/********************************************************************* +/** * ones_in_state * * Return the number of ones that are in this state. - **********************************************************************/ + */ int ones_in_state(STATE *state, int num_joints) { inT8 num_ones = 0; inT8 x; @@ -214,11 +216,11 @@ int ones_in_state(STATE *state, int num_joints) { } -/********************************************************************** +/** * print_state * * Print out the current state variable on a line with a label. - **********************************************************************/ + */ void print_state(const char *label, STATE *state, int num_joints) { int x; unsigned int mask; /* Bit mask */ @@ -250,11 +252,11 @@ void print_state(const char *label, STATE *state, int num_joints) { } -/********************************************************************** +/** * set_n_ones * * Set the first n bits in a state. - **********************************************************************/ + */ void set_n_ones(STATE *state, int n) { if (n < 32) { state->part2 = ~0; @@ -269,7 +271,7 @@ void set_n_ones(STATE *state, int n) { } -/********************************************************************** +/** * compare_states * * Compare the 2 states at the given blob index. Return 1 if the given @@ -277,7 +279,7 @@ void set_n_ones(STATE *state, int n) { * and 5 if both a join and a fragment. * On return the blob index is set to the corresponding index in the * correct string. - **********************************************************************/ + */ int compare_states(STATE *true_state, STATE *this_state, int *blob_index) { int blob_count; //number found int true_index; //index of true blob diff --git a/dict/states.h b/dict/states.h index 45b11cf242..877ab7c4d1 100644 --- a/dict/states.h +++ b/dict/states.h @@ -41,9 +41,10 @@ typedef struct uinT32 part2; } STATE; -typedef int *SEARCH_STATE; /* State variable for search */ +/** State variable for search */ +typedef int *SEARCH_STATE; - /* State variable for search */ +/** State variable for search */ typedef uinT8 PIECES_STATE[MAX_NUM_CHUNKS + 2]; /*---------------------------------------------------------------------- diff --git a/dict/trie.h b/dict/trie.h index 3e6c6228d5..886ebe5327 100644 --- a/dict/trie.h +++ b/dict/trie.h @@ -47,12 +47,12 @@ typedef GenericVector TRIE_NODES; namespace tesseract { -// -// Concrete class for Trie data structure that allows to store a list of -// words (extends Dawg base class) as well as dynamically add new words. -// This class stores a vector of pointers to TRIE_NODE_RECORDs, each of -// which has a vector of forward and backward edges. -// +/** + * Concrete class for Trie data structure that allows to store a list of + * words (extends Dawg base class) as well as dynamically add new words. + * This class stores a vector of pointers to TRIE_NODE_RECORDs, each of + * which has a vector of forward and backward edges. + */ class Trie : public Dawg { public: // max_num_edges argument allows limiting the amount of memory this @@ -69,7 +69,7 @@ class Trie : public Dawg { } ~Trie() { nodes_.delete_data_pointers(); } - // Returns the edge that corresponds to the letter out of this node. + /** Returns the edge that corresponds to the letter out of this node. */ EDGE_REF edge_char_of(NODE_REF node_ref, UNICHAR_ID unichar_id, bool word_end) const { EDGE_RECORD *edge_ptr; @@ -79,8 +79,10 @@ class Trie : public Dawg { return make_edge_ref(node_ref, edge_index); } - // Fills the given NodeChildVector with all the unichar ids (and the - // corresponding EDGE_REFs) for which there is an edge out of this node. + /** + * Fills the given NodeChildVector with all the unichar ids (and the + * corresponding EDGE_REFs) for which there is an edge out of this node. + */ void unichar_ids_of(NODE_REF node, NodeChildVector *vec) const { const EDGE_VECTOR &forward_edges = nodes_[(int)node]->forward_edges; for (int i = 0; i < forward_edges.size(); ++i) { @@ -89,21 +91,25 @@ class Trie : public Dawg { } } - // Returns the next node visited by following the edge - // indicated by the given EDGE_REF. + /** + * Returns the next node visited by following the edge + * indicated by the given EDGE_REF. + */ NODE_REF next_node(EDGE_REF edge_ref) const { if (edge_ref == NO_EDGE || num_edges_ == 0) return NO_EDGE; return next_node_from_edge_rec(*deref_edge_ref(edge_ref)); } - // Returns true if the edge indicated by the given EDGE_REF - // marks the end of a word. + /** + * Returns true if the edge indicated by the given EDGE_REF + * marks the end of a word. + */ bool end_of_word(EDGE_REF edge_ref) const { if (edge_ref == NO_EDGE || num_edges_ == 0) return false; return end_of_word_from_edge_rec(*deref_edge_ref(edge_ref)); } - // Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. + /** Returns UNICHAR_ID stored in the edge indicated by the given EDGE_REF. */ UNICHAR_ID edge_letter(EDGE_REF edge_ref) const { if (edge_ref == NO_EDGE || num_edges_ == 0) return INVALID_UNICHAR_ID; return unichar_id_from_edge_rec(*deref_edge_ref(edge_ref)); @@ -151,13 +157,13 @@ class Trie : public Dawg { TRIE_NODE_RECORD *node_rec = nodes_[(int)node_index]; return &(node_rec->forward_edges[(int)edge_index]); } - // Constructs EDGE_REF from the given node_index and edge_index. + /** Constructs EDGE_REF from the given node_index and edge_index. */ inline EDGE_REF make_edge_ref(NODE_REF node_index, EDGE_INDEX edge_index) const { return ((node_index << flag_start_bit_) | (edge_index << LETTER_START_BIT)); } - // Sets up this edge record to the requested values. + /** Sets up this edge record to the requested values. */ inline void link_edge(EDGE_RECORD *edge, NODE_REF nxt, int direction, bool word_end, UNICHAR_ID unichar_id) { EDGE_RECORD flags = 0; @@ -167,7 +173,7 @@ class Trie : public Dawg { (static_cast(flags) << flag_start_bit_) | (static_cast(unichar_id) << LETTER_START_BIT)); } - // Prints the given EDGE_RECORD. + /** Prints the given EDGE_RECORD. */ inline void print_edge_rec(const EDGE_RECORD &edge_rec) const { tprintf("|" REFFORMAT "|%s%s|%d|", next_node_from_edge_rec(edge_rec), (direction_from_edge_rec(edge_rec) == FORWARD_EDGE) ? "F" : "B", @@ -204,7 +210,7 @@ class Trie : public Dawg { bool word_end, UNICHAR_ID unichar_id); // Adds forward edge linkage from node1 to node2 and the corresponding - // backwad edge linkage in the other direction. + // backward edge linkage in the other direction. bool add_new_edge(NODE_REF node1, NODE_REF node2, bool word_end, UNICHAR_ID unichar_id) { return (add_edge_linkage(node1, node2, FORWARD_EDGE, @@ -252,22 +258,24 @@ class Trie : public Dawg { const EDGE_VECTOR &backward_edges, NODE_MARKER reduced_nodes); - // Order num_edges of consequtive EDGE_RECORDS in the given EDGE_VECTOR in - // increasing order of unichar ids. This function is normally called - // for all edges in a single node, and since number of edges in each node - // is usually quite small, selection sort is used. + /** + * Order num_edges of consequtive EDGE_RECORDS in the given EDGE_VECTOR in + * increasing order of unichar ids. This function is normally called + * for all edges in a single node, and since number of edges in each node + * is usually quite small, selection sort is used. + */ void sort_edges(EDGE_VECTOR *edges); - // Eliminates any redundant edges from this node in the Trie. + /** Eliminates any redundant edges from this node in the Trie. */ void reduce_node_input(NODE_REF node, NODE_MARKER reduced_nodes); // Member variables - TRIE_NODES nodes_; // vector of nodes in the Trie - uinT64 num_edges_; // sum of all edges (forward and backward) - uinT64 max_num_edges_; // maximum number of edges allowed - uinT64 deref_direction_mask_; // mask for EDGE_REF to extract direction - uinT64 deref_node_index_mask_; // mask for EDGE_REF to extract node index + TRIE_NODES nodes_; ///< vector of nodes in the Trie + uinT64 num_edges_; ///< sum of all edges (forward and backward) + uinT64 max_num_edges_; ///< maximum number of edges allowed + uinT64 deref_direction_mask_; ///< mask for EDGE_REF to extract direction + uinT64 deref_node_index_mask_; ///< mask for EDGE_REF to extract node index }; } // namespace tesseract diff --git a/doc/Doxyfile b/doc/Doxyfile index 00430f1a2e..263ef2b359 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1606,3 +1606,1611 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES +# Doxyfile 1.6.3 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = Tesseract + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 3.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = /home/jim/Devel/tesseract/doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = \ + /home/jim/Devel + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set +# FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = /home/jim/Devel/tesseract + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = YES + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = "BOOL_VAR_H(var,val,doc)=bool var = val; /**< doc */" \ + "INT_VAR_H(var,val,doc)=int var = val; /**< doc */" \ + "double_VAR_H(var,val,doc)=double var = val; /**< doc */" \ + "STRING_VAR_H(var,val,doc)=char* var = val; /**< doc */" \ + "BOOL_VAR(var,val,doc)=bool var = val; /**< doc */" \ + "double_VAR(var,val,doc)=double var = val; /**< doc */" \ + "STRING_VAR(var,val,doc)=char* var = val; /**< doc */" \ + "INT_VAR(var,val,doc)=int var = val; /**< doc */" + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/image/img.h b/image/img.h index 03f6a91329..3a8387e5c1 100644 --- a/image/img.h +++ b/image/img.h @@ -24,8 +24,10 @@ struct Pix; -#define MAXIMAGEWIDTH (900*14) /*14inch * 400dpi */ - /*14inch * 400dpi */ +/** 14inch * 400dpi */ +#define MAXIMAGEWIDTH (900*14) + +/** 14inch * 400dpi */ #define MAXIMAGEHEIGHT (900*14) #define COMPUTE_IMAGE_XDIM(xsize,bpp) ((bpp)>8 ? ((xsize)*(bpp)+7)/8 :((xsize)+8/(bpp)-1)/(8/(bpp))) @@ -34,7 +36,8 @@ typedef inT8 (*IMAGE_OPENER) (int, inT32 *, inT32 *, inT8 *, inT8 *, inT32 *); typedef inT8 (*IMAGE_READER) (int, uinT8 *, inT32, inT32, inT8, inT32); typedef inT8 (*IMAGE_WRITER) (int, uinT8 *, inT32, inT32, inT8, inT8, inT32); -typedef uinT8 *COLOUR_PIX; //array of colours +/** array of colours */ +typedef uinT8 *COLOUR_PIX; enum COLOUR_PIX_NAME { RED_PIX, @@ -44,7 +47,8 @@ enum COLOUR_PIX_NAME class DLLSYM IMAGELINE; -class DLLSYM IMAGE //encapsulated image +/** encapsulated image */ +class DLLSYM IMAGE { public: IMAGE(); //constructor @@ -56,122 +60,214 @@ class DLLSYM IMAGE //encapsulated image IMAGE & operator= ( //assignment IMAGE & source); - inT8 read_header( //get file header - const char *name); //name of image - - inT8 read( //get rest of image - inT32 buflines); //size of buffer - - inT8 write( //write image - const char *name); //name to write - - inT8 create( //create blank image - inT32 x, //x size required - inT32 y, //ysize required - inT8 bits_per_pixel); //bpp required - - inT8 capture( //capture raw image - uinT8 *pixels, //pixels to capture - inT32 x, //x size required - inT32 y, //ysize required - inT8 bits_per_pixel); //bpp required - - void destroy(); //destroy image - + /** + * get file header + * @param name name of image + */ + inT8 read_header(const char *name); + + /** + * get rest of image + * @param buflines size of buffer + */ + inT8 read(inT32 buflines); + + /** + * write image + * @param name name to write + */ + inT8 write(const char *name); + + /** + * create blank image + * @param x x size required + * @param y y size required + * @param bits_per_pixel bpp required + */ + inT8 create(inT32 x, + inT32 y, + inT8 bits_per_pixel); + + /** + * capture raw image + * @param pixels pixels to capture + * @param x x size required + * @param y y size required + * @param bits_per_pixel bpp required + */ + inT8 capture(uinT8 *pixels, + inT32 x, + inT32 y, + inT8 bits_per_pixel); + + /** destroy image */ + void destroy(); + + /** + * access function + * @return xsize + */ inT32 get_xsize() { return xsize; } - //access function + /** + * access function + * @return ysize + */ inT32 get_ysize() { return ysize; } - //access function + /** + * access function + * @return bits per pixel + */ inT8 get_bpp() { return bpp; - } //access function + } + /** + * access function + * @return bits per sample + */ inT8 get_bps() { return bps; - } //bits per sample - BOOL8 white_high() { //photo interp + } + /** photo interp */ + BOOL8 white_high() { return photo_interp; } - uinT8 get_white_level() { //access function + /** access function */ + uinT8 get_white_level() { return (1 << bpp) - 1; } + /** get resolution */ inT32 get_res() { return res; - } //access function - void set_res( //set resolution - inT32 resolution) { + } + /** set resolution */ + void set_res(inT32 resolution) { res = resolution; } uinT8 *get_buffer() { return image; } - //access function - - uinT8 pixel( //access pixel - inT32 x, //x coord - inT32 y); //y coord - - void fast_get_line( //get image line - inT32 x, //coord to start at - inT32 y, //line to get - inT32 width, //no of pixels to get - IMAGELINE *linebuf); //line to copy to - - void get_line( //get image line - inT32 x, //coord to start at - inT32 y, //line to get - inT32 width, //no of pixels to get - IMAGELINE *linebuf, //line to copy to - inT32 margins); //size of margins - void get_column( //get image column - inT32 x, //coord to start at - inT32 y, //line to get - inT32 height, //no of pixels to get - IMAGELINE *linebuf, //line to copy to - inT32 margins); //size of margins - - void fast_put_line( //put image line - inT32 x, //coord to start at - inT32 y, //line to put - inT32 width, //no of pixels to put - IMAGELINE *linebuf); //line to copy from - - void put_line( //put image line - inT32 x, //coord to start at - inT32 y, //line to put - inT32 width, //no of pixels to put - IMAGELINE *linebuf, //line to copy from - inT32 margins); //size of margins - void put_column( //put image column - inT32 x, //coord to start at - inT32 y, //line to put - inT32 height, //no of pixels to put - IMAGELINE *linebuf, //line to copy to - inT32 margins); //size of margins - - void check_legal_access( //check coords - inT32 x, //xcoord to check + + /** + * access pixel + * @param x coord + * @param y coord + */ + uinT8 pixel(inT32 x, + inT32 y); + + /** + * get image line + * @param x coord to start at + * @param y line to get + * @param width line to get + * @param linebuf line to copy to + */ + void fast_get_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf); + + /** + * get image line + * @param x coord to start at + * @param y line to get + * @param width line to get + * @param linebuf line to copy to + * @param margins size of margins + */ + void get_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf, + inT32 margins); + /** + * get image column + * @param x coord to start at + * @param y line to get + * @param height number of pixels to get + * @param linebuf line to copy to + * @param margins size of margins + */ + void get_column(inT32 x, + inT32 y, + inT32 height, + IMAGELINE *linebuf, + inT32 margins); + + /** + * put image line + * @param x coord to start at + * @param y line to put + * @param width number of pixels to put + * @param linebuf line to copy from + */ + void fast_put_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf); + + /** + * put image line + * @param x coord to start at + * @param y line to put + * @param width number of pixels to put + * @param linebuf line to copy from + * @param margins size of margins + */ + void put_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf, + inT32 margins); + /** + * put image column + * @param x coord to start at + * @param y line to put + * @param height number of pixels to put + * @param linebuf line to copy to + * @param margins size of margins + */ + void put_column(inT32 x, + inT32 y, + inT32 height, + IMAGELINE *linebuf, + inT32 margins); + + /** + * check coordinates + * @param x xcoord to check + * @param y ycoord to check + */ + void check_legal_access(inT32 x, inT32 y, - inT32 xext); //ycoord to check + inT32 xext); - // Methods to convert image types. Only available if Leptonica is available. + /** Methods to convert image types. Only available if Leptonica is available. */ Pix* ToPix(); void FromPix(const Pix* src_pix); - void convolver ( //Map fn over window - inT32 win_width, //Window width - inT32 win_height, //Window height - void (*convolve) ( //Conv Function - uinT8 ** pixels, //Of window - uinT8 bytespp, //1 or 3 for colour - inT32 win_wd, //Window width - inT32 win_ht, //Window height - uinT8 ret_white_value, //White value to RETURN - uinT8 * result)); //Result pixel(s) + /** + * Map function over window + * @param win_width Window width + * @param win_height Window height + * @param convolve Conv function + */ + void convolver ( + inT32 win_width, + inT32 win_height, + void (*convolve) ( + uinT8 ** pixels, ///< Of window + uinT8 bytespp, ///< 1 or 3 for colour + inT32 win_wd, ///< Window width + inT32 win_ht, ///< Window height + uinT8 ret_white_value, ///< White value to RETURN + uinT8 * result ///< Result pixel(s) + )); //copy rectangle friend DLLSYM void copy_sub_image(IMAGE *source, //source image @@ -221,36 +317,41 @@ class DLLSYM IMAGE //encapsulated image BOOL8 adjust_grey); //shift to match bpp private: - inT8 bpp; //bits per pixel - inT8 bps; //bits per sample - inT8 bytespp; //per pixel - inT8 lineskip; //waste bytes on line - BOOL8 captured; //true if buffer captured - inT8 photo_interp; //interpretation - inT32 xsize, ysize; //size of image - inT32 res; //resolution - uinT8 *image; //the actual image - inT32 xdim; //bytes per line - inT32 bufheight; //height of buffer - int fd; //open file descriptor - IMAGE_READER reader; //reading function - inT32 ymin; //bottom line in mem - inT32 ymax; //top line in mem+1 - inT8 bufread( //read some more - inT32 y); //ycoord required + inT8 bpp; ///< bits per pixel + inT8 bps; ///< bits per sample + inT8 bytespp; ///< per pixel + inT8 lineskip; ///< waste bytes on line + BOOL8 captured; ///< true if buffer captured + inT8 photo_interp; ///< interpretation + inT32 xsize, ysize; ///< size of image + inT32 res; ///< resolution + uinT8 *image; ///< the actual image + inT32 xdim; ///< bytes per line + inT32 bufheight; ///< height of buffer + int fd; ///< open file descriptor + IMAGE_READER reader; ///< reading function + inT32 ymin; ///< bottom line in mem + inT32 ymax; ///< top line in mem+1 + /** + * read some more + * @param y ycoord required + */ + inT8 bufread(inT32 y); }; class DLLSYM IMAGELINE //one line of image { public: - uinT8 * pixels; //image pixels - inT8 bpp; //bits per pixel - COLOUR_PIX operator[] ( //colour pixels + uinT8 * pixels; ///< image pixels + inT8 bpp; ///< bits per pixel + /** colour pixels */ + COLOUR_PIX operator[] ( inT32 index) { return &pixels[index * 3]; //coercion access op } - IMAGELINE() { //default constructor + /** default constructor */ + IMAGELINE() { linewidth = 0; line = NULL; pixels = line; @@ -274,8 +375,8 @@ class DLLSYM IMAGELINE //one line of image free_mem(line); } - void set_bpp( //For colour - inT8 new_bpp) { + /** For colour */ + void set_bpp(inT8 new_bpp) { if (new_bpp <= 8) bpp = 8; else @@ -291,46 +392,87 @@ class DLLSYM IMAGELINE //one line of image } } - friend void IMAGE::get_line( //copies a line - inT32 x, //coord to start at - inT32 y, //line to get - inT32 width, //no of pixels to get - IMAGELINE *linebuf, //line to copy to - inT32 margins); //size of margins - //copies a column - friend void IMAGE::get_column(inT32 x, //coord to start at - inT32 y, //line to get - inT32 height, //no of pixels to get - IMAGELINE *linebuf, //line to copy to - inT32 margins); //size of margins - - friend void IMAGE::put_line( //writes a line - inT32 x, //coord to start at - inT32 y, //line to put - inT32 width, //no of pixels to put - IMAGELINE *linebuf, //line to copy from - inT32 margins); //size of margins - //writes a column - friend void IMAGE::put_column(inT32 x, //coord to start at - inT32 y, //line to put - inT32 height, //no of pixels to put - IMAGELINE *linebuf, //line to copy from - inT32 margins); //size of margins - - //may just change pointer - friend void IMAGE::fast_get_line(inT32 x, //coord to start at - inT32 y, //line to get - inT32 width, //no of pixels to get - IMAGELINE *linebuf); //line to copy to - - //may just change pointer - friend void IMAGE::fast_put_line(inT32 x, //coord to start at - inT32 y, //line to get - inT32 width, //no of pixels to get - IMAGELINE *linebuf); //line to copy to + /** + * copies a line + * @param x coord to start at + * @param y line to get + * @param width no of pixels to get + * @param linebuf line to copy to + * @param margins size of margins + */ + friend void IMAGE::get_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf, + inT32 margins); + /** + * copies a column + * @param x coord to start at + * @param y line to get + * @param height no of pixels to get + * @param linebuf line to copy to + * @param margins size of margins + */ + friend void IMAGE::get_column(inT32 x, + inT32 y, + inT32 height, + IMAGELINE *linebuf, + inT32 margins); + + /** + * writes a line + * @param x coord to start at + * @param y line to get + * @param width no of pixels to put + * @param linebuf line to copy to + * @param margins size of margins + */ + friend void IMAGE::put_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf, + inT32 margins); + + /** + * writes a column + * @param x coord to start at + * @param y line to get + * @param height no of pixels to put + * @param linebuf line to copy to + * @param margins size of margins + */ + friend void IMAGE::put_column(inT32 x, + inT32 y, + inT32 height, + IMAGELINE *linebuf, + inT32 margins); + + /** + * @note may just change pointer + * @param x coord to start at + * @param y line to get + * @param width no of pixels to get + * @param linebuf line to copy to + */ + friend void IMAGE::fast_get_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf); + + /** + * @note may just change pointer + * @param x coord to start at + * @param y line to get + * @param width no of pixels to put + * @param linebuf line to copy to + */ + friend void IMAGE::fast_put_line(inT32 x, + inT32 y, + inT32 width, + IMAGELINE *linebuf); private: - uinT8 * line; //local buffer - inT32 linewidth; //width of buffer + uinT8 * line; ///< local buffer + inT32 linewidth; ///< width of buffer }; #endif diff --git a/textord/blkocc.cpp b/textord/blkocc.cpp index 7c31b3d30e..94306cb7b3 100644 --- a/textord/blkocc.cpp +++ b/textord/blkocc.cpp @@ -115,23 +115,26 @@ static void find_fbox(OUTLINE_IT *out_it, static void maintain_limits(float *min_x, float *max_x, float x); -/* ******************************************************************** +/** A note on transitions. We want to record occupancy in various bands. In general we need to consider 7 situations: +@verbatim (1) (2) (3) (4) -\ / \ / \ / + \ / \ / \ / __\_____/_____\_________/_____\_________/______ Upper Limit - \ / \ / \ / - / \ \-->--/ \--<--/ /-----\ -v ^ / \(7) -\ \ \ / - \ \ /--<--\ /-->--\ \-----/ + \ / \ / \ / + / \ \-->--/ \--<--/ /-----\ + v ^ / \(7) + \ \ \ / + \ \ /--<--\ /-->--\ \-----/ ____\______\____/_______\____/_______\_________ Lower Limit - \ \ / \ / \ - (5) (6) + \ \ / \ / \ + (5) (6) +@endverbatim + We know that following "next" pointers around an outline keeps the black area on the LEFT. We only need be concerned with situations 1,2,3,5 and 7. 4 and 6 can be ignored as they represent small incursions into a large black @@ -158,18 +161,18 @@ to the original band at the same x location. BAND bands[MAX_NUM_BANDS + 1]; // band defns -/********************************************************************** +/** * test_underline * * Check to see if the blob is an underline. * Return TRUE if it is. - **********************************************************************/ + */ BOOL8 test_underline( //look for underlines - BOOL8 testing_on, //drawing blob - PBLOB *blob, //blob to test - float baseline, //coords of baseline - float xheight //height of line + BOOL8 testing_on, //< drawing blob + PBLOB *blob, //< blob to test + float baseline, //< coords of baseline + float xheight //< height of line ) { inT16 occ; inT16 blob_width; //width of blob @@ -208,18 +211,18 @@ BOOL8 test_underline( //look for underlines } -/********************************************************************** +/** * test_underline * * Check to see if the blob is an underline. * Return TRUE if it is. - **********************************************************************/ + */ BOOL8 test_underline( //look for underlines - BOOL8 testing_on, //drawing blob - C_BLOB *blob, //blob to test - inT16 baseline, //coords of baseline - inT16 xheight //height of line + BOOL8 testing_on, //< drawing blob + C_BLOB *blob, //< blob to test + inT16 baseline, //< coords of baseline + inT16 xheight //< height of line ) { inT16 occ; inT16 blob_width; //width of blob @@ -279,16 +282,16 @@ BOOL8 test_underline( //look for underlines } -/********************************************************************** +/** * horizontal_cblob_projection * * Compute the horizontal projection of a cblob from its outlines * and add to the given STATS. - **********************************************************************/ + */ static void horizontal_cblob_projection( //project outlines - C_BLOB *blob, //blob to project - STATS *stats //output + C_BLOB *blob, //< blob to project + STATS *stats //< output ) { //outlines of blob C_OUTLINE_IT out_it = blob->out_list (); @@ -299,16 +302,16 @@ static void horizontal_cblob_projection( //project outlines } -/********************************************************************** +/** * horizontal_coutline_projection * * Compute the horizontal projection of a outline from its outlines * and add to the given STATS. - **********************************************************************/ + */ static void horizontal_coutline_projection( //project outlines - C_OUTLINE *outline, //outline to project - STATS *stats //output + C_OUTLINE *outline, //< outline to project + STATS *stats //< output ) { ICOORD pos; //current point ICOORD step; //edge step diff --git a/textord/linefind.cpp b/textord/linefind.cpp index 0d74b23b2c..265ae21d4b 100644 --- a/textord/linefind.cpp +++ b/textord/linefind.cpp @@ -40,13 +40,13 @@ BOOL_VAR(textord_tabfind_show_vlines, false, "Show vertical rule lines"); namespace tesseract { -// Denominator of resolution makes max pixel width to allow thin lines. +/// Denominator of resolution makes max pixel width to allow thin lines. const int kThinLineFraction = 30; -// Denominator of resolution makes min pixels to demand line lengths to be. +/// Denominator of resolution makes min pixels to demand line lengths to be. const int kMinLineLengthFraction = 8; -// Spacing of cracks across the page to break up tall vertical lines. +/// Spacing of cracks across the page to break up tall vertical lines. const int kCrackSpacing = 100; -// Grid size used by line finder. Not very critical. +/// Grid size used by line finder. Not very critical. const int kLineFindGridSize = 50; // Finds vertical line objects in the given pix. @@ -352,3 +352,4 @@ Boxa* LineFinder::GetHLineBoxes(int resolution, Pix* src_pix, Pix** line_pix) { } // namespace tesseract. + diff --git a/textord/linefind.h b/textord/linefind.h index dd7d97ee6a..0ea7e0b6e8 100644 --- a/textord/linefind.h +++ b/textord/linefind.h @@ -31,60 +31,89 @@ namespace tesseract { class TabVector_LIST; -// The LineFinder class is a simple static function wrapper class that mainly -// exposes the FindVerticalLines function. +/** + * The LineFinder class is a simple static function wrapper class that mainly + * exposes the FindVerticalLines function. + */ class LineFinder { public: - // Finds vertical line objects in the given pix. - // Uses the given resolution to determine size thresholds instead of any - // that may be present in the pix. - // The output vertical_x and vertical_y contain a sum of the output vectors, - // thereby giving the mean vertical direction. - // The output vectors are owned by the list and Frozen (cannot refit) by - // having no boxes, as there is no need to refit or merge separator lines. + /** + * Finds vertical line objects in the given pix. + * + * Uses the given resolution to determine size thresholds instead of any + * that may be present in the pix. + * + * The output vertical_x and vertical_y contain a sum of the output vectors, + * thereby giving the mean vertical direction. + * + * The output vectors are owned by the list and Frozen (cannot refit) by + * having no boxes, as there is no need to refit or merge separator lines. + */ static void FindVerticalLines(int resolution, Pix* pix, int* vertical_x, int* vertical_y, TabVector_LIST* vectors); - // Finds horizontal line objects in the given pix. - // Uses the given resolution to determine size thresholds instead of any - // that may be present in the pix. - // The output vectors are owned by the list and Frozen (cannot refit) by - // having no boxes, as there is no need to refit or merge separator lines. + /** + * Finds horizontal line objects in the given pix. + * + * Uses the given resolution to determine size thresholds instead of any + * that may be present in the pix. + * + * The output vectors are owned by the list and Frozen (cannot refit) by + * having no boxes, as there is no need to refit or merge separator lines. + */ static void FindHorizontalLines(int resolution, Pix* pix, TabVector_LIST* vectors); - // Converts the Boxa array to a list of C_BLOB, getting rid of severely - // overlapping outlines and those that are children of a bigger one. - // The output is a list of C_BLOBs that are owned by the list. - // The C_OUTLINEs in the C_BLOBs contain no outline data - just empty - // bounding boxes. The Boxa is consumed and destroyed. + /** + * Converts the Boxa array to a list of C_BLOB, getting rid of severely + * overlapping outlines and those that are children of a bigger one. + * + * The output is a list of C_BLOBs that are owned by the list. + * + * The C_OUTLINEs in the C_BLOBs contain no outline data - just empty + * bounding boxes. The Boxa is consumed and destroyed. + */ static void ConvertBoxaToBlobs(int image_width, int image_height, Boxa** boxes, C_BLOB_LIST* blobs); private: - // Finds vertical lines in the given list of BLOBNBOXes. bleft and tright - // are the bounds of the image on which the input line_bblobs were found. - // The input line_bblobs list is const really. - // The output vertical_x and vertical_y are the total of all the vectors. - // The output list of TabVector makes no reference to the input BLOBNBOXes. + /** + * Finds vertical lines in the given list of BLOBNBOXes. bleft and tright + * are the bounds of the image on which the input line_bblobs were found. + * + * The input line_bblobs list is const really. + * + * The output vertical_x and vertical_y are the total of all the vectors. + * The output list of TabVector makes no reference to the input BLOBNBOXes. + */ static void FindLineVectors(const ICOORD& bleft, const ICOORD& tright, BLOBNBOX_LIST* line_bblobs, int* vertical_x, int* vertical_y, TabVector_LIST* vectors); - // Get a set of bounding boxes of possible vertical lines in the image. - // The input resolution overrides any resolution set in src_pix. - // The output line_pix contains just all the detected lines. + /** + * Get a set of bounding boxes of possible vertical lines in the image. + * + * The input resolution overrides any resolution set in src_pix. + * + * The output line_pix contains just all the detected lines. + */ static Boxa* GetVLineBoxes(int resolution, Pix* src_pix, Pix** line_pix); - // Get a set of bounding boxes of possible horizontal lines in the image. - // The input resolution overrides any resolution set in src_pix. - // The output line_pix contains just all the detected lines. - // The output boxes undergo the transformation (x,y)->(height-y,x) so the - // lines can be found with a vertical line finder afterwards. - // This transformation allows a simple x/y flip to reverse it in tesseract - // coordinates and it is faster to flip the lines than rotate the image. + /** + * Get a set of bounding boxes of possible horizontal lines in the image. + * + * The input resolution overrides any resolution set in src_pix. + * + * The output line_pix contains just all the detected lines. + * + * The output boxes undergo the transformation (x,y)->(height-y,x) so the + * lines can be found with a vertical line finder afterwards. + * + * This transformation allows a simple x/y flip to reverse it in tesseract + * coordinates and it is faster to flip the lines than rotate the image. + */ static Boxa* GetHLineBoxes(int resolution, Pix* src_pix, Pix** line_pix); }; @@ -92,3 +121,4 @@ class LineFinder { #endif // TESSERACT_TEXTORD_LINEFIND_H__ + diff --git a/viewer/scrollview.cpp b/viewer/scrollview.cpp index 739b02f9b2..05d382797f 100644 --- a/viewer/scrollview.cpp +++ b/viewer/scrollview.cpp @@ -19,6 +19,10 @@ // // Include automatically generated configuration file if running autoconf. +#ifdef HAVE_CONFIG_H +#include "config_auto.h" +#endif + #ifndef GRAPHICS_DISABLED // This class contains the main ScrollView-logic, // e.g. parsing & sending messages, images etc. @@ -84,10 +88,10 @@ SVEvent* SVEvent::copy() { return any; } -// This is the main loop which handles the ScrollView-logic from the server -// to the client. It basically loops through messages, parses them to events -// and distributes it to the waiting handlers. -// It is run from a different thread and synchronizes via SVSync. +/// This is the main loop which handles the ScrollView-logic from the server +/// to the client. It basically loops through messages, parses them to events +/// and distributes it to the waiting handlers. +/// It is run from a different thread and synchronizes via SVSync. void* ScrollView::MessageReceiver(void* a) { int counter_event_id = 0; // ongoing counter char* message = NULL; @@ -236,14 +240,14 @@ int table_colors[ScrollView::GREEN_YELLOW+1][4]= { SVNetwork* ScrollView::stream_ = NULL; int ScrollView::nr_created_windows_ = 0; -// Calls Initialize with all arguments given. +/// Calls Initialize with all arguments given. ScrollView::ScrollView(const char* name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size, bool y_axis_reversed, const char* server_name) { Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size, y_axis_reversed, server_name);} -// Calls Initialize with default argument for server_name_. +/// Calls Initialize with default argument for server_name_. ScrollView::ScrollView(const char* name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size, bool y_axis_reversed) { @@ -251,14 +255,14 @@ ScrollView::ScrollView(const char* name, int x_pos, int y_pos, int x_size, y_axis_reversed, "localhost"); } -// Calls Initialize with default argument for server_name_ & y_axis_reversed. +/// Calls Initialize with default argument for server_name_ & y_axis_reversed. ScrollView::ScrollView(const char* name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size) { Initialize(name, x_pos, y_pos, x_size, y_size, x_canvas_size, y_canvas_size, false, "localhost"); } -// Sets up a ScrollView window, depending on the constructor variables. +/// Sets up a ScrollView window, depending on the constructor variables. void ScrollView::Initialize(const char* name, int x_pos, int y_pos, int x_size, int y_size, int x_canvas_size, int y_canvas_size, bool y_axis_reversed, const char* server_name) { @@ -309,7 +313,7 @@ void ScrollView::Initialize(const char* name, int x_pos, int y_pos, int x_size, SVSync::StartThread(StartEventHandler, this); } -// Sits and waits for events on this window. +/// Sits and waits for events on this window. void* ScrollView::StartEventHandler(void* a) { ScrollView* sv = reinterpret_cast(a); SVEvent* new_event; @@ -373,7 +377,7 @@ ScrollView::~ScrollView() { delete points_; } -// Send a message to the server, attaching the window id. +/// Send a message to the server, attaching the window id. void ScrollView::SendMsg(const char* format, ...) { if (!points_->empty) SendPolygon(); @@ -390,13 +394,13 @@ void ScrollView::SendMsg(const char* format, ...) { stream_->Send(form); } -// Send a message to the server without a -// window id. Used for global events like exit(). +/// Send a message to the server without a +/// window id. Used for global events like exit(). void ScrollView::SendRawMessage(const char* msg) { stream_->Send(msg); } -// Add an Event Listener to this ScrollView Window +/// Add an Event Listener to this ScrollView Window void ScrollView::AddEventHandler(SVEventHandler* listener) { event_handler_ = listener; } @@ -425,9 +429,9 @@ void ScrollView::SetEvent(SVEvent* svevent) { } -// Block until an event of the given type is received. -// Note: The calling function is responsible for deleting the returned -// SVEvent afterwards! +/// Block until an event of the given type is received. +/// Note: The calling function is responsible for deleting the returned +/// SVEvent afterwards! SVEvent* ScrollView::AwaitEvent(SVEventType type) { // Initialize the waiting semaphore. SVSemaphore* sem = new SVSemaphore(); diff --git a/viewer/svutil.h b/viewer/svutil.h index 87b6125a12..7bddaec819 100644 --- a/viewer/svutil.h +++ b/viewer/svutil.h @@ -46,26 +46,26 @@ #define MIN(a, b) ((a < b) ? a : b) #endif -// The SVSync class provides functionality for Thread & Process Creation +/// The SVSync class provides functionality for Thread & Process Creation class SVSync { public: - // Create new thread. + /// Create new thread. static void StartThread(void *(*func)(void*), void* arg); - // Signals a thread to exit. + /// Signals a thread to exit. static void ExitThread(); - // Starts a new process. + /// Starts a new process. static void StartProcess(const char* executable, const char* args); }; -// A semaphore class which encapsulates the main signalling -// and wait abilities of semaphores for windows and unix. +/// A semaphore class which encapsulates the main signalling +/// and wait abilities of semaphores for windows and unix. class SVSemaphore { public: - // Sets up a semaphore. + /// Sets up a semaphore. SVSemaphore(); - // Signal a semaphore. + /// Signal a semaphore. void Signal(); - // Wait on a semaphore. + /// Wait on a semaphore. void Wait(); private: #ifdef WIN32 @@ -75,15 +75,15 @@ class SVSemaphore { #endif }; -// A mutex which encapsulates the main locking and unlocking -// abilites of mutexes for windows and unix. +/// A mutex which encapsulates the main locking and unlocking +/// abilites of mutexes for windows and unix. class SVMutex { public: - // Sets up a new mutex. + /// Sets up a new mutex. SVMutex(); - // Locks on a mutex. + /// Locks on a mutex. void Lock(); - // Unlocks on a mutex. + /// Unlocks on a mutex. void Unlock(); private: #ifdef WIN32 @@ -93,44 +93,44 @@ class SVMutex { #endif }; -// The SVNetwork class takes care of the remote connection for ScrollView -// This means setting up and maintaining a remote connection, sending and -// receiving messages and closing the connection. -// It is designed to work on both Linux and Windows. +/// The SVNetwork class takes care of the remote connection for ScrollView +/// This means setting up and maintaining a remote connection, sending and +/// receiving messages and closing the connection. +/// It is designed to work on both Linux and Windows. class SVNetwork { public: - // Set up a connection to hostname on port. + /// Set up a connection to hostname on port. SVNetwork(const char* hostname, int port); - // Destructor. + /// Destructor. ~SVNetwork(); - // Put a message in the messagebuffer to the server and try to send it. + /// Put a message in the messagebuffer to the server and try to send it. void Send(const char* msg); - // Receive a message from the server. - // This will always return one line of char* (denoted by \n). + /// Receive a message from the server. + /// This will always return one line of char* (denoted by \n). char* Receive(); - // Close the connection to the server. + /// Close the connection to the server. void Close(); - // Flush the buffer. + /// Flush the buffer. void Flush(); private: - // The mutex for access to Send() and Flush(). + /// The mutex for access to Send() and Flush(). SVMutex* mutex_send_; - // The actual stream_ to the server. + /// The actual stream_ to the server. int stream_; - // Stores the last received message-chunk from the server. + /// Stores the last received message-chunk from the server. char* msg_buffer_in_; - // Stores the messages which are supposed to go out. + /// Stores the messages which are supposed to go out. std::string msg_buffer_out_; bool has_content; // Win32 (strtok) - // Where we are at in our msg_buffer_in_ + /// Where we are at in our msg_buffer_in_ char* buffer_ptr_; // Unix (strtok_r) }; diff --git a/wordrec/associate.h b/wordrec/associate.h index 0a28c28ef1..17a354f63f 100644 --- a/wordrec/associate.h +++ b/wordrec/associate.h @@ -45,16 +45,20 @@ ---------------------------------------------------------------------- */ -typedef LIST BLOBS; //? /* List of (BLOB*) */ +/** List of (BLOB*) */ +typedef LIST BLOBS; -typedef LIST OUTLINES; /* List of (TESSLINE*) */ +/** List of (TESSLINE*) */ +typedef LIST OUTLINES; -typedef LIST EDGEPTS; /* List of (EDGEPT*) */ +/** List of (EDGEPT*) */ +typedef LIST EDGEPTS; typedef inT16 BLOB_WEIGHTS[MAX_NUM_CHUNKS]; +/** Each char evaluated */ typedef struct -{ /* Each char evaluated */ +{ float match; float certainty; char character; @@ -62,9 +66,10 @@ typedef struct int gap; } EVALUATION_RECORD; +/** Classification info for chunks */ struct CHUNKS_RECORD -{ /* Classification info */ - MATRIX *ratings; /* for chunks */ +{ + MATRIX *ratings; TBLOB *chunks; SEAMS splits; TEXTROW *row; @@ -75,7 +80,7 @@ struct CHUNKS_RECORD inT16 *weights; }; - /* Each segmentation */ +/** Each segmentation */ typedef EVALUATION_RECORD EVALUATION_ARRAY[MAX_NUM_CHUNKS]; /*---------------------------------------------------------------------- diff --git a/wordrec/badwords.cpp b/wordrec/badwords.cpp index 34165f965a..90d5e15ec7 100644 --- a/wordrec/badwords.cpp +++ b/wordrec/badwords.cpp @@ -16,9 +16,9 @@ ** limitations under the License. ******************************************************************************/ -/**---------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- Include Files and Type Defines -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ #include "general.h" #include "oldheap.h" #include "callcpp.h" @@ -31,28 +31,30 @@ #define MAX_NUM_BAD_WERDS 1000 -/**---------------------------------------------------------------------------- +/*---------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ +/** heap that bad words are stored in */ static HEAP *BadWords = NULL; BOOL_VAR (tessedit_save_stats, FALSE, "Save final recognition statistics"); -/**---------------------------------------------------------------------------- +/*---------------------------------------------------------------------------- Public Code -----------------------------------------------------------------------------**/ +-----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -void PrintBadWords(FILE *File) { -/* - ** Parameters: - ** File open text file to print bad words to - ** Globals: - ** BadWords heap that bad words are stored in - ** Operation: This routine prints the bad words stored in BadWords - ** to file ordered by certainty (worst certainty first). - ** Return: none - ** Exceptions: none - ** History: Thu Apr 25 08:57:08 1991, DSJ, Created. +/** + * This routine prints the bad words stored in BadWords + * to file ordered by certainty (worst certainty first). + * + * @param File open text file to print bad words to + * + * Globals: + * - BadWords heap that bad words are stored in + * + * @note Exceptions: none + * @note History: Thu Apr 25 08:57:08 1991, DSJ, Created. */ +void PrintBadWords(FILE *File) { HEAPENTRY NextWord; if (BadWords == NULL) @@ -72,21 +74,21 @@ void PrintBadWords(FILE *File) { /*---------------------------------------------------------------------------*/ -void SaveBadWord(const char *Word, FLOAT32 Certainty) { -/* - ** Parameters: - ** Word bad word to be saved - ** Certainty certainty of word - ** Globals: - ** BadWords heap to keep bad words in - ** Operation: This routine saves all words flagged as bad in a heap - ** with the worst word on the top of the heap. The contents - ** of this heap can be printed to a file by calling - ** PrintBadWords (File). - ** Return: none - ** Exceptions: none - ** History: Thu Apr 25 08:41:00 1991, DSJ, Created. +/** + * This routine saves all words flagged as bad in a heap + * with the worst word on the top of the heap. The contents + * of this heap can be printed to a file by calling + * PrintBadWords (File). + * + * @param Word bad word to be saved + * @param Certainty certainty of word + * + * Globals: + * - BadWords heap to keep bad words in + * + * History: Thu Apr 25 08:41:00 1991, DSJ, Created. */ +void SaveBadWord(const char *Word, FLOAT32 Certainty) { HEAPENTRY NewWord; assert (Word != NULL); diff --git a/wordrec/bestfirst.cpp b/wordrec/bestfirst.cpp index 4105abae51..5c8425518b 100644 --- a/wordrec/bestfirst.cpp +++ b/wordrec/bestfirst.cpp @@ -73,13 +73,13 @@ double_VAR(wordrec_worst_state, 1, "Worst segmentation state"); F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * best_first_search +namespace tesseract { +/** + * @name best_first_search * * Find the best segmentation by doing a best first search of the * solution space. - **********************************************************************/ -namespace tesseract { + */ void Wordrec::best_first_search(CHUNKS_RECORD *chunks_record, WERD_CHOICE *best_choice, WERD_CHOICE *raw_choice, @@ -176,15 +176,15 @@ void Wordrec::best_first_search(CHUNKS_RECORD *chunks_record, } // namespace tesseract -/********************************************************************** - * chunks_width +/** + * @name chunks_width * * Return the width of a chunk which is a composed of several blobs * blobs[start_blob..last_blob] inclusively, * whose individual widths and gaps are record in width_record in the form * width_record->num_char = n * width_record->widths[2*n-1] = w0,g0,w1,g1..w(n-1),g(n-1) - **********************************************************************/ + */ int chunks_width(WIDTH_RECORD *width_record, int start_blob, int last_blob) { int result = 0; for (int x = start_blob * 2; x <= last_blob * 2; x++) @@ -192,22 +192,22 @@ int chunks_width(WIDTH_RECORD *width_record, int start_blob, int last_blob) { return (result); } -/********************************************************************** - * chunks_gap +/** + * @name chunks_gap * * Return the width of between the specified chunk and next. - **********************************************************************/ + */ int chunks_gap(WIDTH_RECORD *width_record, int last_chunk) { return (last_chunk < width_record->num_chars - 1) ? width_record->widths[last_chunk * 2 + 1] : 0; } -/********************************************************************** +/** * delete_search * * Terminate the current search and free all the memory involved. - **********************************************************************/ + */ void delete_search(SEARCH_RECORD *the_search) { float closeness; @@ -229,13 +229,13 @@ void delete_search(SEARCH_RECORD *the_search) { } -/********************************************************************** +namespace tesseract { +/** * evaluate_chunks * * A particular word level segmentation has been chosen. Evaluation * this to find the word list that corresponds to it. - **********************************************************************/ -namespace tesseract { + */ BLOB_CHOICE_LIST_VECTOR *Wordrec::evaluate_chunks(CHUNKS_RECORD *chunks_record, SEARCH_STATE search_state) { BLOB_CHOICE_LIST_VECTOR *char_choices = new BLOB_CHOICE_LIST_VECTOR(); @@ -283,12 +283,12 @@ BLOB_CHOICE_LIST_VECTOR *Wordrec::evaluate_chunks(CHUNKS_RECORD *chunks_record, return (char_choices); } -/********************************************************************** - * evaluate_state +/** + * @name evaluate_state * * Evaluate the segmentation that is represented by this state in the * best first search. Add this state to the "states_seen" list. - **********************************************************************/ + */ inT16 Wordrec::evaluate_state(CHUNKS_RECORD *chunks_record, SEARCH_RECORD *the_search, DANGERR *fixpt) { @@ -348,12 +348,12 @@ inT16 Wordrec::evaluate_state(CHUNKS_RECORD *chunks_record, } -/********************************************************************** +/** * rebuild_current_state * * Evaluate the segmentation that is represented by this state in the * best first search. Add this state to the "states_seen" list. - **********************************************************************/ + */ BLOB_CHOICE_LIST_VECTOR *Wordrec::rebuild_current_state( TBLOB *blobs, SEAMS seam_list, @@ -546,13 +546,13 @@ BLOB_CHOICE_LIST_VECTOR *Wordrec::rebuild_current_state( } // namespace tesseract -/********************************************************************** - * expand_node +/** + * @name expand_node * * Create the states that are attached to this one. Check to see that * each one has not already been visited. If not add it to the priority * queue. - **********************************************************************/ + */ namespace tesseract { void Wordrec::expand_node(FLOAT32 worst_priority, CHUNKS_RECORD *chunks_record, @@ -617,11 +617,11 @@ void Wordrec::expand_node(FLOAT32 worst_priority, } // namespace tesseract -/********************************************************************** - * new_search +/** + * @name new_search * * Create and initialize a new search record. - **********************************************************************/ + */ SEARCH_RECORD *new_search(CHUNKS_RECORD *chunks_record, int num_joints, WERD_CHOICE *best_choice, @@ -654,12 +654,12 @@ SEARCH_RECORD *new_search(CHUNKS_RECORD *chunks_record, } -/********************************************************************** - * pop_queue +/** + * @name pop_queue * * Get this state from the priority queue. It should be the state that * has the greatest urgency to be evaluated. - **********************************************************************/ + */ STATE *pop_queue(HEAP *queue) { HEAPENTRY entry; @@ -678,11 +678,11 @@ STATE *pop_queue(HEAP *queue) { } -/********************************************************************** - * push_queue +/** + * @name push_queue * * Add this state into the priority queue. - **********************************************************************/ + */ void push_queue(HEAP *queue, STATE *state, FLOAT32 worst_priority, FLOAT32 priority) { HEAPENTRY entry; @@ -702,12 +702,12 @@ void push_queue(HEAP *queue, STATE *state, FLOAT32 worst_priority, } -/********************************************************************** - * replace_char_widths +/** + * @name replace_char_widths * * Replace the value of the char_width field in the chunks_record with * the updated width measurements from the last_segmentation. - **********************************************************************/ + */ void replace_char_widths(CHUNKS_RECORD *chunks_record, SEARCH_STATE state) { WIDTH_RECORD *width_record; int num_blobs; diff --git a/wordrec/chop.cpp b/wordrec/chop.cpp index c463e0c505..14f4b727d9 100644 --- a/wordrec/chop.cpp +++ b/wordrec/chop.cpp @@ -80,13 +80,13 @@ INT_VAR(chop_x_y_weight, 3, "X / Y length weight"); /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** - * length_product +/** + * @name length_product * * Compute the product of the length of two vectors. The * vectors must be of type POINT. This product is used in computing * angles. - **********************************************************************/ + */ #define length_product(p1,p2) \ (sqrt ((((float) (p1).x * (p1).x + (float) (p1).y * (p1).y) * \ ((float) (p2).x * (p2).x + (float) (p2).y * (p2).y)))) @@ -94,22 +94,22 @@ INT_VAR(chop_x_y_weight, 3, "X / Y length weight"); /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * point_priority +/** + * @name point_priority * * Assign a priority to and edge point that might be used as part of a * split. The argument should be of type EDGEPT. - **********************************************************************/ + */ PRIORITY point_priority(EDGEPT *point) { return ((PRIORITY) point_bend_angle (point)); } -/********************************************************************** - * add_point_to_list +/** + * @name add_point_to_list * * Add an edge point to a POINT_GROUP containg a list of other points. - **********************************************************************/ + */ void add_point_to_list(POINT_GROUP point_list, EDGEPT *point) { HEAPENTRY data; @@ -126,12 +126,12 @@ void add_point_to_list(POINT_GROUP point_list, EDGEPT *point) { } -/********************************************************************** - * angle_change +/** + * @name angle_change * * Return the change in angle (degrees) of the line segments between * points one and two, and two and three. - **********************************************************************/ + */ int angle_change(EDGEPT *point1, EDGEPT *point2, EDGEPT *point3) { VECTOR vector1; VECTOR vector2; @@ -162,12 +162,12 @@ int angle_change(EDGEPT *point1, EDGEPT *point2, EDGEPT *point3) { return (angle); } -/********************************************************************** - * is_little_chunk +/** + * @name is_little_chunk * * Return TRUE if one of the pieces resulting from this split would * less than some number of edge points. - **********************************************************************/ + */ int is_little_chunk(EDGEPT *point1, EDGEPT *point2) { EDGEPT *p = point1; /* Iterator */ int counter = 0; @@ -198,11 +198,11 @@ int is_little_chunk(EDGEPT *point1, EDGEPT *point2) { } -/********************************************************************** - * is_small_area +/** + * @name is_small_area * * Test the area defined by a split accross this outline. - **********************************************************************/ + */ int is_small_area(EDGEPT *point1, EDGEPT *point2) { EDGEPT *p = point1->next; /* Iterator */ int area = 0; @@ -221,12 +221,12 @@ int is_small_area(EDGEPT *point1, EDGEPT *point2) { } -/********************************************************************** - * pick_close_point +/** + * @name pick_close_point * * Choose the edge point that is closest to the critical point. This * point may not be exactly vertical from the critical point. - **********************************************************************/ + */ EDGEPT *pick_close_point(EDGEPT *critical_point, EDGEPT *vertical_point, int *best_dist) { @@ -258,13 +258,13 @@ EDGEPT *pick_close_point(EDGEPT *critical_point, } -/********************************************************************** - * prioritize_points +/** + * @name prioritize_points * * Find a list of edge points from the outer outline of this blob. For * each of these points assign a priority. Sort these points using a * heap structure so that they can be visited in order. - **********************************************************************/ + */ void prioritize_points(TESSLINE *outline, POINT_GROUP points) { EDGEPT *this_point; EDGEPT *local_min = NULL; @@ -324,13 +324,13 @@ void prioritize_points(TESSLINE *outline, POINT_GROUP points) { } -/********************************************************************** - * new_min_point +/** + * @name new_min_point * * Found a new minimum point try to decide whether to save it or not. * Return the new value for the local minimum. If a point is saved then * the local minimum is reset to NULL. - **********************************************************************/ + */ void new_min_point(EDGEPT *local_min, POINT_GROUP points) { inT16 dir; @@ -348,13 +348,13 @@ void new_min_point(EDGEPT *local_min, POINT_GROUP points) { } -/********************************************************************** - * new_max_point +/** + * @name new_max_point * * Found a new minimum point try to decide whether to save it or not. * Return the new value for the local minimum. If a point is saved then * the local minimum is reset to NULL. - **********************************************************************/ + */ void new_max_point(EDGEPT *local_max, POINT_GROUP points) { inT16 dir; @@ -372,8 +372,8 @@ void new_max_point(EDGEPT *local_max, POINT_GROUP points) { } -/********************************************************************** - * vertical_projection_point +/** + * @name vertical_projection_point * * For one point on the outline, find the corresponding point on the * other side of the outline that is a likely projection for a split @@ -381,7 +381,7 @@ void new_max_point(EDGEPT *local_max, POINT_GROUP points) { * X value of the point being looked at is greater than the X value of * the split point. Ensure that the point being returned is not right * next to the split point. Return the edge point as a result. - **********************************************************************/ + */ void vertical_projection_point(EDGEPT *split_point, EDGEPT *target_point, EDGEPT** best_point) { EDGEPT *p; /* Iterator */ diff --git a/wordrec/chop.h b/wordrec/chop.h index 5dbc2b2c9c..d7447b32aa 100644 --- a/wordrec/chop.h +++ b/wordrec/chop.h @@ -78,12 +78,12 @@ extern INT_VAR_H(chop_x_y_weight, 3, "X / Y length weight"); /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** - * point_bend_angle +/** + * @name point_bend_angle * * Measure the angle of bend at this edge point. The argument should * be of type EDGEPT. - **********************************************************************/ + */ #define point_bend_angle(point) \ (angle_change ((point)->prev, (point), (point)->next)) diff --git a/wordrec/chopper.cpp b/wordrec/chopper.cpp index c0e2077b9c..4df7ca02e8 100644 --- a/wordrec/chopper.cpp +++ b/wordrec/chopper.cpp @@ -68,12 +68,12 @@ BOOL_VAR(fragments_guide_chopper, FALSE, /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** - * bounds_inside +/** + * @name bounds_inside * * Check to see if the bounding box of one thing is inside the * bounding box of another. - **********************************************************************/ + */ #define bounds_inside(inner_tl,inner_br,outer_tl,outer_br) \ ((inner_tl.x >= outer_tl.x) && \ (inner_tl.y <= outer_tl.y) && \ @@ -83,11 +83,11 @@ BOOL_VAR(fragments_guide_chopper, FALSE, /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * preserve_outline_tree +/** + * @name preserve_outline_tree * * Copy the list of outlines. - **********************************************************************/ + */ void preserve_outline(EDGEPT *start) { EDGEPT *srcpt; @@ -115,11 +115,11 @@ void preserve_outline_tree(TESSLINE *srcline) { } -/********************************************************************** - * restore_outline_tree +/** + * @name restore_outline_tree * * Copy the list of outlines. - **********************************************************************/ + */ EDGEPT *restore_outline(EDGEPT *start) { EDGEPT *srcpt; EDGEPT *real_start; @@ -166,12 +166,12 @@ void restore_outline_tree(TESSLINE *srcline) { } -/********************************************************************** - * attempt_blob_chop +/** + * @name attempt_blob_chop * * Try to split the this blob after this one. Check to make sure that * it was successful. - **********************************************************************/ + */ SEAM *attempt_blob_chop(TWERD *word, inT32 blob_number, SEAMS seam_list) { TBLOB *blob; TBLOB *other_blob; @@ -246,11 +246,11 @@ SEAM *attempt_blob_chop(TWERD *word, inT32 blob_number, SEAMS seam_list) { } -/********************************************************************** - * any_shared_split_points +/** + * @name any_shared_split_points * * Return true if any of the splits share a point with this one. - **********************************************************************/ + */ int any_shared_split_points(SEAMS seam_list, SEAM *seam) { int length; int index; @@ -263,11 +263,11 @@ int any_shared_split_points(SEAMS seam_list, SEAM *seam) { } -/********************************************************************** - * check_blob +/** + * @name check_blob * - * Return true if blob has a non whole outline. - **********************************************************************/ + * @return true if blob has a non whole outline. + */ int check_blob(TBLOB *blob) { TESSLINE *outline; EDGEPT *edgept; @@ -287,13 +287,13 @@ int check_blob(TBLOB *blob) { } -/********************************************************************** - * improve_one_blob +namespace tesseract { +/** + * @name improve_one_blob * * Start with the current word of blobs and its classification. Find * the worst blobs and try to divide it up to improve the ratings. - *********************************************************************/ -namespace tesseract { + */ bool Wordrec::improve_one_blob(TWERD *word, BLOB_CHOICE_LIST_VECTOR *char_choices, int fx, @@ -348,13 +348,13 @@ bool Wordrec::improve_one_blob(TWERD *word, return true; } -/********************************************************************** - * modify_blob_choice +/** + * @name modify_blob_choice * * Takes a blob and its chop index, converts that chop index to a * unichar_id, and stores the chop index in place of the blob's * original unichar_id. - *********************************************************************/ + */ void Wordrec::modify_blob_choice(BLOB_CHOICE_LIST *answer, int chop_index) { char chop_index_string[2]; @@ -377,13 +377,13 @@ void Wordrec::modify_blob_choice(BLOB_CHOICE_LIST *answer, answer_it.add_after_then_move(modified_blob); } -/********************************************************************** - * chop_one_blob +/** + * @name chop_one_blob * * Start with the current one-blob word and its classification. Find * the worst blobs and try to divide it up to improve the ratings. * Used for testing chopper. - *********************************************************************/ + */ bool Wordrec::chop_one_blob(TWERD *word, BLOB_CHOICE_LIST_VECTOR *char_choices, inT32 *blob_number, @@ -443,14 +443,14 @@ bool Wordrec::chop_one_blob(TWERD *word, } } // namespace tesseract -/********************************************************************** - * check_seam_order +/** + * @name check_seam_order * * Make sure that each of the splits in this seam match to outlines * in this blob. If any of the splits could not correspond to this * blob then there is a problem (and FALSE should be returned to the * caller). - **********************************************************************/ + */ inT16 check_seam_order(TBLOB *blob, SEAM *seam) { TESSLINE *outline; TESSLINE *last_outline; @@ -486,15 +486,15 @@ inT16 check_seam_order(TBLOB *blob, SEAM *seam) { return (TRUE); } -/********************************************************************** - * chop_word_main +namespace tesseract { +/** + * @name chop_word_main * * Classify the blobs in this word and permute the results. Find the * worst blob in the word and chop it up. Continue this process until * a good answer has been found or all the blobs have been chopped up * enough. Return the word level ratings. - **********************************************************************/ -namespace tesseract { + */ BLOB_CHOICE_LIST_VECTOR *Wordrec::chop_word_main(register TWERD *word, int fx, WERD_CHOICE *best_choice, @@ -605,15 +605,15 @@ BLOB_CHOICE_LIST_VECTOR *Wordrec::chop_word_main(register TWERD *word, -/********************************************************************** - * improve_by_chopping +/** + * @name improve_by_chopping * * Start with the current word of blobs and its classification. Find * the worst blobs and try to divide them up to improve the ratings. * As long as ratings are produced by the new blob splitting. When * all the splitting has been accomplished all the ratings memory is * reclaimed. - **********************************************************************/ + */ void Wordrec::improve_by_chopping(register TWERD *word, BLOB_CHOICE_LIST_VECTOR *char_choices, int fx, @@ -892,3 +892,4 @@ MATRIX *Wordrec::word_associator(TBLOB *blobs, } } // namespace tesseract + diff --git a/wordrec/closed.cpp b/wordrec/closed.cpp index 6e51e0cbc4..0fe14723b4 100644 --- a/wordrec/closed.cpp +++ b/wordrec/closed.cpp @@ -43,12 +43,12 @@ HASH_TABLE global_hash = NULL; /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * hash_add +/** + * @name hash_add * * Look in the hash table for a particular value. If it is not there * then add it. - **********************************************************************/ + */ int hash_add(HASH_TABLE state_table, STATE *state) { int x; int i = 0; @@ -79,12 +79,12 @@ int hash_add(HASH_TABLE state_table, STATE *state) { } -/********************************************************************** - * hash_lookup +/** + * @name hash_lookup * * Look in the hash table for a particular value. If the value is there * then return TRUE, FALSE otherwise. - **********************************************************************/ + */ int hash_lookup(HASH_TABLE state_table, STATE *state) { int x; int i = 0; @@ -114,11 +114,11 @@ int hash_lookup(HASH_TABLE state_table, STATE *state) { } -/********************************************************************** - * new_hash_table +/** + * @name new_hash_table * * Create and initialize a hash table. - **********************************************************************/ + */ HASH_TABLE new_hash_table() { HASH_TABLE ht; int x; diff --git a/wordrec/closed.h b/wordrec/closed.h index 6282877f1b..d5ed68d972 100644 --- a/wordrec/closed.h +++ b/wordrec/closed.h @@ -46,11 +46,11 @@ extern HASH_TABLE global_hash; /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** +/** * free_hash_table * * Free the memory taken by a state variable. - **********************************************************************/ + */ #define free_hash_table(table) \ global_hash = table diff --git a/wordrec/seam.cpp b/wordrec/seam.cpp index 88a128e24e..049c7c6bf5 100644 --- a/wordrec/seam.cpp +++ b/wordrec/seam.cpp @@ -46,12 +46,13 @@ freeseam, SEAMBLOCK, "SEAM", seamcount); /*---------------------------------------------------------------------- Public Function Code ----------------------------------------------------------------------*/ -/********************************************************************** - * point_in_split +/** + * @name point_in_split * * Check to see if either of these points are present in the current - * split. Return TRUE if one of them is. - **********************************************************************/ + * split. + * @returns TRUE if one of them is split. + */ bool point_in_split(SPLIT *split, EDGEPT *point1, EDGEPT *point2) { return ((split) ? ((exact_point (split->point1, point1) || @@ -61,12 +62,13 @@ bool point_in_split(SPLIT *split, EDGEPT *point1, EDGEPT *point2) { } -/********************************************************************** - * point_in_seam +/** + * @name point_in_seam * * Check to see if either of these points are present in the current - * seam. Return TRUE if one of them is. - **********************************************************************/ + * seam. + * @returns TRUE if one of them is. + */ bool point_in_seam(SEAM *seam, SPLIT *split) { return (point_in_split (seam->split1, split->point1, split->point2) || point_in_split (seam->split2, split->point1, split->point2) || @@ -74,23 +76,23 @@ bool point_in_seam(SEAM *seam, SPLIT *split) { } -/********************************************************************** - * add_seam +/** + * @name add_seam * * Add another seam to a collection of seams. - **********************************************************************/ + */ SEAMS add_seam(SEAMS seam_list, SEAM *seam) { return (array_push (seam_list, seam)); } -/********************************************************************** - * combine_seam +/** + * @name combine_seam * * Combine two seam records into a single seam. Move the split * references from the second seam to the first one. The argument * convention is patterned after strcpy. - **********************************************************************/ + */ void combine_seams(SEAM *dest_seam, SEAM *source_seam) { dest_seam->priority += source_seam->priority; dest_seam->location += source_seam->location; @@ -124,11 +126,11 @@ void combine_seams(SEAM *dest_seam, SEAM *source_seam) { } -/********************************************************************** - * delete_seam +/** + * @name delete_seam * * Free this seam record and the splits that are attached to it. - **********************************************************************/ + */ void delete_seam(void *arg) { //SEAM *seam) SEAM *seam = (SEAM *) arg; @@ -144,12 +146,12 @@ void delete_seam(void *arg) { //SEAM *seam) } -/********************************************************************** - * free_seam_list +/** + * @name free_seam_list * * Free all the seams that have been allocated in this list. Reclaim * the memory for each of the splits as well. - **********************************************************************/ + */ void free_seam_list(SEAMS seam_list) { int x; @@ -158,11 +160,11 @@ void free_seam_list(SEAMS seam_list) { } -/********************************************************************** - * test_insert_seam +/** + * @name test_insert_seam * - * Return true if insert_seam will succeed. - **********************************************************************/ + * @returns true if insert_seam will succeed. + */ bool test_insert_seam(SEAMS seam_list, int index, TBLOB *left_blob, @@ -192,12 +194,12 @@ bool test_insert_seam(SEAMS seam_list, return true; } -/********************************************************************** - * insert_seam +/** + * @name insert_seam * * Add another seam to a collection of seams at a particular location * in the seam array. - **********************************************************************/ + */ SEAMS insert_seam(SEAMS seam_list, int index, SEAM *seam, @@ -243,12 +245,12 @@ SEAMS insert_seam(SEAMS seam_list, } -/********************************************************************** - * account_splits_right +/** + * @name account_splits_right * * Account for all the splits by looking to the right. * in the blob list. - **********************************************************************/ + */ int account_splits_right(SEAM *seam, TBLOB *blob) { inT8 found_em[3]; inT8 width; @@ -277,12 +279,12 @@ int account_splits_right(SEAM *seam, TBLOB *blob) { } -/********************************************************************** - * account_splits_left +/** + * @name account_splits_left * * Account for all the splits by looking to the left. * in the blob list. - **********************************************************************/ + */ int account_splits_left(SEAM *seam, TBLOB *blob, TBLOB *end_blob) { static inT32 depth = 0; static inT8 width; @@ -315,11 +317,11 @@ int account_splits_left(SEAM *seam, TBLOB *blob, TBLOB *end_blob) { } -/********************************************************************** - * find_split_in_blob +/** + * @name find_split_in_blob * - * Return TRUE if the split is somewhere in this blob. - **********************************************************************/ + * @returns TRUE if the split is somewhere in this blob. + */ bool find_split_in_blob(SPLIT *split, TBLOB *blob) { TESSLINE *outline; @@ -341,12 +343,12 @@ bool find_split_in_blob(SPLIT *split, TBLOB *blob) { } -/********************************************************************** - * join_two_seams +/** + * @name join_two_seams * * Merge these two seams into a new seam. Duplicate the split records * in both of the input seams. Return the resultant seam. - **********************************************************************/ + */ SEAM *join_two_seams(SEAM *seam1, SEAM *seam2) { SEAM *result = NULL; SEAM *temp; @@ -365,13 +367,13 @@ SEAM *join_two_seams(SEAM *seam1, SEAM *seam2) { } -/********************************************************************** - * new_seam +/** + * @name new_seam * * Create a structure for a "seam" between two blobs. This data * structure may actually hold up to three different splits. * Initailization of this record is done by this routine. - **********************************************************************/ + */ SEAM *new_seam(PRIORITY priority, int x_location, SPLIT *split1, @@ -393,22 +395,22 @@ SEAM *new_seam(PRIORITY priority, } -/********************************************************************** - * new_seam_list +/** + * @name new_seam_list * * Create a collection of seam records in an array. - **********************************************************************/ + */ SEAMS new_seam_list() { return (array_new (NUM_STARTING_SEAMS)); } -/********************************************************************** - * print_seam +/** + * @name print_seam * * Print a list of splits. Show the coordinates of both points in * each split. - **********************************************************************/ + */ void print_seam(const char *label, SEAM *seam) { if (seam) { cprintf(label); @@ -431,12 +433,12 @@ void print_seam(const char *label, SEAM *seam) { } -/********************************************************************** - * print_seams +/** + * @name print_seams * * Print a list of splits. Show the coordinates of both points in * each split. - **********************************************************************/ + */ void print_seams(const char *label, SEAMS seams) { int x; char number[CHARS_PER_LINE]; @@ -452,13 +454,13 @@ void print_seams(const char *label, SEAMS seams) { } -/********************************************************************** - * shared_split_points +/** + * @name shared_split_points * * Check these two seams to make sure that neither of them have two * points in common. Return TRUE if any of the same points are present * in any of the splits of both seams. - **********************************************************************/ + */ int shared_split_points(SEAM *seam1, SEAM *seam2) { if (seam1 == NULL || seam2 == NULL) return (FALSE); diff --git a/wordrec/seam.h b/wordrec/seam.h index 65e5710337..e8793757e0 100644 --- a/wordrec/seam.h +++ b/wordrec/seam.h @@ -54,11 +54,11 @@ extern SEAM *newseam(); /*---------------------------------------------------------------------- M a c r o s ----------------------------------------------------------------------*/ -/********************************************************************** - * clone_seam +/** + * @name clone_seam * * Create a new seam record and copy the contents of this seam into it. - **********************************************************************/ + */ #define clone_seam(dest,source) \ if (source) { \ @@ -76,12 +76,12 @@ else { \ } \ -/********************************************************************** +/** * exact_point * * Return TRUE if the point positions are the exactly the same. The * parameters must be of type (EDGEPT*). - **********************************************************************/ + */ #define exact_point(p1,p2) \ (! ((p1->pos.x - p2->pos.x) || (p1->pos.y - p2->pos.y))) diff --git a/wordrec/tessinit.cpp b/wordrec/tessinit.cpp index f995eed745..8cf2ddbc45 100644 --- a/wordrec/tessinit.cpp +++ b/wordrec/tessinit.cpp @@ -47,12 +47,12 @@ int row_number; F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * program_init +namespace tesseract { +/** + * @name program_init * * Initialize all the things in the program that need to be initialized. - **********************************************************************/ -namespace tesseract { + */ void Wordrec::program_init() { /* Plots flags */ plots[OCR] = wordrec_plots_ocr; @@ -70,11 +70,11 @@ void Wordrec::program_init() { } // namespace tesseract -/********************************************************************** - * matherr +/** + * @name matherr * * Trap procedure for the Standard Math library - **********************************************************************/ + */ #ifdef __UNIX int matherr (error) diff --git a/wordrec/tface.cpp b/wordrec/tface.cpp index 8f80511afd..b53c6b3b13 100644 --- a/wordrec/tface.cpp +++ b/wordrec/tface.cpp @@ -63,12 +63,12 @@ BOOL_VAR(wordrec_no_block, false, "Don't output block information"); /*---------------------------------------------------------------------- Function Code ----------------------------------------------------------------------*/ -/********************************************************************** - * start_recog +namespace tesseract { +/** + * @name start_recog * * Startup recog program ready to recognize words. - **********************************************************************/ -namespace tesseract { + */ int Wordrec::start_recog(const char *textbase) { program_editup(textbase, true); @@ -76,13 +76,13 @@ int Wordrec::start_recog(const char *textbase) { } -/********************************************************************** - * program_editup +/** + * @name program_editup * * Initialize all the things in the program that need to be initialized. * init_permute determines whether to initialize the permute functions * and Dawg models. - **********************************************************************/ + */ void Wordrec::program_editup(const char *textbase, bool init_permute) { if (textbase != NULL) { imagefile = textbase; @@ -104,12 +104,12 @@ void Wordrec::program_editup(const char *textbase, bool init_permute) { } // namespace tesseract -/********************************************************************** - * edit_with_ocr +/** + * @name edit_with_ocr * * Initialize all the things in the program needed before the classifier * code is called. - **********************************************************************/ + */ void edit_with_ocr(const char *imagename) { char name[FILENAMESIZE]; /*base name of file */ @@ -135,11 +135,11 @@ void edit_with_ocr(const char *imagename) { } -/********************************************************************** - * end_recog +/** + * @name end_recog * * Cleanup and exit the recog program. - **********************************************************************/ + */ namespace tesseract { int Wordrec::end_recog() { program_editdown (0); @@ -148,12 +148,12 @@ int Wordrec::end_recog() { } -/********************************************************************** - * program_editdown +/** + * @name program_editdown * * This function holds any nessessary post processing for the Wise Owl * program. - **********************************************************************/ + */ void Wordrec::program_editdown(inT32 elasped_time) { dj_cleanup(); if (tord_display_text) @@ -188,11 +188,11 @@ void Wordrec::program_editdown(inT32 elasped_time) { } -/********************************************************************** - * set_pass1 +/** + * @name set_pass1 * * Get ready to do some pass 1 stuff. - **********************************************************************/ + */ void Wordrec::set_pass1() { tord_blob_skip.set_value(false); chop_ok_split.set_value(70.0); @@ -202,11 +202,11 @@ void Wordrec::set_pass1() { } -/********************************************************************** - * set_pass2 +/** + * @name set_pass2 * * Get ready to do some pass 2 stuff. - **********************************************************************/ + */ void Wordrec::set_pass2() { tord_blob_skip.set_value(false); chop_ok_split.set_value(pass2_ok_split); @@ -216,11 +216,11 @@ void Wordrec::set_pass2() { } -/********************************************************************** - * cc_recog +/** + * @name cc_recog * * Recognize a word. - **********************************************************************/ + */ BLOB_CHOICE_LIST_VECTOR *Wordrec::cc_recog(TWERD *tessword, WERD_CHOICE *best_choice, WERD_CHOICE *best_raw_choice, @@ -253,29 +253,29 @@ BLOB_CHOICE_LIST_VECTOR *Wordrec::cc_recog(TWERD *tessword, } -/********************************************************************** - * dict_word() +/** + * @name dict_word() * * Test the dictionaries, returning NO_PERM (0) if not found, or one * of the PermuterType values if found, according to the dictionary. - **********************************************************************/ + */ int Wordrec::dict_word(const WERD_CHOICE &word) { return getDict().valid_word(word); } -/********************************************************************** - * call_matcher +/** + * @name call_matcher * * Called from Tess with a blob in tess form. * Convert the blob to editor form. * Call the matcher setup by the segmenter in tess_matcher. * Convert the output choices back to tess form. - **********************************************************************/ -BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *ptblob, //previous - TBLOB *tessblob, //blob to match - TBLOB *ntblob, //next - void *, //unused parameter - TEXTROW * //always null anyway + */ +BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *ptblob, //< previous blob + TBLOB *tessblob, //< blob to match + TBLOB *ntblob, //< next blob + void *, //< unused parameter + TEXTROW * //< always null anyway ) { PBLOB *pblob; //converted blob PBLOB *blob; //converted blob @@ -310,14 +310,14 @@ BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *ptblob, //previous return ratings; } -/********************************************************************** - * make_ed_blob +/** + * @name make_ed_blob * * Make an editor format blob from the tess style blob. - **********************************************************************/ + */ PBLOB *make_ed_blob( //construct blob - TBLOB *tessblob //blob to convert + TBLOB *tessblob //< blob to convert ) { TESSLINE *tessol; //tess outline FRAGMENT_LIST fragments; //list of fragments @@ -339,14 +339,14 @@ PBLOB *make_ed_blob( //construct blob return NULL; //couldn't do it return new PBLOB (&out_list); //turn to blob } -/********************************************************************** - * make_ed_outline +/** + * @name make_ed_outline * * Make an editor format outline from the list of fragments. - **********************************************************************/ + */ OUTLINE *make_ed_outline( //constructoutline - FRAGMENT_LIST *list //list of fragments + FRAGMENT_LIST *list //< list of fragments ) { FRAGMENT *fragment; //current fragment EDGEPT *edgept; //current point @@ -399,15 +399,15 @@ OUTLINE *make_ed_outline( //constructoutline while (tailpos != headpos); return new OUTLINE (&poly_it); //turn to outline } -/********************************************************************** - * register_outline +/** + * @name register_outline * * Add the fragments in the given outline to the list - **********************************************************************/ + */ void register_outline( //add fragments - TESSLINE *outline, //tess format - FRAGMENT_LIST *list //list to add to + TESSLINE *outline, //< tess format + FRAGMENT_LIST *list //< list to add to ) { EDGEPT *startpt; //start of outline EDGEPT *headpt; //start of fragment @@ -446,14 +446,14 @@ void register_outline( //add fragments ELISTIZE (FRAGMENT) -/********************************************************************** - * FRAGMENT::FRAGMENT +/** + * @name FRAGMENT::FRAGMENT * * Constructor for fragments. - **********************************************************************/ + */ FRAGMENT::FRAGMENT ( //constructor -EDGEPT * head_pt, //start point -EDGEPT * tail_pt //end point +EDGEPT * head_pt, //< start point +EDGEPT * tail_pt //< end point ):head (head_pt->pos.x, head_pt->pos.y), tail (tail_pt->pos.x, tail_pt->pos.y) { headpt = head_pt; // save ptrs diff --git a/wordrec/wordclass.cpp b/wordrec/wordclass.cpp index 1633bcc9e1..6b9b77c6f4 100644 --- a/wordrec/wordclass.cpp +++ b/wordrec/wordclass.cpp @@ -69,19 +69,26 @@ inT16 first_pass; /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ -/********************************************************************** - * classify_blob +namespace tesseract { +/** + * @name classify_blob * * Classify the this blob if it is not already recorded in the match * table. Attempt to recognize this blob as a character. The recognition * rating for this blob will be stored as a part of the blob. This value * will also be returned to the caller. - **********************************************************************/ -namespace tesseract { + * + * @param pblob Previous blob + * @param blob Current blob + * @param nlob Next blob + * @param row The row to process + * @param string The string to display in ScrollView + * @param color The colour to use when displayed with ScrollView + */ BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *pblob, TBLOB *blob, TBLOB *nblob, - TEXTROW *row, + TEXTROW *row, const char *string, C_COL color) { BLOB_CHOICE_LIST *choices = NULL; @@ -108,12 +115,12 @@ BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *pblob, return (choices); } -/********************************************************************** - * update_blob_classifications +/** + * @name update_blob_classifications * * For each blob in the given word update match_table with the * corresponding BLOB_CHOICES_LIST from choices. - * **********************************************************************/ + */ void Wordrec::update_blob_classifications( TWERD *word, const BLOB_CHOICE_LIST_VECTOR &choices) { TBLOB *tblob = word->blobs; @@ -127,12 +134,12 @@ void Wordrec::update_blob_classifications( } // namespace tesseract; -/********************************************************************** - * write_text_files +/** + * @name write_text_files * * Write an answer to the output file that is the raw guess (without * context) directly from the classifier. - **********************************************************************/ + */ void write_text_files(TWERD *word, char *raw_choice, int same_row,