Tesseract  3.02
tesseract-ocr/wordrec/chopper.h File Reference
#include "cutil.h"
#include "matrix.h"
#include "seam.h"
#include "states.h"
#include "stopper.h"

Go to the source code of this file.

Functions

void preserve_outline (EDGEPT *start)
void preserve_outline_tree (TESSLINE *srcline)
EDGEPTrestore_outline (EDGEPT *start)
void restore_outline_tree (TESSLINE *srcline)
int any_shared_split_points (SEAMS seam_list, SEAM *seam)
int check_blob (TBLOB *blob)
inT16 check_seam_order (TBLOB *blob, SEAM *seam)
inT16 total_containment (TBLOB *blob1, TBLOB *blob2)

Function Documentation

int any_shared_split_points ( SEAMS  seam_list,
SEAM seam 
)

Definition at line 289 of file chopper.cpp.

                                                         {
  int length;
  int index;

  length = array_count (seam_list);
  for (index = 0; index < length; index++)
    if (shared_split_points ((SEAM *) array_value (seam_list, index), seam))
      return TRUE;
  return FALSE;
}
int check_blob ( TBLOB blob)

Definition at line 306 of file chopper.cpp.

                            {
  TESSLINE *outline;
  EDGEPT *edgept;

  for (outline = blob->outlines; outline != NULL; outline = outline->next) {
    edgept = outline->loop;
    do {
      if (edgept == NULL)
        break;
      edgept = edgept->next;
    }
    while (edgept != outline->loop);
    if (edgept == NULL)
      return 1;
  }
  return 0;
}
inT16 check_seam_order ( TBLOB blob,
SEAM seam 
)

Definition at line 539 of file chopper.cpp.

                                                {
  TESSLINE *outline;
  TESSLINE *last_outline;
  inT8 found_em[3];

  if (seam->split1 == NULL || seam->split1 == NULL || blob == NULL)
    return (TRUE);

  found_em[0] = found_em[1] = found_em[2] = FALSE;

  for (outline = blob->outlines; outline; outline = outline->next) {
    if (!found_em[0] &&
      ((seam->split1 == NULL) ||
    is_split_outline (outline, seam->split1))) {
      found_em[0] = TRUE;
    }
    if (!found_em[1] &&
      ((seam->split2 == NULL) ||
    is_split_outline (outline, seam->split2))) {
      found_em[1] = TRUE;
    }
    if (!found_em[2] &&
      ((seam->split3 == NULL) ||
    is_split_outline (outline, seam->split3))) {
      found_em[2] = TRUE;
    }
    last_outline = outline;
  }

  if (!found_em[0] || !found_em[1] || !found_em[2])
    return (FALSE);
  else
    return (TRUE);
}
void preserve_outline ( EDGEPT start)

Definition at line 65 of file chopper.cpp.

                                     {
  EDGEPT *srcpt;

  if (start == NULL)
    return;
  srcpt = start;
  do {
    srcpt->flags[1] = 1;
    srcpt = srcpt->next;
  }
  while (srcpt != start);
  srcpt->flags[1] = 2;
}
void preserve_outline_tree ( TESSLINE srcline)

Definition at line 81 of file chopper.cpp.

                                              {
  TESSLINE *outline;

  for (outline = srcline; outline != NULL; outline = outline->next) {
    preserve_outline (outline->loop);
  }
}
EDGEPT* restore_outline ( EDGEPT start)

Definition at line 95 of file chopper.cpp.

                                       {
  EDGEPT *srcpt;
  EDGEPT *real_start;
  EDGEPT *deadpt;

  if (start == NULL)
    return NULL;
  srcpt = start;
  do {
    if (srcpt->flags[1] == 2)
      break;
    srcpt = srcpt->next;
  }
  while (srcpt != start);
  real_start = srcpt;
  do {
    if (srcpt->flags[1] == 0) {
      deadpt = srcpt;
      srcpt = srcpt->next;
      srcpt->prev = deadpt->prev;
      deadpt->prev->next = srcpt;
      deadpt->prev->vec.x = srcpt->pos.x - deadpt->prev->pos.x;
      deadpt->prev->vec.y = srcpt->pos.y - deadpt->prev->pos.y;
      delete deadpt;
    }
    else
      srcpt = srcpt->next;
  }
  while (srcpt != real_start);
  return real_start;
}
void restore_outline_tree ( TESSLINE srcline)

Definition at line 129 of file chopper.cpp.

                                             {
  TESSLINE *outline;

  for (outline = srcline; outline != NULL; outline = outline->next) {
    outline->loop = restore_outline (outline->loop);
    outline->start = outline->loop->pos;
  }
}
inT16 total_containment ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 1050 of file chopper.cpp.

                                                    {
  TBOX box1 = blob1->bounding_box();
  TBOX box2 = blob2->bounding_box();
  return box1.contains(box2) || box2.contains(box1);
}