本文整理汇总了C++中BLOBNBOX::region_type方法的典型用法代码示例。如果您正苦于以下问题:C++ BLOBNBOX::region_type方法的具体用法?C++ BLOBNBOX::region_type怎么用?C++ BLOBNBOX::region_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLOBNBOX
的用法示例。
在下文中一共展示了BLOBNBOX::region_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VerticalTextlinePartner
// Return the partner of this TabVector if the vector qualifies as
// being a vertical text line, otherwise NULL.
TabVector* TabVector::VerticalTextlinePartner() {
if (!partners_.singleton())
return NULL;
TabVector_C_IT partner_it(&partners_);
TabVector* partner = partner_it.data();
BLOBNBOX_C_IT box_it1(&boxes_);
BLOBNBOX_C_IT box_it2(&partner->boxes_);
// Count how many boxes are also in the other list.
// At the same time, gather the mean width and median vertical gap.
if (textord_debug_tabfind > 1) {
Print("Testing for vertical text");
partner->Print(" partner");
}
int num_matched = 0;
int num_unmatched = 0;
int total_widths = 0;
int width = startpt().x() - partner->startpt().x();
if (width < 0)
width = -width;
STATS gaps(0, width * 2);
BLOBNBOX* prev_bbox = NULL;
box_it2.mark_cycle_pt();
for (box_it1.mark_cycle_pt(); !box_it1.cycled_list(); box_it1.forward()) {
BLOBNBOX* bbox = box_it1.data();
TBOX box = bbox->bounding_box();
if (prev_bbox != NULL) {
gaps.add(box.bottom() - prev_bbox->bounding_box().top(), 1);
}
while (!box_it2.cycled_list() && box_it2.data() != bbox &&
box_it2.data()->bounding_box().bottom() < box.bottom()) {
box_it2.forward();
}
if (!box_it2.cycled_list() && box_it2.data() == bbox &&
bbox->region_type() >= BRT_UNKNOWN &&
(prev_bbox == NULL || prev_bbox->region_type() >= BRT_UNKNOWN))
++num_matched;
else
++num_unmatched;
total_widths += box.width();
prev_bbox = bbox;
}
if (num_unmatched + num_matched == 0) return NULL;
double avg_width = total_widths * 1.0 / (num_unmatched + num_matched);
double max_gap = textord_tabvector_vertical_gap_fraction * avg_width;
int min_box_match = static_cast<int>((num_matched + num_unmatched) *
textord_tabvector_vertical_box_ratio);
bool is_vertical = (gaps.get_total() > 0 &&
num_matched >= min_box_match &&
gaps.median() <= max_gap);
if (textord_debug_tabfind > 1) {
tprintf("gaps=%d, matched=%d, unmatched=%d, min_match=%d "
"median gap=%.2f, width=%.2f max_gap=%.2f Vertical=%s\n",
gaps.get_total(), num_matched, num_unmatched, min_box_match,
gaps.median(), avg_width, max_gap, is_vertical?"Yes":"No");
}
return (is_vertical) ? partner : NULL;
}
示例2: NoisyNeighbours
// Returns the number of side neighbours that are of type BRT_NOISE.
int BLOBNBOX::NoisyNeighbours() const {
int count = 0;
for (int dir = 0; dir < BND_COUNT; ++dir) {
BlobNeighbourDir bnd = static_cast<BlobNeighbourDir>(dir);
BLOBNBOX* blob = neighbour(bnd);
if (blob != NULL && blob->region_type() == BRT_NOISE)
++count;
}
return count;
}