tesseract  4.0.0-1-g2a2b
tesseract::TessHOcrRenderer Class Reference

#include <renderer.h>

Inheritance diagram for tesseract::TessHOcrRenderer:
tesseract::TessResultRenderer

Public Member Functions

 TessHOcrRenderer (const char *outputbase, bool font_info)
 
 TessHOcrRenderer (const char *outputbase)
 
- Public Member Functions inherited from tesseract::TessResultRenderer
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

virtual bool BeginDocumentHandler ()
 
virtual bool AddImageHandler (TessBaseAPI *api)
 
virtual bool EndDocumentHandler ()
 
- Protected Member Functions inherited from tesseract::TessResultRenderer
 TessResultRenderer (const char *outputbase, const char *extension)
 
void AppendString (const char *s)
 
void AppendData (const char *s, int len)
 

Detailed Description

Renders tesseract output into an hocr text string

Definition at line 155 of file renderer.h.

Constructor & Destructor Documentation

◆ TessHOcrRenderer() [1/2]

tesseract::TessHOcrRenderer::TessHOcrRenderer ( const char *  outputbase,
bool  font_info 
)
explicit

Definition at line 150 of file renderer.cpp.

151  : TessResultRenderer(outputbase, "hocr") {
152  font_info_ = font_info;
153 }
TessResultRenderer(const char *outputbase, const char *extension)
Definition: renderer.cpp:33

◆ TessHOcrRenderer() [2/2]

tesseract::TessHOcrRenderer::TessHOcrRenderer ( const char *  outputbase)
explicit

Definition at line 145 of file renderer.cpp.

146  : TessResultRenderer(outputbase, "hocr") {
147  font_info_ = false;
148 }
TessResultRenderer(const char *outputbase, const char *extension)
Definition: renderer.cpp:33

Member Function Documentation

◆ AddImageHandler()

bool tesseract::TessHOcrRenderer::AddImageHandler ( TessBaseAPI api)
protectedvirtual

Implements tesseract::TessResultRenderer.

Definition at line 187 of file renderer.cpp.

187  {
188  const std::unique_ptr<const char[]> hocr(api->GetHOCRText(imagenum()));
189  if (hocr == nullptr) return false;
190 
191  AppendString(hocr.get());
192 
193  return true;
194 }
void AppendString(const char *s)
Definition: renderer.cpp:102

◆ BeginDocumentHandler()

bool tesseract::TessHOcrRenderer::BeginDocumentHandler ( )
protectedvirtual

Reimplemented from tesseract::TessResultRenderer.

Definition at line 155 of file renderer.cpp.

155  {
156  AppendString(
157  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
158  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
159  " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
160  "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" "
161  "lang=\"en\">\n <head>\n <title>");
162  AppendString(title());
163  AppendString(
164  "</title>\n"
165  "<meta http-equiv=\"Content-Type\" content=\"text/html;"
166  "charset=utf-8\" />\n"
167  " <meta name='ocr-system' content='tesseract " PACKAGE_VERSION
168  "' />\n"
169  " <meta name='ocr-capabilities' content='ocr_page ocr_carea ocr_par"
170  " ocr_line ocrx_word ocrp_wconf");
171  if (font_info_)
172  AppendString(
173  " ocrp_lang ocrp_dir ocrp_font ocrp_fsize");
174  AppendString(
175  "'/>\n"
176  "</head>\n<body>\n");
177 
178  return true;
179 }
const char * title() const
Definition: renderer.h:81
void AppendString(const char *s)
Definition: renderer.cpp:102

◆ EndDocumentHandler()

bool tesseract::TessHOcrRenderer::EndDocumentHandler ( )
protectedvirtual

Reimplemented from tesseract::TessResultRenderer.

Definition at line 181 of file renderer.cpp.

181  {
182  AppendString(" </body>\n</html>\n");
183 
184  return true;
185 }
void AppendString(const char *s)
Definition: renderer.cpp:102

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