last-svn-commit-929-gecd297e Fix compilation.

* scribo/core/object_groups.hh, * scribo/debug/logger.hh, * scribo/estim/object_groups_mean_width.hh, * src/debug/show_paragraph_blocks.cc, * src/debug/show_text_lines.cc, * src/non_text_components.cc, * src/primitive/extract/alignments.cc, * scribo/text/extract_paragraphs_hdoc.hh: Fix namespace ambiguities. * scribo/core/object_links.hh: Remove useless find_root(). * scribo/debug/bboxes_enlarged_image.hh, * scribo/debug/looks_like_a_text_line_image.hh: Update includes. * scribo/filter/images_in_paragraph.hh, * scribo/filter/paragraphs_bbox_overlap.hh, * scribo/filter/paragraphs_in_image.hh, * scribo/filter/separators_in_element.hh, * scribo/filter/separators_in_paragraph.hh, * scribo/io/img/internal/debug_img_visitor.hh, * scribo/io/img/internal/full_img_visitor.hh, * scribo/io/xml/internal/compute_text_colour.hh, * scribo/io/xml/internal/full_xml_visitor.hh, * scribo/io/xml/internal/page_xml_visitor.hh, * scribo/io/xml/internal/time_info.hh, * scribo/postprocessing/images_to_drop_capital.hh, * scribo/primitive/remove/separators.hh, * scribo/text/extract_paragraphs.hh, * scribo/text/paragraphs_closing.hh, * scribo/toolchain/internal/content_in_hdoc_functor.hh: Add missing includes. * scribo/io/xml/load.hh: Fix string conversions. * scribo/primitive/group/from_double_link.hh * scribo/primitive/link/with_several_left_links.hh * scribo/primitive/link/with_several_right_links.hh * src/afp/link.hh: Update according new API in object_groups/links. * src/text_in_picture.cc, * src/text_in_picture_neg.cc, * src/text_recognition_in_picture.cc: Update a routine name. --- scribo/ChangeLog | 48 ++++++++++++++++++++ scribo/scribo/core/object_groups.hh | 20 +++++++-- scribo/scribo/core/object_links.hh | 11 ----- scribo/scribo/debug/bboxes_enlarged_image.hh | 3 +- scribo/scribo/debug/logger.hh | 10 ++-- .../scribo/debug/looks_like_a_text_line_image.hh | 3 +- scribo/scribo/estim/object_groups_mean_width.hh | 2 +- scribo/scribo/filter/images_in_paragraph.hh | 1 + scribo/scribo/filter/paragraphs_bbox_overlap.hh | 4 +- scribo/scribo/filter/paragraphs_in_image.hh | 2 + scribo/scribo/filter/separators_in_element.hh | 1 + scribo/scribo/filter/separators_in_paragraph.hh | 3 +- scribo/scribo/io/img/internal/debug_img_visitor.hh | 1 + scribo/scribo/io/img/internal/full_img_visitor.hh | 1 + .../scribo/io/xml/internal/compute_text_colour.hh | 3 + scribo/scribo/io/xml/internal/full_xml_visitor.hh | 1 + scribo/scribo/io/xml/internal/page_xml_visitor.hh | 1 + scribo/scribo/io/xml/internal/time_info.hh | 3 +- scribo/scribo/io/xml/load.hh | 33 +++++++------- .../postprocessing/images_to_drop_capital.hh | 1 + scribo/scribo/primitive/group/from_double_link.hh | 25 ++++------ .../primitive/link/with_several_left_links.hh | 16 +++--- .../primitive/link/with_several_right_links.hh | 16 +++--- scribo/scribo/primitive/remove/separators.hh | 1 + scribo/scribo/text/extract_paragraphs.hh | 1 + scribo/scribo/text/extract_paragraphs_hdoc.hh | 11 +++-- scribo/scribo/text/paragraphs_closing.hh | 3 + .../toolchain/internal/content_in_hdoc_functor.hh | 2 +- scribo/src/afp/link.hh | 6 +- scribo/src/debug/show_paragraph_blocks.cc | 2 +- scribo/src/debug/show_text_lines.cc | 4 +- scribo/src/non_text_components.cc | 2 +- scribo/src/primitive/extract/alignments.cc | 5 +- scribo/src/text_in_picture.cc | 6 +- scribo/src/text_in_picture_neg.cc | 1 - scribo/src/text_recognition_in_picture.cc | 6 +- 36 files changed, 161 insertions(+), 98 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index b0b50f3..f756ab3 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,51 @@ +2011-06-28 Guillaume Lazzara <z@lrde.epita.fr> + + Fix compilation. + + * scribo/core/object_groups.hh, + * scribo/debug/logger.hh, + * scribo/estim/object_groups_mean_width.hh, + * src/debug/show_paragraph_blocks.cc, + * src/debug/show_text_lines.cc, + * src/non_text_components.cc, + * src/primitive/extract/alignments.cc, + * scribo/text/extract_paragraphs_hdoc.hh: Fix namespace ambiguities. + + * scribo/core/object_links.hh: Remove useless find_root(). + + * scribo/debug/bboxes_enlarged_image.hh, + * scribo/debug/looks_like_a_text_line_image.hh: Update includes. + + * scribo/filter/images_in_paragraph.hh, + * scribo/filter/paragraphs_bbox_overlap.hh, + * scribo/filter/paragraphs_in_image.hh, + * scribo/filter/separators_in_element.hh, + * scribo/filter/separators_in_paragraph.hh, + * scribo/io/img/internal/debug_img_visitor.hh, + * scribo/io/img/internal/full_img_visitor.hh, + * scribo/io/xml/internal/compute_text_colour.hh, + * scribo/io/xml/internal/full_xml_visitor.hh, + * scribo/io/xml/internal/page_xml_visitor.hh, + * scribo/io/xml/internal/time_info.hh, + * scribo/postprocessing/images_to_drop_capital.hh, + * scribo/primitive/remove/separators.hh, + * scribo/text/extract_paragraphs.hh, + * scribo/text/paragraphs_closing.hh, + * scribo/toolchain/internal/content_in_hdoc_functor.hh: Add + missing includes. + + * scribo/io/xml/load.hh: Fix string conversions. + + * scribo/primitive/group/from_double_link.hh + * scribo/primitive/link/with_several_left_links.hh + * scribo/primitive/link/with_several_right_links.hh + * src/afp/link.hh: Update according new API in + object_groups/links. + + * src/text_in_picture.cc, + * src/text_in_picture_neg.cc, + * src/text_recognition_in_picture.cc: Update a routine name. + 2011-06-27 Guillaume Lazzara <z@lrde.epita.fr> * scribo/toolchain/internal/content_in_doc_functor.hh: Add a diff --git a/scribo/scribo/core/object_groups.hh b/scribo/scribo/core/object_groups.hh index 1cc8815..9990996 100644 --- a/scribo/scribo/core/object_groups.hh +++ b/scribo/scribo/core/object_groups.hh @@ -54,6 +54,18 @@ namespace scribo namespace internal { + + inline + unsigned + find_root(mln::util::array<unsigned>& parent, unsigned x) + { + if (parent(x) == x) + return x; + else + return parent(x) = find_root(parent, parent(x)); + } + + /// Data structure for \c scribo::object_groups<I>. template <typename L> struct object_groups_data @@ -149,7 +161,7 @@ namespace scribo comp_to_group_ = links.comp_to_link(); unsigned ngroups = 0; - util::array<unsigned> new_id(comp_to_group_.nelements(), 0); + mln::util::array<unsigned> new_id(comp_to_group_.nelements(), 0); mln::util::array<mln::util::array<component_id_t> > comp_ids(1); mln::util::array<accu::shape::bbox<mln_site(L)> > bboxes(1); mln::util::array<unsigned> pixel_areas(1); @@ -157,7 +169,7 @@ namespace scribo // Remove potential loops in linking // FIXME: we may try to avoid loops while linking... { - util::array<bool> deja_vu(comp_to_group_.nelements()); + mln::util::array<bool> deja_vu(comp_to_group_.nelements()); for_all_elements(e, comp_to_group_) if (comp_to_group_(e) != e && comp_to_group_(e) != 0) { @@ -199,7 +211,7 @@ namespace scribo group_info_.resize(1); group_info_.reserve(ngroups); - util::array<unsigned> group_idx(ngroups + 1, 0); + mln::util::array<unsigned> group_idx(ngroups + 1, 0); for (unsigned i = 1; i < new_id.nelements(); ++i) if (new_id(i)) @@ -306,7 +318,7 @@ namespace scribo } template <typename L> - const util::array<unsigned>& + const mln::util::array<unsigned>& object_groups<L>::comp_to_group() const { return data_->comp_to_group_; diff --git a/scribo/scribo/core/object_links.hh b/scribo/scribo/core/object_links.hh index 386de41..37fd299 100644 --- a/scribo/scribo/core/object_links.hh +++ b/scribo/scribo/core/object_links.hh @@ -51,17 +51,6 @@ namespace scribo namespace internal { - inline - unsigned - find_root(mln::util::array<unsigned>& parent, unsigned x) - { - if (parent(x) == x) - return x; - else - return parent(x) = find_root(parent, parent(x)); - } - - /// Data structure for \c scribo::object_links<I>. template <typename L> struct object_links_data diff --git a/scribo/scribo/debug/bboxes_enlarged_image.hh b/scribo/scribo/debug/bboxes_enlarged_image.hh index 2563a1a..24fea2f 100644 --- a/scribo/scribo/debug/bboxes_enlarged_image.hh +++ b/scribo/scribo/debug/bboxes_enlarged_image.hh @@ -39,8 +39,7 @@ # include <scribo/core/line_set.hh> -// Declares internal::looks_like_a_text_line. -# include <scribo/text/merging.hh> +# include <scribo/text/look_like_text_lines.hh> namespace scribo diff --git a/scribo/scribo/debug/logger.hh b/scribo/scribo/debug/logger.hh index d955f08..f16dd89 100644 --- a/scribo/scribo/debug/logger.hh +++ b/scribo/scribo/debug/logger.hh @@ -246,14 +246,14 @@ namespace scribo // void // logger_::log_image_generic(const I& ima, const std::string& name) // { - // io::magick::save(ima, mln::debug::filename(name + ".png")); + // mln::io::magick::save(ima, mln::debug::filename(name + ".png")); // } template <typename I> void logger_::log_image_rgb(const I& ima, const std::string& name) { - io::ppm::save(ima, mln::debug::filename(name + ".ppm")); + mln::io::ppm::save(ima, mln::debug::filename(name + ".ppm")); } @@ -261,7 +261,7 @@ namespace scribo void logger_::log_image_bool(const I& ima, const std::string& name) { - io::pbm::save(ima, mln::debug::filename(name + ".pbm")); + mln::io::pbm::save(ima, mln::debug::filename(name + ".pbm")); } @@ -269,8 +269,8 @@ namespace scribo void logger_::log_image_grayscale(const I& ima, const std::string& name) { - io::pgm::save(data::wrap(value::int_u8(), ima), - mln::debug::filename(name + ".pgm")); + mln::io::pgm::save(data::wrap(value::int_u8(), ima), + mln::debug::filename(name + ".pgm")); } } // end of namespace scribo::debug::internal diff --git a/scribo/scribo/debug/looks_like_a_text_line_image.hh b/scribo/scribo/debug/looks_like_a_text_line_image.hh index d8aacf0..376baae 100644 --- a/scribo/scribo/debug/looks_like_a_text_line_image.hh +++ b/scribo/scribo/debug/looks_like_a_text_line_image.hh @@ -40,8 +40,7 @@ # include <scribo/core/line_set.hh> -// Declares internal::looks_like_a_text_line. -# include <scribo/text/merging.hh> +# include <scribo/text/look_like_text_lines.hh> namespace scribo diff --git a/scribo/scribo/estim/object_groups_mean_width.hh b/scribo/scribo/estim/object_groups_mean_width.hh index 65d843c..9167db4 100644 --- a/scribo/scribo/estim/object_groups_mean_width.hh +++ b/scribo/scribo/estim/object_groups_mean_width.hh @@ -63,7 +63,7 @@ namespace scribo template <typename L> - util::array<float> + mln::util::array<float> object_groups_mean_width(const object_groups<L>& groups) { trace::entering("scribo::estim::object_groups_mean_width"); diff --git a/scribo/scribo/filter/images_in_paragraph.hh b/scribo/scribo/filter/images_in_paragraph.hh index 3cf64e1..cf77892 100644 --- a/scribo/scribo/filter/images_in_paragraph.hh +++ b/scribo/scribo/filter/images_in_paragraph.hh @@ -33,6 +33,7 @@ # include <mln/core/concept/image.hh> +# include <mln/draw/box_plain.hh> # include <scribo/core/component_set.hh> # include <scribo/core/document.hh> diff --git a/scribo/scribo/filter/paragraphs_bbox_overlap.hh b/scribo/scribo/filter/paragraphs_bbox_overlap.hh index 188a77e..1cf9793 100644 --- a/scribo/scribo/filter/paragraphs_bbox_overlap.hh +++ b/scribo/scribo/filter/paragraphs_bbox_overlap.hh @@ -38,10 +38,10 @@ # include <mln/core/image/dmorph/image_if.hh> # include <mln/data/transform.hh> # include <mln/util/array.hh> +# include <mln/draw/box_plain.hh> # include <scribo/core/paragraph_set.hh> - -#include <mln/labeling/colorize.hh> +# include <scribo/util/box_intersection.hh> namespace scribo { diff --git a/scribo/scribo/filter/paragraphs_in_image.hh b/scribo/scribo/filter/paragraphs_in_image.hh index f67b863..be15b06 100644 --- a/scribo/scribo/filter/paragraphs_in_image.hh +++ b/scribo/scribo/filter/paragraphs_in_image.hh @@ -38,11 +38,13 @@ # include <mln/core/image/dmorph/image_if.hh> # include <mln/data/transform.hh> +# include <mln/draw/box_plain.hh> # include <mln/util/array.hh> # include <mln/pw/all.hh> +# include <scribo/core/document.hh> # include <scribo/core/paragraph_set.hh> # include <scribo/fun/v2b/objects_small_filter.hh> # include <scribo/primitive/extract/components.hh> diff --git a/scribo/scribo/filter/separators_in_element.hh b/scribo/scribo/filter/separators_in_element.hh index a8b0ebb..7e8a437 100644 --- a/scribo/scribo/filter/separators_in_element.hh +++ b/scribo/scribo/filter/separators_in_element.hh @@ -33,6 +33,7 @@ # include <mln/core/concept/image.hh> +# include <mln/draw/box_plain.hh> # include <scribo/core/component_set.hh> # include <scribo/core/document.hh> diff --git a/scribo/scribo/filter/separators_in_paragraph.hh b/scribo/scribo/filter/separators_in_paragraph.hh index 7c157be..ac399c3 100644 --- a/scribo/scribo/filter/separators_in_paragraph.hh +++ b/scribo/scribo/filter/separators_in_paragraph.hh @@ -23,7 +23,7 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_FILTER_SEPARATORS_IN_PARAGRAPHS_HH +#ifndef SCRIBO_FILTER_SEPARATORS_IN_PARAGRAPH_HH # define SCRIBO_FILTER_SEPARATORS_IN_PARAGRAPH_HH /// \file @@ -33,6 +33,7 @@ # include <mln/core/concept/image.hh> +# include <mln/draw/box_plain.hh> # include <scribo/core/component_set.hh> # include <scribo/core/document.hh> diff --git a/scribo/scribo/io/img/internal/debug_img_visitor.hh b/scribo/scribo/io/img/internal/debug_img_visitor.hh index cde16ed..b5e576b 100644 --- a/scribo/scribo/io/img/internal/debug_img_visitor.hh +++ b/scribo/scribo/io/img/internal/debug_img_visitor.hh @@ -37,6 +37,7 @@ # include <mln/draw/polygon.hh> # include <mln/subsampling/antialiased.hh> # include <mln/morpho/elementary/gradient_external.hh> +# include <mln/draw/box.hh> # include <scribo/core/internal/doc_serializer.hh> # include <scribo/core/document.hh> diff --git a/scribo/scribo/io/img/internal/full_img_visitor.hh b/scribo/scribo/io/img/internal/full_img_visitor.hh index f31eec1..2e4ddad 100644 --- a/scribo/scribo/io/img/internal/full_img_visitor.hh +++ b/scribo/scribo/io/img/internal/full_img_visitor.hh @@ -42,6 +42,7 @@ # include <scribo/core/paragraph_set.hh> # include <scribo/core/line_info.hh> +# include <scribo/text/paragraphs_closing.hh> # include <scribo/io/img/internal/draw_edges.hh> # include <scribo/util/component_precise_outline.hh> diff --git a/scribo/scribo/io/xml/internal/compute_text_colour.hh b/scribo/scribo/io/xml/internal/compute_text_colour.hh index f592c08..ef9929e 100644 --- a/scribo/scribo/io/xml/internal/compute_text_colour.hh +++ b/scribo/scribo/io/xml/internal/compute_text_colour.hh @@ -31,6 +31,7 @@ /// Find the color name of a given color. # include <mln/value/rgb8.hh> +# include <mln/value/int_u8.hh> # include <mln/make/vec.hh> # include <mln/norm/l2.hh> @@ -47,6 +48,8 @@ namespace scribo namespace internal { + using namespace mln; + const char * compute_text_colour(const value::rgb8& v); diff --git a/scribo/scribo/io/xml/internal/full_xml_visitor.hh b/scribo/scribo/io/xml/internal/full_xml_visitor.hh index c6109ee..b4fb683 100644 --- a/scribo/scribo/io/xml/internal/full_xml_visitor.hh +++ b/scribo/scribo/io/xml/internal/full_xml_visitor.hh @@ -30,6 +30,7 @@ /// /// XML serializer Visitor. +# include <iomanip> # include <fstream> # include <QByteArray> diff --git a/scribo/scribo/io/xml/internal/page_xml_visitor.hh b/scribo/scribo/io/xml/internal/page_xml_visitor.hh index dab1cce..4c15e83 100644 --- a/scribo/scribo/io/xml/internal/page_xml_visitor.hh +++ b/scribo/scribo/io/xml/internal/page_xml_visitor.hh @@ -37,6 +37,7 @@ # include <scribo/util/component_precise_outline.hh> +# include <scribo/io/xml/internal/print_image_coords.hh> # include <scribo/io/xml/internal/print_box_coords.hh> # include <scribo/io/xml/internal/print_page_preambule.hh> # include <scribo/io/xml/internal/compute_text_colour.hh> diff --git a/scribo/scribo/io/xml/internal/time_info.hh b/scribo/scribo/io/xml/internal/time_info.hh index 760e856..77aee0d 100644 --- a/scribo/scribo/io/xml/internal/time_info.hh +++ b/scribo/scribo/io/xml/internal/time_info.hh @@ -31,6 +31,7 @@ /// Get formated time info for PAGE XML format. # include <ctime> +# include <string> namespace scribo { @@ -44,7 +45,7 @@ namespace scribo namespace internal { - using namespace mln; + std::string time_info(); # ifndef MLN_INCLUDE_ONLY diff --git a/scribo/scribo/io/xml/load.hh b/scribo/scribo/io/xml/load.hh index 4e90b20..984029f 100644 --- a/scribo/scribo/io/xml/load.hh +++ b/scribo/scribo/io/xml/load.hh @@ -188,14 +188,14 @@ namespace scribo // Component Info case ComponentInfo: { - component_info info(atts.value("id").toInt(), - mln::make::box2d(atts.value("pmin_y").toInt(), - atts.value("pmin_x").toInt(), - atts.value("pmax_y").toInt(), - atts.value("pmax_x").toInt()), - mln::point2d(atts.value("mass_center_y").toInt(), - atts.value("mass_center_x").toInt()), - atts.value("card").toInt()); + component_info<L> info(atts.value("id").toInt(), + mln::make::box2d(atts.value("pmin_y").toInt(), + atts.value("pmin_x").toInt(), + atts.value("pmax_y").toInt(), + atts.value("pmax_x").toInt()), + mln::point2d(atts.value("mass_center_y").toInt(), + atts.value("mass_center_x").toInt()), + atts.value("card").toInt()); info.update_tag(component::str2tag(atts.value("tag").toUtf8().constData())); @@ -212,7 +212,7 @@ namespace scribo { component_features_data comp_features; comp_features.valid = true; - comp_features.color = scribo::util::hex_to_color(atts.value("color")); + comp_features.color = scribo::util::hex_to_color(atts.value("color").toUtf8().constData()); comp_features.boldness = atts.value("boldness").toFloat(); comp_set_data->infos_.last().update_features(comp_features); @@ -261,7 +261,8 @@ namespace scribo // qDebug() << "TextRegion"; current_paragraph = paragraph_info<L>(llinks); - current_paragraph.set_color_(scribo::util::hex_to_color(atts.value("color"))); + current_paragraph.set_color_( + scribo::util::hex_to_color(atts.value("color").toUtf8().constData())); current_paragraph.set_color_reliability_(atts.value("color_reliability").toFloat()); } break; @@ -282,7 +283,6 @@ namespace scribo line_data = new scribo::internal::line_info_data<L>(lines, mln::util::array<component_id_t>()); - line_data->holder_ = lines; line_data->text_ = atts.value("text").toUtf8().constData(); line_data->hidden_ = false; @@ -299,7 +299,7 @@ namespace scribo line_data->word_space_ = 0; line_data->reading_direction_ = line::LeftToRight; - line_data->type_ = line::str2type(atts.value("txt_text_type").toAscii().constData()); + line_data->type_ = line::str2type(atts.value("txt_text_type").toUtf8().constData()); line_data->reverse_video_ = (atts.value("txt_reverse_video") == "false" ? false : true); line_data->orientation_ = 0; line_data->reading_orientation_ = atts.value("txt_reading_orientation").toInt(); @@ -308,7 +308,8 @@ namespace scribo line_data->boldness_ = atts.value("boldness").toFloat(); line_data->boldness_reliability_ = atts.value("boldness_reliability").toFloat(); - line_data->color_ = scribo::util::hex_to_color(atts.value("color")); + line_data->color_ = scribo::util::hex_to_color( + atts.value("color").toUtf8().constData()); line_data->color_reliability_ = atts.value("color_reliability").toFloat(); @@ -514,7 +515,7 @@ namespace scribo { case LabeledImage: { - QByteArray data = ch.toAscii(); + QByteArray data = ch.toUtf8(); data = QByteArray::fromBase64(data); data = qUncompress(data); memcpy((char *) comp_set_data->ima_.buffer(), data.data(), data.size()); @@ -523,7 +524,7 @@ namespace scribo case SeparatorsImage: { - QByteArray data = ch.toAscii(); + QByteArray data = ch.toUtf8(); data = QByteArray::fromBase64(data); data = qUncompress(data); memcpy((char *) comp_set_data->separators_.buffer(), data.data(), data.size()); @@ -534,7 +535,7 @@ namespace scribo case HLineSeparatorsImage: case VLineSeparatorsImage: { - QByteArray data = ch.toAscii(); + QByteArray data = ch.toUtf8(); data = QByteArray::fromBase64(data); data = qUncompress(data); memcpy((char *) seps.buffer(), data.data(), data.size()); diff --git a/scribo/scribo/postprocessing/images_to_drop_capital.hh b/scribo/scribo/postprocessing/images_to_drop_capital.hh index ca76609..f7d18a6 100644 --- a/scribo/scribo/postprocessing/images_to_drop_capital.hh +++ b/scribo/scribo/postprocessing/images_to_drop_capital.hh @@ -33,6 +33,7 @@ # include <mln/core/concept/image.hh> +# include <mln/draw/box_plain.hh> # include <scribo/core/component_set.hh> # include <scribo/core/document.hh> diff --git a/scribo/scribo/primitive/group/from_double_link.hh b/scribo/scribo/primitive/group/from_double_link.hh index 3af395d..260bfea 100644 --- a/scribo/scribo/primitive/group/from_double_link.hh +++ b/scribo/scribo/primitive/group/from_double_link.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010. 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -89,27 +89,22 @@ namespace scribo mln_precondition(left_link.nelements() == right_link.nelements()); - object_groups<L> parent(left_link); - parent.init(); + object_links<L> parent = left_link.duplicate(); + for_all_comps(i, left_link.components()) - { - mln::util::couple<bool, unsigned> - nbh = internal::is_link_valid(left_link, right_link, i); - if (nbh.first()) + if (internal::is_link_valid(left_link, right_link, i)) { - unsigned par = internal::find_root(parent, nbh.second()); + component_id_t par = left_link(i); if (par < i) - parent(par) = i; + parent.update(par, i); else - parent(i) = par; + parent.update(i, par); } - } - for (unsigned i = parent.nelements() - 1; i < parent.nelements(); --i) - parent(i) = parent(parent(i)); + object_groups<L> result = from_single_link(parent); trace::exiting("scribo::primitive::group::from_double_link"); - return parent; + return result; } diff --git a/scribo/scribo/primitive/link/with_several_left_links.hh b/scribo/scribo/primitive/link/with_several_left_links.hh index 3f9a0cd..e9b53d2 100644 --- a/scribo/scribo/primitive/link/with_several_left_links.hh +++ b/scribo/scribo/primitive/link/with_several_left_links.hh @@ -103,16 +103,16 @@ namespace scribo for_all_comps(i, comps) { - if (link_center(i) != i) - final_link(i) = link_center(i); + if (link_center.is_linked(i)) + final_link.update((i), link_center(i)); else if (link_top(i) == link_bot(i)) - final_link(i) = link_top(i); - else if (link_top(i) != i && link_bot(i) == i) - final_link(i) = link_top(i); - else if (link_bot(i) != i && link_top(i) == i) - final_link(i) = link_bot(i); + final_link.update(i, link_top(i)); + else if (link_top.is_linked(i) && ! link_bot.is_linked(i)) + final_link.update(i, link_top(i)); + else if (link_bot.is_linked(i) && ! link_top.is_linked(i)) + final_link.update(i, link_bot(i)); else - final_link(i) = i; + final_link.clear(i); } diff --git a/scribo/scribo/primitive/link/with_several_right_links.hh b/scribo/scribo/primitive/link/with_several_right_links.hh index d75ac7b..6590309 100644 --- a/scribo/scribo/primitive/link/with_several_right_links.hh +++ b/scribo/scribo/primitive/link/with_several_right_links.hh @@ -106,16 +106,16 @@ namespace scribo for_all_comps(i, comps) { - if (link_center(i) != i) - final_link(i) = link_center(i); + if (link_center.is_linked(i)) + final_link.update(i, link_center(i)); else if (link_top(i) == link_bot(i)) - final_link(i) = link_top(i); - else if (link_top(i) != i && link_bot(i) == i) - final_link(i) = link_top(i); - else if (link_bot(i) != i && link_top(i) == i) - final_link(i) = link_bot(i); + final_link.update(i, link_top(i)); + else if (link_top.is_linked(i) && ! link_bot.is_linked(i)) + final_link.update(i, link_top(i)); + else if (link_bot.is_linked(i) && ! link_top.is_linked(i)) + final_link.update(i, link_bot(i)); else - final_link(i) = i; + final_link.clear(i); } trace::exiting("scribo::primitive::link::with_several_right_links"); diff --git a/scribo/scribo/primitive/remove/separators.hh b/scribo/scribo/primitive/remove/separators.hh index 1b75494..192867f 100644 --- a/scribo/scribo/primitive/remove/separators.hh +++ b/scribo/scribo/primitive/remove/separators.hh @@ -39,6 +39,7 @@ # include <mln/data/fill.hh> +# include <mln/border/fill.hh> # include <mln/border/resize.hh> diff --git a/scribo/scribo/text/extract_paragraphs.hh b/scribo/scribo/text/extract_paragraphs.hh index e8e9ac6..1cf9a62 100644 --- a/scribo/scribo/text/extract_paragraphs.hh +++ b/scribo/scribo/text/extract_paragraphs.hh @@ -47,6 +47,7 @@ #include <mln/geom/rotate.hh> #include <mln/literal/colors.hh> +#include <scribo/core/def/lbl_type.hh> #include <scribo/core/macros.hh> #include <scribo/core/line_set.hh> #include <scribo/core/line_links.hh> diff --git a/scribo/scribo/text/extract_paragraphs_hdoc.hh b/scribo/scribo/text/extract_paragraphs_hdoc.hh index 57d3713..52f4ea0 100644 --- a/scribo/scribo/text/extract_paragraphs_hdoc.hh +++ b/scribo/scribo/text/extract_paragraphs_hdoc.hh @@ -47,6 +47,7 @@ #include <mln/geom/rotate.hh> #include <mln/literal/colors.hh> +#include <scribo/core/def/lbl_type.hh> #include <scribo/core/macros.hh> #include <scribo/core/line_set.hh> #include <scribo/core/line_links.hh> @@ -1301,18 +1302,18 @@ namespace scribo rbbox.resize(lines.nelements() + 1); // std::cout << "Preparing lines" << std::endl; - prepare_lines(input.domain(), lines , blocks, rbbox); + internal::prepare_lines(input.domain(), lines , blocks, rbbox); // io::pgm::save(blocks, "blocks.pgm"); // std::cout << "Linking left" << std::endl; - process_left_link(blocks, rbbox, lines , left); + internal::process_left_link(blocks, rbbox, lines , left); // std::cout << "Linking right" << std::endl; - process_right_link(blocks, rbbox, lines , right); + internal::process_right_link(blocks, rbbox, lines , right); // std::cout << "Finalizing links" << std::endl; - finalize_links(left, right, lines ); + internal::finalize_links(left, right, lines ); // std::cout << "Finalizing merging" << std::endl; // finalize_line_merging(left, right, lines); // std::cout << "Extracting paragraphs" << std::endl; - filter::paragraph_links(left, right, output, lines); + internal::paragraph_links(left, right, output, lines); paragraph_set<L> par_set = make::paragraph(output, right); return par_set; diff --git a/scribo/scribo/text/paragraphs_closing.hh b/scribo/scribo/text/paragraphs_closing.hh index 2b685df..13f8bc2 100644 --- a/scribo/scribo/text/paragraphs_closing.hh +++ b/scribo/scribo/text/paragraphs_closing.hh @@ -32,7 +32,10 @@ /// Paragraphs closing using CRLA. # include <mln/draw/line.hh> + +# include <scribo/core/paragraph_set.hh> # include <scribo/draw/line_components.hh> +# include <scribo/debug/logger.hh> namespace scribo { diff --git a/scribo/scribo/toolchain/internal/content_in_hdoc_functor.hh b/scribo/scribo/toolchain/internal/content_in_hdoc_functor.hh index 4a74aef..bda31b3 100644 --- a/scribo/scribo/toolchain/internal/content_in_hdoc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_hdoc_functor.hh @@ -76,7 +76,7 @@ # include <scribo/text/merging_hdoc.hh> # include <scribo/text/link_lines.hh> -# include <scribo/text/paragraphs_hdoc.hh> +# include <scribo/text/extract_paragraphs_hdoc.hh> # include <scribo/make/debug_filename.hh> diff --git a/scribo/src/afp/link.hh b/scribo/src/afp/link.hh index dfcde88..2e2d474 100644 --- a/scribo/src/afp/link.hh +++ b/scribo/src/afp/link.hh @@ -52,7 +52,7 @@ namespace scribo template <typename L> - util::couple<object_links<L>, object_links<L> > + mln::util::couple<object_links<L>, object_links<L> > left_right(const component_set<L>& components) { object_links<L> @@ -96,7 +96,7 @@ namespace scribo && *p != i // Not the current component && right(*p) != i) // No loops { - right(i) = *p; + right.update(i, *p); break; } } @@ -115,7 +115,7 @@ namespace scribo && *p != i // Not the current component && left(*p) != i) // No loops { - left(i) = *p; + left.update(i, *p); break; } } diff --git a/scribo/src/debug/show_paragraph_blocks.cc b/scribo/src/debug/show_paragraph_blocks.cc index e99c2ec..0954964 100644 --- a/scribo/src/debug/show_paragraph_blocks.cc +++ b/scribo/src/debug/show_paragraph_blocks.cc @@ -87,7 +87,7 @@ int main(int argc, char* argv[]) scribo::paragraph_set<L> parset = scribo::make::paragraph(llinks); doc.set_paragraphs(parset); - util::timer t; + mln::util::timer t; t.start(); image2d<bool> blocks; diff --git a/scribo/src/debug/show_text_lines.cc b/scribo/src/debug/show_text_lines.cc index 1da0d66..57608f0 100644 --- a/scribo/src/debug/show_text_lines.cc +++ b/scribo/src/debug/show_text_lines.cc @@ -74,7 +74,7 @@ int main(int argc, char* argv[]) image2d<bool> input_seps; mln::io::pbm::load(input_seps, argv[2]); - util::timer t; + mln::util::timer t; t.start(); typedef image2d<scribo::def::lbl_type> L; @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) for_all_lines(l, lines) if (lines(l).is_textline()) { - const util::array<component_id_t>& comps = lines(l).component_ids(); + const mln::util::array<component_id_t>& comps = lines(l).component_ids(); const L& lbl = lines.components().labeled_image(); for_all_elements(c, comps) data::fill((output | lines.components()(comps(c)).bbox()).rw(), diff --git a/scribo/src/non_text_components.cc b/scribo/src/non_text_components.cc index 0f4cce4..38a4e5e 100644 --- a/scribo/src/non_text_components.cc +++ b/scribo/src/non_text_components.cc @@ -88,7 +88,7 @@ int main(int argc, char* argv[]) image2d<value::rgb8> input; mln::io::magick::load(input, argv[1]); - util::timer t; + mln::util::timer t; t.start(); // Preprocess document diff --git a/scribo/src/primitive/extract/alignments.cc b/scribo/src/primitive/extract/alignments.cc index 6690b17..544322a 100644 --- a/scribo/src/primitive/extract/alignments.cc +++ b/scribo/src/primitive/extract/alignments.cc @@ -30,6 +30,7 @@ #include <scribo/text/extract_lines_wo_merge.hh> #include <scribo/primitive/extract/alignments.hh> +#include <scribo/primitive/extract/separators.hh> #include <scribo/primitive/remove/separators.hh> #include <scribo/debug/usage.hh> @@ -77,14 +78,14 @@ int main(int argc, char *argv[]) lines = scribo::text::extract_lines_wo_merge(doc, c8(), separators); doc.set_paragraphs(scribo::make::paragraph(lines)); - util::timer t; + mln::util::timer t; t.start(); mln::util::couple<component_set<L>, mln_ch_value_(L,bool)> res = primitive::extract::alignments(doc, dmax_ratio, delta_pixel); t.stop(); std::cout << t << std::endl; - io::pbm::save(res.second(), argv[2]); + mln::io::pbm::save(res.second(), argv[2]); trace::exiting("main"); } diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc index af00c4f..d4b5320 100644 --- a/scribo/src/text_in_picture.cc +++ b/scribo/src/text_in_picture.cc @@ -69,7 +69,7 @@ #include <scribo/filter/object_links_bbox_overlap.hh> #include <scribo/filter/object_groups_small.hh> -#include <scribo/filter/object_groups_v_thickness.hh> +#include <scribo/filter/object_groups_mean_width.hh> #include <scribo/debug/highlight_text_area.hh> #include <scribo/debug/text_areas_image.hh> @@ -498,8 +498,8 @@ int main(int argc, char* argv[]) { std::cout << "** Using group too thin" << std::endl; filtered_thin_groups - = filter::object_groups_v_thickness(filtered_small_groups, - conf.v_thickness); + = filter::object_groups_mean_width(filtered_small_groups, + conf.v_thickness); } else filtered_thin_groups = filtered_small_groups; diff --git a/scribo/src/text_in_picture_neg.cc b/scribo/src/text_in_picture_neg.cc index 2b06a72..9f98372 100644 --- a/scribo/src/text_in_picture_neg.cc +++ b/scribo/src/text_in_picture_neg.cc @@ -86,7 +86,6 @@ #include <scribo/filter/common/objects_photo.hh> #include <scribo/filter/object_groups_small.hh> -#include <scribo/filter/object_groups_v_thickness.hh> #include <scribo/debug/highlight_text_area.hh> #include <scribo/debug/text_areas_image.hh> diff --git a/scribo/src/text_recognition_in_picture.cc b/scribo/src/text_recognition_in_picture.cc index de7a9ed..f71b280 100644 --- a/scribo/src/text_recognition_in_picture.cc +++ b/scribo/src/text_recognition_in_picture.cc @@ -90,7 +90,7 @@ #include <scribo/filter/common/objects_photo.hh> #include <scribo/filter/object_groups_small.hh> -#include <scribo/filter/object_groups_v_thickness.hh> +#include <scribo/filter/object_groups_mean_width.hh> #include <scribo/debug/highlight_text_area.hh> @@ -344,8 +344,8 @@ int main(int argc, char* argv[]) // Remove components part of groups having a mean thickness lower than 8. object_groups<L> filtered_thin_groups; filtered_thin_groups - = filter::object_groups_v_thickness(filtered_small_groups, - conf.v_thickness); + = filter::object_groups_mean_width(filtered_small_groups, + conf.v_thickness); // Grouping groups together if possible. -- 1.5.6.5
participants (1)
-
Guillaume Lazzara