Tesseract 3.01
|
00001 /********************************************************************** 00002 * File: boxread.cpp 00003 * Description: Read data from a box file. 00004 * Author: Ray Smith 00005 * Created: Fri Aug 24 17:47:23 PDT 2007 00006 * 00007 * (C) Copyright 2007, Google Inc. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef TESSERACT_CCUTIL_BOXREAD_H__ 00021 #define TESSERACT_CCUTIL_BOXREAD_H__ 00022 00023 #include <stdio.h> 00024 #include "strngs.h" 00025 00026 // Size of buffer used to read a line from a box file. 00027 const int kBoxReadBufSize = 1024; 00028 00029 // Open the boxfile based on the given image filename. 00030 FILE* OpenBoxFile(const STRING& fname); 00031 00032 // read_next_box factors out the code to interpret a line of a box 00033 // file so that applybox and unicharset_extractor interpret the same way. 00034 // This function returns the next valid box file utf8 string and coords 00035 // and returns true, or false on eof (and closes the file). 00036 // If ignores the uft8 file signature, checks for valid utf-8 and allows 00037 // space or tab between fields. 00038 // utf8_str must be at least kBoxReadBufSize in length. 00039 // If there are page numbers in the file, it reads them all. 00040 bool read_next_box(int *line_number, FILE* box_file, char* utf8_str, 00041 int* x_min, int* y_min, int* x_max, int* y_max); 00042 // As read_next_box above, but get a specific page number. (0-based) 00043 // Use -1 to read any page number. Files without page number all 00044 // read as if they are page 0. 00045 bool read_next_box(int page, int *line_number, FILE* box_file, char* utf8_str, 00046 int* x_min, int* y_min, int* x_max, int* y_max); 00047 00048 #endif // TESSERACT_CCUTIL_BOXREAD_H__