Update Tesseract to version 5.0.

This commit is contained in:
Damiano Galassi committed 2021-12-07 12:05:31 +01:00
1 parent f9492c57bc
commit 8cffa8c9bb
32 files changed
+1119 -12894

No files matched your search

+42 -40
View File
@@ -3,7 +3,6 @@
// Description: Iterator for tesseract page structure that avoids using
// tesseract internal data structures.
// Author: Ray Smith
// Created: Fri Feb 26 11:01:06 PST 2010
//
// (C) Copyright 2010, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,18 +20,19 @@
#ifndef TESSERACT_CCMAIN_PAGEITERATOR_H_
#define TESSERACT_CCMAIN_PAGEITERATOR_H_
#include "export.h"
#include "publictypes.h"
#include "platform.h"
struct Pix;
struct Pta;
namespace tesseract {
struct BlamerBundle;
class C_BLOB_IT;
class PAGE_RES;
class PAGE_RES_IT;
class WERD;
struct Pix;
struct Pta;
namespace tesseract {
class Tesseract;
@@ -44,13 +44,13 @@ class Tesseract;
* 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 tesseract/publictypes.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.
*/
class TESS_API PageIterator {
public:
public:
/**
* page_res and tesseract come directly from the BaseAPI.
* The rectangle parameters are copied indirectly from the Thresholder,
@@ -65,10 +65,9 @@ class TESS_API PageIterator {
* that tesseract has been given by the Thresholder.
* After the constructor, Begin has already been called.
*/
PageIterator(PAGE_RES* page_res, Tesseract* tesseract,
int scale, int scaled_yres,
int rect_left, int rect_top,
int rect_width, int rect_height);
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();
/**
@@ -77,11 +76,11 @@ class TESS_API PageIterator {
* objects at a higher level. These constructors DO NOT CALL Begin, so
* iterations will continue from the location of src.
*/
PageIterator(const PageIterator& src);
const PageIterator& operator=(const PageIterator& src);
PageIterator(const PageIterator &src);
const PageIterator &operator=(const PageIterator &src);
/** Are we positioned at the same location as other? */
bool PositionedAtSameWord(const PAGE_RES_IT* other) const;
bool PositionedAtSameWord(const PAGE_RES_IT *other) const;
// ============= Moving around within the page ============.
@@ -203,24 +202,24 @@ class TESS_API PageIterator {
* from a grey image. The padding argument to GetImage can be used to expand
* the image to include more foreground pixels. See GetImage below.
*/
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 BoundingBox(PageIteratorLevel level, int *left, int *top, int *right,
int *bottom) const;
bool BoundingBox(PageIteratorLevel level, int padding, int *left, int *top,
int *right, int *bottom) const;
/**
* Returns the bounding rectangle of the object in a coordinate system of the
* working image rectangle having its origin at (rect_left_, rect_top_) with
* respect to the original image and is scaled by a factor scale_.
*/
bool BoundingBoxInternal(PageIteratorLevel level,
int* left, int* top, int* right, int* bottom) const;
bool BoundingBoxInternal(PageIteratorLevel level, int *left, int *top,
int *right, int *bottom) const;
/** Returns whether there is no object of a given level. */
bool Empty(PageIteratorLevel level) const;
/**
* Returns the type of the current block. See apitypes.h for
* PolyBlockType.
* Returns the type of the current block.
* See tesseract/publictypes.h for PolyBlockType.
*/
PolyBlockType BlockType() const;
@@ -231,7 +230,7 @@ class TESS_API PageIterator {
* point and the first point. nullptr will be returned if the iterator is
* at the end of the document or layout analysis was not used.
*/
Pta* BlockPolygon() const;
Pta *BlockPolygon() const;
/**
* Returns a binary image of the current object at the given level.
@@ -239,7 +238,7 @@ class TESS_API PageIterator {
* this could be upscaled with respect to the original input image.
* Use pixDestroy to delete the image after use.
*/
Pix* GetBinaryImage(PageIteratorLevel level) const;
Pix *GetBinaryImage(PageIteratorLevel level) const;
/**
* Returns an image of the current object at the given level in greyscale
@@ -252,8 +251,8 @@ class TESS_API PageIterator {
* If you do not supply an original image, you will get a binary one.
* Use pixDestroy to delete the image after use.
*/
Pix* GetImage(PageIteratorLevel level, int padding, Pix* original_img,
int* left, int* top) const;
Pix *GetImage(PageIteratorLevel level, int padding, Pix *original_img,
int *left, int *top) const;
/**
* Returns the baseline of the current object at the given level.
@@ -261,8 +260,12 @@ class TESS_API PageIterator {
* WARNING: with vertical text, baselines may be vertical!
* Returns false if there is no baseline at the current position.
*/
bool Baseline(PageIteratorLevel level,
int* x1, int* y1, int* x2, int* y2) const;
bool Baseline(PageIteratorLevel level, int *x1, int *y1, int *x2,
int *y2) const;
// Returns the attributes of the current row.
void RowAttributes(float *row_height, float *descenders,
float *ascenders) const;
/**
* Returns orientation for the block the iterator points to.
@@ -306,8 +309,7 @@ class TESS_API PageIterator {
* of text.
*/
void ParagraphInfo(tesseract::ParagraphJustification *justification,
bool *is_list_item,
bool *is_crown,
bool *is_list_item, bool *is_crown,
int *first_line_indent) const;
// If the current WERD_RES (it_->word()) is not nullptr, sets the BlamerBundle
@@ -316,27 +318,27 @@ class TESS_API PageIterator {
// Can only be used when iterating on the word level.
bool SetWordBlamerBundle(BlamerBundle *blamer_bundle);
protected:
protected:
/**
* Sets up the internal data for iterating the blobs of a new word, then
* moves the iterator to the given offset.
*/
TESS_LOCAL void BeginWord(int offset);
void BeginWord(int offset);
/** Pointer to the page_res owned by the API. */
PAGE_RES* page_res_;
PAGE_RES *page_res_;
/** Pointer to the Tesseract object owned by the API. */
Tesseract* tesseract_;
Tesseract *tesseract_;
/**
* The iterator to the page_res_. Owned by this ResultIterator.
* A pointer just to avoid dragging in Tesseract includes.
*/
PAGE_RES_IT* it_;
PAGE_RES_IT *it_;
/**
* The current input WERD being iterated. If there is an output from OCR,
* then word_ is nullptr. Owned by the API
*/
WERD* word_;
WERD *word_;
/** The length of the current word_. */
int word_length_;
/** The current blob index within the word. */
@@ -346,7 +348,7 @@ class TESS_API PageIterator {
* OCR results in the box_word.
* Owned by this ResultIterator.
*/
C_BLOB_IT* cblob_it_;
C_BLOB_IT *cblob_it_;
/** Control over what to include in bounding boxes. */
bool include_upper_dots_;
bool include_lower_dots_;
@@ -359,6 +361,6 @@ class TESS_API PageIterator {
int rect_height_;
};
} // namespace tesseract.
} // namespace tesseract.
#endif // TESSERACT_CCMAIN_PAGEITERATOR_H_
#endif // TESSERACT_CCMAIN_PAGEITERATOR_H_