tesseract  5.0.0-alpha-619-ge9db
tesseract::TessAltoRenderer Class Reference

#include <renderer.h>

Inheritance diagram for tesseract::TessAltoRenderer:
tesseract::TessResultRenderer

Public Member Functions

 TessAltoRenderer (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

bool BeginDocumentHandler () override
 
bool AddImageHandler (TessBaseAPI *api) override
 
bool EndDocumentHandler () override
 
- 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 alto text string

Definition at line 185 of file renderer.h.

Constructor & Destructor Documentation

◆ TessAltoRenderer()

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

Definition at line 111 of file altorenderer.cpp.

112  : TessResultRenderer(outputbase, "xml") {}

Member Function Documentation

◆ AddImageHandler()

bool tesseract::TessAltoRenderer::AddImageHandler ( TessBaseAPI api)
overrideprotectedvirtual

Append the ALTO XML for the layout of the image

Implements tesseract::TessResultRenderer.

Definition at line 93 of file altorenderer.cpp.

93  {
94  const std::unique_ptr<const char[]> text(api->GetAltoText(imagenum()));
95  if (text == nullptr) return false;
96 
97  AppendString(text.get());
98 
99  return true;
100 }

◆ BeginDocumentHandler()

bool tesseract::TessAltoRenderer::BeginDocumentHandler ( )
overrideprotectedvirtual

Append the ALTO XML for the beginning of the document

Reimplemented from tesseract::TessResultRenderer.

Definition at line 56 of file altorenderer.cpp.

56  {
58  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
59  "<alto xmlns=\"http://www.loc.gov/standards/alto/ns-v3#\" "
60  "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
61  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
62  "xsi:schemaLocation=\"http://www.loc.gov/standards/alto/ns-v3# "
63  "http://www.loc.gov/alto/v3/alto-3-0.xsd\">\n"
64  "\t<Description>\n"
65  "\t\t<MeasurementUnit>pixel</MeasurementUnit>\n"
66  "\t\t<sourceImageInformation>\n"
67  "\t\t\t<fileName>");
68 
70 
72  "</fileName>\n"
73  "\t\t</sourceImageInformation>\n"
74  "\t\t<OCRProcessing ID=\"OCR_0\">\n"
75  "\t\t\t<ocrProcessingStep>\n"
76  "\t\t\t\t<processingSoftware>\n"
77  "\t\t\t\t\t<softwareName>tesseract ");
80  "</softwareName>\n"
81  "\t\t\t\t</processingSoftware>\n"
82  "\t\t\t</ocrProcessingStep>\n"
83  "\t\t</OCRProcessing>\n"
84  "\t</Description>\n"
85  "\t<Layout>\n");
86 
87  return true;
88 }

◆ EndDocumentHandler()

bool tesseract::TessAltoRenderer::EndDocumentHandler ( )
overrideprotectedvirtual

Append the ALTO XML for the end of the document

Reimplemented from tesseract::TessResultRenderer.

Definition at line 105 of file altorenderer.cpp.

105  {
106  AppendString("\t</Layout>\n</alto>\n");
107 
108  return true;
109 }

The documentation for this class was generated from the following files:
tesseract::TessResultRenderer::AppendString
void AppendString(const char *s)
Definition: renderer.cpp:101
tesseract::TessResultRenderer::TessResultRenderer
TessResultRenderer(const char *outputbase, const char *extension)
Definition: renderer.cpp:32
tesseract::TessBaseAPI::Version
static const char * Version()
Definition: baseapi.cpp:233
tesseract::TessResultRenderer::title
const char * title() const
Definition: renderer.h:89
tesseract::TessResultRenderer::imagenum
int imagenum() const
Definition: renderer.h:107