Tesseract  3.02
tesseract-ocr/wordrec/matchtab.h
Go to the documentation of this file.
00001 /* -*-C-*-
00002  ********************************************************************************
00003  *
00004  * File:        matchtab.h  (Formerly matchtab.h)
00005  * Description:  Match table to retain blobs that were matched.
00006  * Author:       Mark Seaman, OCR Technology
00007  * Created:      Mon Jan 29 09:00:56 1990
00008  * Modified:     Tue Mar 19 15:38:19 1991 (Mark Seaman) marks@hpgrlt
00009  * Language:     C
00010  * Package:      N/A
00011  * Status:       Experimental (Do Not Distribute)
00012  *
00013  * (c) Copyright 1990, Hewlett-Packard Company.
00014  ** Licensed under the Apache License, Version 2.0 (the "License");
00015  ** you may not use this file except in compliance with the License.
00016  ** You may obtain a copy of the License at
00017  ** http://www.apache.org/licenses/LICENSE-2.0
00018  ** Unless required by applicable law or agreed to in writing, software
00019  ** distributed under the License is distributed on an "AS IS" BASIS,
00020  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  ** See the License for the specific language governing permissions and
00022  ** limitations under the License.
00023  *
00024  *********************************************************************************/
00025 #ifndef MATCHTAB_H
00026 #define MATCHTAB_H
00027 
00028 #include "ratngs.h"
00029 #include "blobs.h"
00030 
00031 namespace tesseract {
00032 
00033 struct MATCH {
00034   MATCH() : rating(NULL) {}
00035   TBOX box;
00036   BLOB_CHOICE_LIST *rating;
00037 };
00038 
00039 // A class for mapping rectangular bounding boxes to choice lists.
00040 // Only meant to be used at the word level, as we have a limit of
00041 // 500 recognition lists for all subsequences of blobs.
00042 class BlobMatchTable {
00043  public:
00044   BlobMatchTable();
00045   ~BlobMatchTable();
00046 
00047   void init_match_table();
00048   void end_match_table();
00049   void put_match(TBLOB *blob, BLOB_CHOICE_LIST *ratings);
00050   BLOB_CHOICE_LIST *get_match(TBLOB *blob);
00051   BLOB_CHOICE_LIST *get_match_by_box(const TBOX &box);
00052   void add_to_match(TBLOB *blob, BLOB_CHOICE_LIST *ratings);
00053 
00054  private:
00055   int Hash(const TBOX &box) const;
00056   // Returns whether the idx entry in the array is still empty.
00057   bool IsEmpty(int idx) const;
00058 
00059   bool been_initialized_;
00060   MATCH* match_table_;
00061 };
00062 
00063 }
00064 #endif