tesseract  3.03
tesseract::BaselineDetect Class Reference

#include <baselinedetect.h>

List of all members.

Public Member Functions

 BaselineDetect (int debug_level, const FCOORD &page_skew, TO_BLOCK_LIST *blocks)
 ~BaselineDetect ()
void ComputeStraightBaselines (bool use_box_bottoms)
void ComputeBaselineSplinesAndXheights (const ICOORD &page_tr, bool enable_splines, bool remove_noise, bool show_final_rows, Textord *textord)
void SetDebugImage (Pix *pixIn, const STRING &output_path)

Detailed Description

Definition at line 242 of file baselinedetect.h.


Constructor & Destructor Documentation

tesseract::BaselineDetect::BaselineDetect ( int  debug_level,
const FCOORD page_skew,
TO_BLOCK_LIST *  blocks 
)

Definition at line 786 of file baselinedetect.cpp.

    : page_skew_(page_skew), debug_level_(debug_level), pix_debug_(NULL),
      debug_file_prefix_("") {
  TO_BLOCK_IT it(blocks);
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    TO_BLOCK* to_block = it.data();
    BLOCK* block = to_block->block;
    POLY_BLOCK* pb = block->poly_block();
    // A note about non-text blocks.
    // On output, non-text blocks are supposed to contain a single empty word
    // in each incoming text line. These mark out the polygonal bounds of the
    // block. Ideally no baselines should be required, but currently
    // make_words crashes if a baseline and xheight are not provided, so we
    // include non-text blocks here, but flag them for special treatment.
    bool non_text = pb != NULL && !pb->IsText();
    blocks_.push_back(new BaselineBlock(debug_level_, non_text, to_block));
  }
}

Definition at line 806 of file baselinedetect.cpp.

                                {
  pixDestroy(&pix_debug_);
}

Member Function Documentation

void tesseract::BaselineDetect::ComputeBaselineSplinesAndXheights ( const ICOORD page_tr,
bool  enable_splines,
bool  remove_noise,
bool  show_final_rows,
Textord textord 
)

Definition at line 845 of file baselinedetect.cpp.

                                                                        {
  Pix* pix_spline = pix_debug_ ? pixConvertTo32(pix_debug_) : NULL;
  for (int i = 0; i < blocks_.size(); ++i) {
    BaselineBlock* bl_block = blocks_[i];
    bl_block->PrepareForSplineFitting(page_tr, remove_noise);
    bl_block->FitBaselineSplines(enable_splines, show_final_rows, textord);
    if (pix_spline) {
      bl_block->DrawPixSpline(pix_spline);
    }
    if (show_final_rows) {
      bl_block->DrawFinalRows(page_tr);
    }
  }

  if (pix_spline) {
    STRING outfile_name = debug_file_prefix_ + "_spline.png";
    pixWrite(outfile_name.string(), pix_spline, IFF_PNG);
    pixDestroy(&pix_spline);
  }
}

Definition at line 813 of file baselinedetect.cpp.

                                                                  {
  GenericVector<double> block_skew_angles;
  for (int i = 0; i < blocks_.size(); ++i) {
    BaselineBlock* bl_block = blocks_[i];
    if (debug_level_ > 0)
      tprintf("Fitting initial baselines...\n");
    if (bl_block->FitBaselinesAndFindSkew(use_box_bottoms)) {
      block_skew_angles.push_back(bl_block->skew_angle());
    }
  }
  // Compute a page-wide default skew for blocks with too little information.
  double default_block_skew = page_skew_.angle();
  if (!block_skew_angles.empty()) {
    default_block_skew = MedianOfCircularValues(M_PI, &block_skew_angles);
  }
  if (debug_level_ > 0) {
    tprintf("Page skew angle = %g\n", default_block_skew);
  }
  // Set bad lines in each block to the default block skew and then force fit
  // a linespacing model where it makes sense to do so.
  for (int i = 0; i < blocks_.size(); ++i) {
    BaselineBlock* bl_block = blocks_[i];
    bl_block->ParallelizeBaselines(default_block_skew);
    bl_block->SetupBlockParameters();  // This replaced compute_row_stats.
  }
}
void tesseract::BaselineDetect::SetDebugImage ( Pix *  pixIn,
const STRING output_path 
)

Definition at line 870 of file baselinedetect.cpp.

                                                                        {
  pixDestroy(&pix_debug_);
  pix_debug_ = pixClone(pixIn);
  debug_file_prefix_ = output_path;
}

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