tesseract  5.0.0-alpha-619-ge9db
werdit.cpp File Reference
#include "werdit.h"
#include "errcode.h"
#include "pageres.h"
#include "stepblob.h"
#include "werd.h"

Go to the source code of this file.

Functions

PAGE_RES_ITmake_pseudo_word (PAGE_RES *page_res, const TBOX &selection_box)
 

Function Documentation

◆ make_pseudo_word()

PAGE_RES_IT* make_pseudo_word ( PAGE_RES page_res,
const TBOX selection_box 
)

Definition at line 33 of file werdit.cpp.

35  {
36  PAGE_RES_IT pr_it(page_res);
37  C_BLOB_LIST new_blobs; // list of gathered blobs
38  C_BLOB_IT new_blob_it = &new_blobs; // iterator
39 
40  for (WERD_RES* word_res = pr_it.word(); word_res != nullptr;
41  word_res = pr_it.forward()) {
42  WERD* word = word_res->word;
43  if (word->bounding_box().overlap(selection_box)) {
44  C_BLOB_IT blob_it(word->cblob_list());
45  for (blob_it.mark_cycle_pt();
46  !blob_it.cycled_list(); blob_it.forward()) {
47  C_BLOB* blob = blob_it.data();
48  if (blob->bounding_box().overlap(selection_box)) {
49  new_blob_it.add_after_then_move(C_BLOB::deep_copy(blob));
50  }
51  }
52  if (!new_blobs.empty()) {
53  WERD* pseudo_word = new WERD(&new_blobs, 1, nullptr);
54  word_res = pr_it.InsertSimpleCloneWord(*word_res, pseudo_word);
55  auto* it = new PAGE_RES_IT(page_res);
56  while (it->word() != word_res && it->word() != nullptr) it->forward();
57  ASSERT_HOST(it->word() == word_res);
58  return it;
59  }
60  }
61  }
C_BLOB::bounding_box
TBOX bounding_box() const
Definition: stepblob.cpp:247
ASSERT_HOST
#define ASSERT_HOST(x)
Definition: errcode.h:87
WERD::bounding_box
TBOX bounding_box() const
Definition: werd.cpp:147
TBOX::overlap
bool overlap(const TBOX &box) const
Definition: rect.h:350
WERD_RES
Definition: pageres.h:160
C_BLOB
Definition: stepblob.h:36
WERD::cblob_list
C_BLOB_LIST * cblob_list()
Definition: werd.h:94
C_BLOB::deep_copy
static C_BLOB * deep_copy(const C_BLOB *src)
Definition: stepblob.h:118
PAGE_RES_IT
Definition: pageres.h:668
WERD
Definition: werd.h:55
WERD_RES::word
WERD * word
Definition: pageres.h:180