|
| PageIterator (PAGE_RES *page_res, Tesseract *tesseract, int scale, int scaled_yres, int rect_left, int rect_top, int rect_width, int rect_height) |
|
virtual | ~PageIterator () |
|
| PageIterator (const PageIterator &src) |
|
const PageIterator & | operator= (const PageIterator &src) |
|
bool | PositionedAtSameWord (const PAGE_RES_IT *other) const |
|
virtual void | Begin () |
|
virtual void | RestartParagraph () |
|
bool | IsWithinFirstTextlineOfParagraph () const |
|
virtual void | RestartRow () |
|
virtual bool | Next (PageIteratorLevel level) |
|
virtual bool | IsAtBeginningOf (PageIteratorLevel level) const |
|
virtual bool | IsAtFinalElement (PageIteratorLevel level, PageIteratorLevel element) const |
|
int | Cmp (const PageIterator &other) const |
|
void | SetBoundingBoxComponents (bool include_upper_dots, bool include_lower_dots) |
|
bool | BoundingBox (PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const |
|
bool | BoundingBox (PageIteratorLevel level, const int padding, int *left, int *top, int *right, int *bottom) const |
|
bool | BoundingBoxInternal (PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const |
|
bool | Empty (PageIteratorLevel level) const |
|
PolyBlockType | BlockType () const |
|
Pta * | BlockPolygon () const |
|
Pix * | GetBinaryImage (PageIteratorLevel level) const |
|
Pix * | GetImage (PageIteratorLevel level, int padding, Pix *original_img, int *left, int *top) const |
|
bool | Baseline (PageIteratorLevel level, int *x1, int *y1, int *x2, int *y2) const |
|
void | Orientation (tesseract::Orientation *orientation, tesseract::WritingDirection *writing_direction, tesseract::TextlineOrder *textline_order, float *deskew_angle) const |
|
void | ParagraphInfo (tesseract::ParagraphJustification *justification, bool *is_list_item, bool *is_crown, int *first_line_indent) const |
|
bool | SetWordBlamerBundle (BlamerBundle *blamer_bundle) |
|
Class to iterate over tesseract page structure, providing access to all levels of the page hierarchy, without including any tesseract headers or having to handle any tesseract structures. WARNING! This class points to data held within the TessBaseAPI class, and therefore can only be used while the TessBaseAPI class still exists and has not been subjected to a call of Init, SetImage, Recognize, Clear, End DetectOS, or anything else that changes the internal PAGE_RES. See apitypes.h for the definition of PageIteratorLevel. See also ResultIterator, derived from PageIterator, which adds in the ability to access OCR output with text-specific methods.
tesseract::PageIterator::PageIterator |
( |
const PageIterator & |
src | ) |
|
Page/ResultIterators may be copied! This makes it possible to iterate over all the objects at a lower level, while maintaining an iterator to objects at a higher level. These constructors DO NOT CALL Begin, so iterations will continue from the location of src.
PageIterators may be copied! This makes it possible to iterate over all the objects at a lower level, while maintaining an iterator to objects at a higher level.
bool tesseract::PageIterator::Baseline |
( |
PageIteratorLevel |
level, |
|
|
int * |
x1, |
|
|
int * |
y1, |
|
|
int * |
x2, |
|
|
int * |
y2 |
|
) |
| const |
Returns the baseline of the current object at the given level. The baseline is the line that passes through (x1, y1) and (x2, y2). WARNING: with vertical text, baselines may be vertical! Returns false if there is no baseline at the current position.
Returns the baseline of the current object at the given level. The baseline is the line that passes through (x1, y1) and (x2, y2). WARNING: with vertical text, baselines may be vertical!
Returns a binary image of the current object at the given level. The position and size match the return from BoundingBoxInternal, and so this could be upscaled with respect to the original input image. Use pixDestroy to delete the image after use.
Returns a binary image of the current object at the given level. The position and size match the return from BoundingBoxInternal, and so this could be upscaled with respect to the original input image. Use pixDestroy to delete the image after use. The following methods are used to generate the images: RIL_BLOCK: mask the page image with the block polygon. RIL_TEXTLINE: Clip the rectangle of the line box from the page image. TODO(rays) fix this to generate and use a line polygon. RIL_WORD: Clip the rectangle of the word box from the page image. RIL_SYMBOL: Render the symbol outline to an image for cblobs (prior to recognition) or the bounding box otherwise. A reconstruction of the original image (using xor to check for double representation) should be reasonably accurate, apart from removed noise, at the block level. Below the block level, the reconstruction will be missing images and line separators. At the symbol level, kerned characters will be invade the bounding box if rendered after recognition, making an xor reconstruction inaccurate, but an or construction better. Before recognition, symbol-level reconstruction should be good, even with xor, since the images come from the connected components.
Returns true if the iterator is at the start of an object at the given level.
For instance, suppose an iterator it is pointed to the first symbol of the first word of the third line of the second paragraph of the first block in a page, then: it.IsAtBeginningOf(RIL_BLOCK) = false it.IsAtBeginningOf(RIL_PARA) = false it.IsAtBeginningOf(RIL_TEXTLINE) = true it.IsAtBeginningOf(RIL_WORD) = true it.IsAtBeginningOf(RIL_SYMBOL) = true
Returns true if the iterator is at the start of an object at the given level. Possible uses include determining if a call to Next(RIL_WORD) moved to the start of a RIL_PARA.
Reimplemented in tesseract::ResultIterator.
Returns whether the iterator is positioned at the last element in a given level. (e.g. the last word in a line, the last line in a block)
Here's some two-paragraph example
text. It starts off innocuously enough but quickly turns bizarre. The author inserts a cornucopia of words to guard against confused references.
Now take an iterator it pointed to the start of "bizarre." it.IsAtFinalElement(RIL_PARA, RIL_SYMBOL) = false it.IsAtFinalElement(RIL_PARA, RIL_WORD) = true it.IsAtFinalElement(RIL_BLOCK, RIL_WORD) = false
Returns whether the iterator is positioned at the last element in a given level. (e.g. the last word in a line, the last line in a block)
Reimplemented in tesseract::ResultIterator.
Moves to the start of the next object at the given level in the page hierarchy, and returns false if the end of the page was reached. NOTE that RIL_SYMBOL will skip non-text blocks, but all other PageIteratorLevel level values will visit each non-text block once. Think of non text blocks as containing a single para, with a single line, with a single imaginary word. Calls to Next with different levels may be freely intermixed. This function iterates words in right-to-left scripts correctly, if the appropriate language has been loaded into Tesseract.
Moves to the start of the next object at the given level in the page hierarchy, and returns false if the end of the page was reached. NOTE (CHANGED!) that ALL PageIteratorLevel level values will visit each non-text block at least once. Think of non text blocks as containing a single para, with at least one line, with a single imaginary word, containing a single symbol. The bounding boxes mark out any polygonal nature of the block, and PTIsTextType(BLockType()) is false for non-text blocks. Calls to Next with different levels may be freely intermixed. This function iterates words in right-to-left scripts correctly, if the appropriate language has been loaded into Tesseract.
Reimplemented in tesseract::ResultIterator.
void tesseract::PageIterator::ParagraphInfo |
( |
tesseract::ParagraphJustification * |
justification, |
|
|
bool * |
is_list_item, |
|
|
bool * |
is_crown, |
|
|
int * |
first_line_indent |
|
) |
| const |
Returns information about the current paragraph, if available.
justification - LEFT if ragged right, or fully justified and script is left-to-right. RIGHT if ragged left, or fully justified and script is right-to-left. unknown if it looks like source code or we have very few lines. is_list_item - true if we believe this is a member of an ordered or unordered list. is_crown - true if the first line of the paragraph is aligned with the other lines of the paragraph even though subsequent paragraphs have first line indents. This typically indicates that this is the continuation of a previous paragraph or that it is the very first paragraph in the chapter. first_line_indent - For LEFT aligned paragraphs, the first text line of paragraphs of this kind are indented this many pixels from the left edge of the rest of the paragraph. for RIGHT aligned paragraphs, the first text line of paragraphs of this kind are indented this many pixels from the right edge of the rest of the paragraph. NOTE 1: This value may be negative. NOTE 2: if *is_crown == true, the first line of this paragraph is actually flush, and first_line_indent is set to the "common" first_line_indent for subsequent paragraphs in this block of text.
void tesseract::PageIterator::SetBoundingBoxComponents |
( |
bool |
include_upper_dots, |
|
|
bool |
include_lower_dots |
|
) |
| |
|
inline |
Controls what to include in a bounding box. Bounding boxes of all levels between RIL_WORD and RIL_BLOCK can include or exclude potential diacritics. Between layout analysis and recognition, it isn't known where all diacritics belong, so this control is used to include or exclude some diacritics that are above or below the main body of the word. In most cases where the placement is obvious, and after recognition, it doesn't make as much difference, as the diacritics will already be included in the word.