tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
tesseract::TessResultRenderer Class Referenceabstract

#include <renderer.h>

Inheritance diagram for tesseract::TessResultRenderer:
Collaboration diagram for tesseract::TessResultRenderer:

Public Member Functions

virtual ~TessResultRenderer ()
 
void insert (TessResultRenderer *next)
 
TessResultRenderernext ()
 
bool BeginDocument (const char *title)
 
bool AddImage (TessBaseAPI *api)
 
bool EndDocument ()
 
const char * file_extension () const
 
const char * title () const
 
bool happy ()
 
int imagenum () const
 

Protected Member Functions

 TessResultRenderer (const char *outputbase, const char *extension)
 
virtual bool BeginDocumentHandler ()
 
virtual bool AddImageHandler (TessBaseAPI *api)=0
 
virtual bool EndDocumentHandler ()
 
void AppendString (const char *s)
 
void AppendData (const char *s, int len)
 

Private Attributes

const char * file_extension_
 
STRING title_
 
int imagenum_
 
FILE * fout_
 
TessResultRenderernext_
 
bool happy_
 

Detailed Description

Interface for rendering tesseract results into a document, such as text, HOCR or pdf. This class is abstract. Specific classes handle individual formats. This interface is then used to inject the renderer class into tesseract when processing images.

For simplicity implementing this with tesesract version 3.01, the renderer contains document state that is cleared from document to document just as the TessBaseAPI is. This way the base API can just delegate its rendering functionality to injected renderers, and the renderers can manage the associated state needed for the specific formats in addition to the heuristics for producing it.

Constructor & Destructor Documentation

◆ ~TessResultRenderer()

tesseract::TessResultRenderer::~TessResultRenderer ( )
virtual

◆ TessResultRenderer()

tesseract::TessResultRenderer::TessResultRenderer ( const char *  outputbase,
const char *  extension 
)
protected

Called by concrete classes.

outputbase is the name of the output file excluding extension. For example, "/path/to/chocolate-chip-cookie-recipe"

extension indicates the file extension to be used for output files. For example "pdf" will produce a .pdf file, and "hocr" will produce .hocr files.

Member Function Documentation

◆ AddImage()

bool tesseract::TessResultRenderer::AddImage ( TessBaseAPI api)

Adds the recognized text from the source image to the current document. Invalid if BeginDocument not yet called.

Note that this API is a bit weird but is designed to fit into the current TessBaseAPI implementation where the api has lots of state information that we might want to add in.

◆ AddImageHandler()

◆ AppendData()

void tesseract::TessResultRenderer::AppendData ( const char *  s,
int  len 
)
protected

◆ AppendString()

void tesseract::TessResultRenderer::AppendString ( const char *  s)
protected

◆ BeginDocument()

bool tesseract::TessResultRenderer::BeginDocument ( const char *  title)

Starts a new document with the given title. This clears the contents of the output data. Title should use UTF-8 encoding.

◆ BeginDocumentHandler()

bool tesseract::TessResultRenderer::BeginDocumentHandler ( )
protectedvirtual

◆ EndDocument()

bool tesseract::TessResultRenderer::EndDocument ( )

Finishes the document and finalizes the output data Invalid if BeginDocument not yet called.

◆ EndDocumentHandler()

bool tesseract::TessResultRenderer::EndDocumentHandler ( )
protectedvirtual

◆ file_extension()

const char* tesseract::TessResultRenderer::file_extension ( ) const
inline

◆ happy()

bool tesseract::TessResultRenderer::happy ( )
inline

◆ imagenum()

int tesseract::TessResultRenderer::imagenum ( ) const
inline

Returns the index of the last image given to AddImage (i.e. images are incremented whether the image succeeded or not)

This is always defined. It means either the number of the current image, the last image ended, or in the completed document depending on when in the document lifecycle you are looking at it. Will return -1 if a document was never started.

◆ insert()

void tesseract::TessResultRenderer::insert ( TessResultRenderer next)

◆ next()

TessResultRenderer* tesseract::TessResultRenderer::next ( )
inline

◆ title()

const char* tesseract::TessResultRenderer::title ( ) const
inline

Member Data Documentation

◆ file_extension_

const char* tesseract::TessResultRenderer::file_extension_
private

◆ fout_

FILE* tesseract::TessResultRenderer::fout_
private

◆ happy_

bool tesseract::TessResultRenderer::happy_
private

◆ imagenum_

int tesseract::TessResultRenderer::imagenum_
private

◆ next_

TessResultRenderer* tesseract::TessResultRenderer::next_
private

◆ title_

STRING tesseract::TessResultRenderer::title_
private

The documentation for this class was generated from the following files: