tesseract 4.1.1
Loading...
Searching...
No Matches
workingpartset.h
Go to the documentation of this file.
1
2// File: workingpartset.h
3// Description: Class to hold a working set of partitions of the page
4// during construction of text/image regions.
5// Author: Ray Smith
6// Created: Tue Ocr 28 17:21:01 PDT 2008
7//
8// (C) Copyright 2008, Google Inc.
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12// http://www.apache.org/licenses/LICENSE-2.0
13// Unless required by applicable law or agreed to in writing, software
14// distributed under the License is distributed on an "AS IS" BASIS,
15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16// See the License for the specific language governing permissions and
17// limitations under the License.
18//
20
21#ifndef TESSERACT_TEXTORD_WORKINGPARSET_H_
22#define TESSERACT_TEXTORD_WORKINGPARSET_H_
23
24#include "blobbox.h" // For TO_BLOCK_LIST and BLOCK_LIST.
25#include "colpartition.h" // For ColPartition_LIST.
26
27namespace tesseract {
28
29// WorkingPartSet holds a working set of ColPartitions during transformation
30// from the grid-based storage to regions in logical reading order, and is
31// therefore only used during construction of the regions.
32class WorkingPartSet : public ELIST_LINK {
33 public:
35 : column_(column), latest_part_(nullptr), part_it_(&part_set_) {
36 }
37
38 // Simple accessors.
40 return column_;
41 }
43 column_ = col;
44 }
45
46 // Add the partition to this WorkingPartSet. Partitions are generally
47 // stored in the order in which they are received, but if the partition
48 // has a SingletonPartner, make sure that it stays with its partner.
49 void AddPartition(ColPartition* part);
50
51 // Make blocks out of any partitions in this WorkingPartSet, and append
52 // them to the end of the blocks list. bleft, tright and resolution give
53 // the bounds and resolution of the source image, so that blocks can be
54 // made to fit in the bounds.
55 // All ColPartitions go in the used_parts list, as they need to be kept
56 // around, but are no longer needed.
57 void ExtractCompletedBlocks(const ICOORD& bleft, const ICOORD& tright,
58 int resolution, ColPartition_LIST* used_parts,
59 BLOCK_LIST* blocks, TO_BLOCK_LIST* to_blocks);
60
61 // Insert the given blocks at the front of the completed_blocks_ list so
62 // they can be kept in the correct reading order.
63 void InsertCompletedBlocks(BLOCK_LIST* blocks, TO_BLOCK_LIST* to_blocks);
64
65 private:
66 // Convert the part_set_ into blocks, starting a new block at a break
67 // in partnerships, or a change in linespacing (for text).
68 void MakeBlocks(const ICOORD& bleft, const ICOORD& tright, int resolution,
69 ColPartition_LIST* used_parts);
70
71 // The column that this working set applies to. Used by the caller.
72 ColPartition* column_;
73 // The most recently added partition.
74 ColPartition* latest_part_;
75 // All the partitions in the block that is currently under construction.
76 ColPartition_LIST part_set_;
77 // Iteratorn on part_set_ pointing to the most recent addition.
78 ColPartition_IT part_it_;
79 // The blocks that have been made so far and belong before the current block.
80 BLOCK_LIST completed_blocks_;
81 TO_BLOCK_LIST to_blocks_;
82};
83
84ELISTIZEH(WorkingPartSet)
85
86} // namespace tesseract.
87
88#endif // TESSERACT_TEXTORD_WORKINGPARSET_H_
#define ELISTIZEH(CLASSNAME)
Definition: elst.h:918
integer coordinate
Definition: points.h:32
void set_column(ColPartition *col)
ColPartition * column() const
void AddPartition(ColPartition *part)
void ExtractCompletedBlocks(const ICOORD &bleft, const ICOORD &tright, int resolution, ColPartition_LIST *used_parts, BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
void InsertCompletedBlocks(BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
WorkingPartSet(ColPartition *column)