• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**********************************************************************
2  * File:        boxread.cpp
3  * Description: Read data from a box file.
4  * Author:		Ray Smith
5  * Created:		Fri Aug 24 17:47:23 PDT 2007
6  *
7  * (C) Copyright 2007, Google Inc.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef TESSERACT_CCUTIL_BOXREAD_H__
21 #define TESSERACT_CCUTIL_BOXREAD_H__
22 
23 #include <stdio.h>
24 
25 // Size of buffer used to read a line from a box file.
26 const int kBoxReadBufSize = 256;
27 
28 // read_next_box factors out the code to interpret a line of a box
29 // file so that applybox and unicharset_extractor interpret the same way.
30 // This function returns the next valid box file utf8 string and coords
31 // and returns true, or false on eof (and closes the file).
32 // If ignores the uft8 file signature, checks for valid utf-8 and allows
33 // space or tab between fields.
34 // utf8_str must be at least kBoxReadBufSize in length.
35 // If there are page numbers in the file, it reads them all.
36 bool read_next_box(FILE* box_file, char* utf8_str,
37                    int* x_min, int* y_min, int* x_max, int* y_max);
38 // As read_next_box above, but get a specific page number. (0-based)
39 // Use -1 to read any page number. Files without page number all
40 // read as if they are page 0.
41 bool read_next_box(int page, FILE* box_file, char* utf8_str,
42                    int* x_min, int* y_min, int* x_max, int* y_max);
43 
44 #endif  // TESSERACT_CCUTIL_BOXREAD_H__
45