00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: bestfirst.h (Formerly bestfirst.h) 00005 * Description: Best first search functions 00006 * Author: Mark Seaman, OCR Technology 00007 * Created: Mon May 14 11:23:29 1990 00008 * Modified: Mon Apr 29 14:21:57 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 00026 #ifndef BESTFIRST_H 00027 #define BESTFIRST_H 00028 00029 /*---------------------------------------------------------------------- 00030 I n c l u d e s 00031 ----------------------------------------------------------------------*/ 00032 00033 #include "associate.h" 00034 #include "blobs.h" 00035 #include "closed.h" 00036 #include "oldheap.h" 00037 #include "ratngs.h" 00038 #include "seam.h" 00039 #include "states.h" 00040 #include "stopper.h" 00041 #include "tessclas.h" 00042 00043 /*---------------------------------------------------------------------- 00044 T y p e s 00045 ----------------------------------------------------------------------*/ 00046 struct SEARCH_RECORD 00047 { 00048 HEAP *open_states; 00049 HASH_TABLE closed_states; 00050 STATE *this_state; 00051 STATE *first_state; 00052 STATE *best_state; 00053 int num_joints; 00054 long num_states; 00055 long before_best; 00056 float segcost_bias; 00057 WERD_CHOICE *best_choice; 00058 WERD_CHOICE *raw_choice; 00059 }; 00060 00061 /*---------------------------------------------------------------------- 00062 V a r i a b l e s 00063 ---------------------------------------------------------------------*/ 00064 extern INT_VAR_H(wordrec_num_seg_states, 30, "Segmentation states"); 00065 00066 extern double_VAR_H(wordrec_worst_state, 1, "Worst segmentation state"); 00067 00068 00069 /*---------------------------------------------------------------------- 00070 F u n c t i o n s 00071 ----------------------------------------------------------------------*/ 00072 int chunks_width(WIDTH_RECORD *width_record, int start_chunk, int last_chunk); 00073 int chunks_gap(WIDTH_RECORD *width_record, int last_chunk); 00074 00075 void delete_search(SEARCH_RECORD *the_search); 00076 00077 SEARCH_RECORD *new_search(CHUNKS_RECORD *chunks_record, 00078 int num_joints, 00079 WERD_CHOICE *best_choice, 00080 WERD_CHOICE *raw_choice, 00081 STATE *state); 00082 00083 STATE *pop_queue(HEAP *queue); 00084 00085 void push_queue(HEAP *queue, STATE *state, 00086 FLOAT32 worst_priority, FLOAT32 priority); 00087 00088 void replace_char_widths(CHUNKS_RECORD *chunks_record, SEARCH_STATE state); 00089 00090 // Joins blobs between index x and y, hides corresponding seams and 00091 // returns classification of the resulting merged blob. 00092 BLOB_CHOICE_LIST *join_blobs_and_classify(TBLOB *blobs, SEAMS seam_list, 00093 int x, int y, int fx); 00094 #endif