tesseract 3.04.01

tesseract::TessHOcrRenderer Class Reference

#include <renderer.h>

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

List of all members.

Public Member Functions

 TessHOcrRenderer (const char *outputbase, bool font_info)
 TessHOcrRenderer (const char *outputbase)

Protected Member Functions

virtual bool BeginDocumentHandler ()
virtual bool AddImageHandler (TessBaseAPI *api)
virtual bool EndDocumentHandler ()

Detailed Description

Renders tesseract output into an hocr text string

Definition at line 151 of file renderer.h.


Constructor & Destructor Documentation

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

Definition at line 135 of file renderer.cpp.

    : TessResultRenderer(outputbase, "hocr") {
    font_info_ = font_info;
}
tesseract::TessHOcrRenderer::TessHOcrRenderer ( const char *  outputbase) [explicit]

Definition at line 130 of file renderer.cpp.

    : TessResultRenderer(outputbase, "hocr") {
    font_info_ = false;
}

Member Function Documentation

bool tesseract::TessHOcrRenderer::AddImageHandler ( TessBaseAPI api) [protected, virtual]

Implements tesseract::TessResultRenderer.

Definition at line 172 of file renderer.cpp.

                                                       {
  char* hocr = api->GetHOCRText(imagenum());
  if (hocr == NULL) return false;

  AppendString(hocr);
  delete[] hocr;

  return true;
}
bool tesseract::TessHOcrRenderer::BeginDocumentHandler ( ) [protected, virtual]

Reimplemented from tesseract::TessResultRenderer.

Definition at line 140 of file renderer.cpp.

                                            {
  AppendString(
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
        "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
        "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" "
        "lang=\"en\">\n <head>\n  <title>");
  AppendString(title());
  AppendString(
      "</title>\n"
      "<meta http-equiv=\"Content-Type\" content=\"text/html;"
      "charset=utf-8\" />\n"
      "  <meta name='ocr-system' content='tesseract " TESSERACT_VERSION_STR
              "' />\n"
      "  <meta name='ocr-capabilities' content='ocr_page ocr_carea ocr_par"
      " ocr_line ocrx_word");
  if (font_info_)
    AppendString(
      " ocrp_lang ocrp_dir ocrp_font ocrp_fsize ocrp_wconf");
  AppendString(
      "'/>\n"
      "</head>\n<body>\n");

  return true;
}
bool tesseract::TessHOcrRenderer::EndDocumentHandler ( ) [protected, virtual]

Reimplemented from tesseract::TessResultRenderer.

Definition at line 166 of file renderer.cpp.

                                          {
  AppendString(" </body>\n</html>\n");

  return true;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines