示例#1
0
void plot_fp_cells2(                        //draw words
        ScrollView *win,             //window tro draw in
        ScrollView::Color colour,          //colour of lines
        TO_ROW *row,            //for location
        FPSEGPT_LIST *seg_list  //segments to plot
) {
    TBOX word_box;                  //bounding box
    FPSEGPT_IT seg_it = seg_list;
    //blobs in row
    BLOBNBOX_IT blob_it = row->blob_list();
    FPSEGPT *segpt;                //current point

    word_box = blob_it.data()->bounding_box();
    for (blob_it.mark_cycle_pt(); !blob_it.cycled_list();)
        word_box += box_next(&blob_it);
    for (seg_it.mark_cycle_pt(); !seg_it.cycled_list(); seg_it.forward()) {
        segpt = seg_it.data();
        if (segpt->faked) {
            colour = ScrollView::WHITE;
            win->Pen(colour);
        }
        else {
            win->Pen(colour);
        }
        win->Line(segpt->position(), word_box.bottom(), segpt->position(), word_box.top());
    }
}
示例#2
0
void make_illegal_segment(                          //find segmentation
                          FPSEGPT_LIST *prev_list,  //previous segments
                          TBOX blob_box,            //bounding box
                          BLOBNBOX_IT blob_it,      //iterator
                          int16_t region_index,     //number of segment
                          int16_t pitch,            //pitch estimate
                          int16_t pitch_error,      //tolerance
                          FPSEGPT_LIST *seg_list    //output list
                         ) {
  int16_t x;                     //current coord
  int16_t min_x = 0;             //in this region
  int16_t max_x = 0;
  int16_t offset;                //dist to edge
  FPSEGPT *segpt;                //segment point
  FPSEGPT *prevpt;               //previous point
  float best_cost;               //best path
  FPSEGPT_IT segpt_it = seg_list;//iterator
                                 //previous points
  FPSEGPT_IT prevpt_it = prev_list;

  best_cost = FLT_MAX;
  for (prevpt_it.mark_cycle_pt (); !prevpt_it.cycled_list ();
  prevpt_it.forward ()) {
    prevpt = prevpt_it.data ();
    if (prevpt->cost_function () < best_cost) {
                                 //find least
      best_cost = prevpt->cost_function ();
      min_x = prevpt->position ();
      max_x = min_x;             //limits on coords
    }
    else if (prevpt->cost_function () == best_cost) {
      max_x = prevpt->position ();
    }
  }
  min_x += pitch - pitch_error;
  max_x += pitch + pitch_error;
  for (x = min_x; x <= max_x; x++) {
    while (x > blob_box.right ()) {
      blob_box = box_next (&blob_it);
    }
    offset = x - blob_box.left ();
    if (blob_box.right () - x < offset)
      offset = blob_box.right () - x;
    segpt = new FPSEGPT (x, FALSE, offset,
      region_index, pitch, pitch_error, prev_list);
    if (segpt->previous () != nullptr) {
      ASSERT_HOST (offset >= 0);
      fprintf (stderr, "made fake at %d\n", x);
                                 //make one up
      segpt_it.add_after_then_move (segpt);
      segpt->faked = TRUE;
      segpt->fake_count++;
    }
    else
      delete segpt;
  }
}
示例#3
0
void plot_fp_cells(                        //draw words
        ScrollView *win,             //window tro draw in
        ScrollView::Color colour,          //colour of lines
        BLOBNBOX_IT *blob_it,   //blobs
        inT16 pitch,            //of block
        inT16 blob_count,       //no of real blobs
        STATS *projection,      //vertical
        inT16 projection_left,  //edges //scale factor
        inT16 projection_right,
        float projection_scale) {
    inT16 occupation;              //occupied cells
    TBOX word_box;                  //bounding box
    FPSEGPT_LIST seg_list;         //list of cuts
    FPSEGPT_IT seg_it;
    FPSEGPT *segpt;                //current point

    if (pitsync_linear_version)
        check_pitch_sync2(blob_it, blob_count, pitch, 2, projection,
                          projection_left, projection_right,
                          projection_scale, occupation, &seg_list, 0, 0);
    else
        check_pitch_sync(blob_it, blob_count, pitch, 2, projection, &seg_list);
    word_box = blob_it->data()->bounding_box();
    for (; blob_count > 0; blob_count--)
        word_box += box_next(blob_it);
    seg_it.set_to_list(&seg_list);
    for (seg_it.mark_cycle_pt(); !seg_it.cycled_list(); seg_it.forward()) {
        segpt = seg_it.data();
        if (segpt->faked) {
            colour = ScrollView::WHITE;
            win->Pen(colour);
        }
        else {
            win->Pen(colour);
        }
        win->Line(segpt->position(), word_box.bottom(), segpt->position(), word_box.top());
    }
}