LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
9625 discussions
Start a n
N
ew thread
last-svn-commit-768-g26501ab mln/util/array.hh: Add last() method.
by Guillaume Lazzara
--- milena/ChangeLog | 4 ++++ milena/mln/util/array.hh | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index e03d35c..c4bed2c 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,9 @@ 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + * mln/util/array.hh: Add last() method. + +2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Add an optional base index for debug::iota. * mln/debug/iota.hh, diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh index 0fe34e7..c7febfe 100644 --- a/milena/mln/util/array.hh +++ b/milena/mln/util/array.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2008, 2009, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -187,6 +187,11 @@ namespace mln /// \pre i < nelements() mutable_result operator[](unsigned i); + /// \brief Return the last element. + ro_result last() const; + + /// \brief Return the last element. + mutable_result last(); /// Empty the array. All elements contained in the array are /// destroyed. \post is_empty() == true @@ -553,6 +558,22 @@ namespace mln template <typename T> inline + typename array<T>::ro_result + array<T>::last() const + { + return v_[nelements() - 1]; + } + + template <typename T> + inline + typename array<T>::mutable_result + array<T>::last() + { + return v_[nelements() - 1]; + } + + template <typename T> + inline bool array<T>::is_empty() const { -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-769-g7bdf8a2 Rename files in Scribo.
by Guillaume Lazzara
* scribo/primitive/extract/elements.hh, * src/primitive/extract/extract_discontinued_hlines.cc, * src/primitive/extract/extract_discontinued_lines.cc, * src/primitive/extract/extract_discontinued_vlines.cc, * src/primitive/extract/extract_thick_hlines.cc, * src/primitive/extract/extract_thick_vlines.cc: Rename to... * scribo/primitive/extract/non_text.hh, * src/primitive/extract/discontinued_hlines.cc, * src/primitive/extract/discontinued_lines.cc, * src/primitive/extract/discontinued_vlines.cc, * src/primitive/extract/thick_hlines.cc, * src/primitive/extract/thick_vlines.cc: ... this. * scribo/toolchain/internal/content_in_doc_functor.hh: Rename function call from extract::elements to extract_non_text. * src/primitive/extract/Makefile.am: Update target names. --- scribo/ChangeLog | 23 +++++++ .../primitive/extract/{elements.hh => non_text.hh} | 64 +++++++++++--------- .../toolchain/internal/content_in_doc_functor.hh | 2 +- scribo/src/primitive/extract/Makefile.am | 26 ++++---- ...scontinued_hlines.cc => discontinued_hlines.cc} | 0 ...discontinued_lines.cc => discontinued_lines.cc} | 0 ...scontinued_vlines.cc => discontinued_vlines.cc} | 0 .../{extract_thick_hlines.cc => thick_hlines.cc} | 0 .../{extract_thick_vlines.cc => thick_vlines.cc} | 0 9 files changed, 73 insertions(+), 42 deletions(-) rename scribo/scribo/primitive/extract/{elements.hh => non_text.hh} (82%) rename scribo/src/primitive/extract/{extract_discontinued_hlines.cc => discontinued_hlines.cc} (100%) rename scribo/src/primitive/extract/{extract_discontinued_lines.cc => discontinued_lines.cc} (100%) rename scribo/src/primitive/extract/{extract_discontinued_vlines.cc => discontinued_vlines.cc} (100%) rename scribo/src/primitive/extract/{extract_thick_hlines.cc => thick_hlines.cc} (100%) rename scribo/src/primitive/extract/{extract_thick_vlines.cc => thick_vlines.cc} (100%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 9cbfca1..e08f2fd 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,28 @@ 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Rename files in Scribo. + + * scribo/primitive/extract/elements.hh, + * src/primitive/extract/extract_discontinued_hlines.cc, + * src/primitive/extract/extract_discontinued_lines.cc, + * src/primitive/extract/extract_discontinued_vlines.cc, + * src/primitive/extract/extract_thick_hlines.cc, + * src/primitive/extract/extract_thick_vlines.cc: Rename to... + + * scribo/primitive/extract/non_text.hh, + * src/primitive/extract/discontinued_hlines.cc, + * src/primitive/extract/discontinued_lines.cc, + * src/primitive/extract/discontinued_vlines.cc, + * src/primitive/extract/thick_hlines.cc, + * src/primitive/extract/thick_vlines.cc: ... this. + + * scribo/toolchain/internal/content_in_doc_functor.hh: Rename + function call from extract::elements to extract_non_text. + + * src/primitive/extract/Makefile.am: Update target names. + +2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Add Base64 conversion routines. * scribo/scribo/convert/from_base64.hh, diff --git a/scribo/scribo/primitive/extract/elements.hh b/scribo/scribo/primitive/extract/non_text.hh similarity index 82% rename from scribo/scribo/primitive/extract/elements.hh rename to scribo/scribo/primitive/extract/non_text.hh index ddf2c92..a017f1f 100644 --- a/scribo/scribo/primitive/extract/elements.hh +++ b/scribo/scribo/primitive/extract/non_text.hh @@ -26,12 +26,12 @@ /// \file /// -/// \brief Find in a document elements which are not text. +/// \brief Find in a document non text which are not text. /// /// \fixme To be optimized! -#ifndef SCRIBO_PRIMITIVE_EXTRACT_ELEMENTS_HH -# define SCRIBO_PRIMITIVE_EXTRACT_ELEMENTS_HH +#ifndef SCRIBO_PRIMITIVE_EXTRACT_NON_TEXT_HH +# define SCRIBO_PRIMITIVE_EXTRACT_NON_TEXT_HH # include <mln/core/image/image2d.hh> # include <mln/core/alias/neighb2d.hh> @@ -58,6 +58,10 @@ # include <mln/clustering/kmean_rgb.hh> # include <mln/fun/v2v/rgb8_to_rgbn.hh> +# include <mln/util/timer.hh> + +# include <mln/io/pbm/save.hh> + namespace scribo { @@ -72,7 +76,7 @@ namespace scribo template <typename L, typename I> component_set<L> - elements(const document<L>& doc, const Image<I>& input); + non_text(const document<L>& doc, const Image<I>& input); # ifndef MLN_INCLUDE_ONLY @@ -107,9 +111,9 @@ namespace scribo template <typename L, typename I> component_set<L> - elements(const document<L>& doc, const Image<I>& input_) + non_text(const document<L>& doc, const Image<I>& input_) { - trace::entering("scribo::primitive::extract::elements"); + trace::entering("scribo::primitive::extract::non_text"); const I& input = exact(input_); mln_precondition(doc.is_valid()); @@ -135,9 +139,16 @@ namespace scribo image2d<t_rgb5> img_rgb5 = mln::data::transform(doc.image(), t_rgb8_to_rgb5()); + // DEBUG + io::pbm::save(content, "text_area.pbm"); + + mln::util::timer t; + t.start(); img_lbl8 = mln::clustering::kmean_rgb<double,5>((img_rgb5 | pw::value(content)), 3, 10, 10).unmorph_(); data::fill((img_lbl8 | !pw::value(content)).rw(), 0u); + t.stop(); + std::cout << t << std::endl; mln::util::array<unsigned> card = mln::labeling::compute(accu::math::count<value::label_8>(), @@ -162,15 +173,25 @@ namespace scribo std::cout << "Removing small elements" << std::endl; { - image2d<bool> elts; - initialize(elts, img_lbl8); - data::fill(elts, false); - data::fill((elts | (pw::value(img_lbl8) != pw::cst(0))).rw(), true); + image2d<bool> elts; + initialize(elts, img_lbl8); + data::fill(elts, false); + data::fill((elts | (pw::value(img_lbl8) != pw::cst(0))).rw(), true); + + // DEBUG + data::fill((elts | (pw::value(doc.line_seps()) != pw::cst(0))).rw(), + false); + // END OF DEBUG + - scribo::def::lbl_type nlabels; - elts = filter::components_small(elts, c8(), nlabels, 40); + scribo::def::lbl_type nlabels; + elts = filter::components_small(elts, c8(), nlabels, 40); - output = primitive::extract::components(elts, c8(), nlabels); + // DEBUG + io::pbm::save(elts, "elements.pbm"); + // END OF DEBUG + + output = primitive::extract::components(elts, c8(), nlabels); } @@ -207,20 +228,7 @@ namespace scribo } } -// mln::io::pbm::save(merged_elts, "merged_elts.pbm"); - -// mln::util::array<image2d<value::rgb8> > elt_ima; -// unsigned i = 0; -// for_all_comps(c, elt_comp) -// if (elt_comp(c).is_valid()) -// { -// elt_ima.append(preprocessing::crop(doc.image(), elt_comp(c).bbox())); -// mln::io::ppm::save(elt_ima(i), mln::debug::filename("elt.ppm", i)); -// ++i; -// } - - - trace::exiting("scribo::primitive::extract::elements"); + trace::exiting("scribo::primitive::extract::non_text"); return output; } @@ -233,4 +241,4 @@ namespace scribo } // end of namespace scribo -#endif // ! SCRIBO_PRIMITIVE_EXTRACT_ELEMENTS_HH +#endif // ! SCRIBO_PRIMITIVE_EXTRACT_NON_TEXT_HH diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh index b8aa56d..ed691e8 100644 --- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh @@ -463,7 +463,7 @@ namespace scribo // Extract other Elements on_new_progress_label("Extracting Elements"); component_set<L> - elements = scribo::primitive::extract::elements(doc, original_image); + elements = scribo::primitive::extract::non_text(doc, original_image); on_progress(); diff --git a/scribo/src/primitive/extract/Makefile.am b/scribo/src/primitive/extract/Makefile.am index 2c8188e..a46cd68 100644 --- a/scribo/src/primitive/extract/Makefile.am +++ b/scribo/src/primitive/extract/Makefile.am @@ -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. # @@ -18,17 +18,17 @@ include $(top_srcdir)/scribo/scribo.mk -noinst_PROGRAMS = \ - extract_discontinued_lines \ - extract_discontinued_vlines \ - extract_discontinued_hlines \ - extract_thick_vlines \ - extract_thick_hlines \ +noinst_PROGRAMS = \ + discontinued_lines \ + discontinued_vlines \ + discontinued_hlines \ + thick_vlines \ + thick_hlines \ lines_pattern -extract_discontinued_lines_SOURCES = extract_discontinued_lines.cc -extract_discontinued_vlines_SOURCES = extract_discontinued_vlines.cc -extract_discontinued_hlines_SOURCES = extract_discontinued_hlines.cc -extract_thick_vlines_SOURCES = extract_thick_vlines.cc -extract_thick_hlines_SOURCES = extract_thick_hlines.cc +discontinued_lines_SOURCES = discontinued_lines.cc +discontinued_vlines_SOURCES = discontinued_vlines.cc +discontinued_hlines_SOURCES = discontinued_hlines.cc +thick_vlines_SOURCES = thick_vlines.cc +thick_hlines_SOURCES = thick_hlines.cc lines_pattern_SOURCES = lines_pattern.cc diff --git a/scribo/src/primitive/extract/extract_discontinued_hlines.cc b/scribo/src/primitive/extract/discontinued_hlines.cc similarity index 100% rename from scribo/src/primitive/extract/extract_discontinued_hlines.cc rename to scribo/src/primitive/extract/discontinued_hlines.cc diff --git a/scribo/src/primitive/extract/extract_discontinued_lines.cc b/scribo/src/primitive/extract/discontinued_lines.cc similarity index 100% rename from scribo/src/primitive/extract/extract_discontinued_lines.cc rename to scribo/src/primitive/extract/discontinued_lines.cc diff --git a/scribo/src/primitive/extract/extract_discontinued_vlines.cc b/scribo/src/primitive/extract/discontinued_vlines.cc similarity index 100% rename from scribo/src/primitive/extract/extract_discontinued_vlines.cc rename to scribo/src/primitive/extract/discontinued_vlines.cc diff --git a/scribo/src/primitive/extract/extract_thick_hlines.cc b/scribo/src/primitive/extract/thick_hlines.cc similarity index 100% rename from scribo/src/primitive/extract/extract_thick_hlines.cc rename to scribo/src/primitive/extract/thick_hlines.cc diff --git a/scribo/src/primitive/extract/extract_thick_vlines.cc b/scribo/src/primitive/extract/thick_vlines.cc similarity index 100% rename from scribo/src/primitive/extract/extract_thick_vlines.cc rename to scribo/src/primitive/extract/thick_vlines.cc -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-770-gb9a6289 Various changes in scribo core structures.
by Guillaume Lazzara
* scribo/scribo/core/component_info.hh: Remove useless line_id. * scribo/scribo/core/line_set.hh, * scribo/scribo/core/component_set.hh: Add new constructors. * scribo/scribo/core/document.hh: Store line separators. * scribo/scribo/core/line_info.hh: Share attributes and add new constructors. (is_textline): New method. * scribo/scribo/core/line_links.hh: Do not allocate useless data. * scribo/scribo/core/paragraph_info.hh (operator<<): New. * scribo/scribo/core/paragraph_set.hh: Share attributes and add new constructors. --- scribo/ChangeLog | 22 ++ scribo/scribo/core/component_info.hh | 17 +-- scribo/scribo/core/component_set.hh | 65 +++++-- scribo/scribo/core/document.hh | 48 +++++- scribo/scribo/core/line_info.hh | 367 ++++++++++++++++++---------------- scribo/scribo/core/line_links.hh | 2 +- scribo/scribo/core/line_set.hh | 29 +++- scribo/scribo/core/paragraph_info.hh | 10 + scribo/scribo/core/paragraph_set.hh | 84 +++++++- 9 files changed, 425 insertions(+), 219 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index e08f2fd..ab028c3 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,27 @@ 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Various changes in scribo core structures. + + * scribo/scribo/core/component_info.hh: Remove useless line_id. + + * scribo/scribo/core/line_set.hh, + * scribo/scribo/core/component_set.hh: Add new constructors. + + * scribo/scribo/core/document.hh: Store line separators. + + * scribo/scribo/core/line_info.hh: Share attributes and add new + constructors. + (is_textline): New method. + + * scribo/scribo/core/line_links.hh: Do not allocate useless data. + + * scribo/scribo/core/paragraph_info.hh (operator<<): New. + + * scribo/scribo/core/paragraph_set.hh: Share attributes and add new + constructors. + +2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Rename files in Scribo. * scribo/primitive/extract/elements.hh, diff --git a/scribo/scribo/core/component_info.hh b/scribo/scribo/core/component_info.hh index 4ed6db7..1b03318 100644 --- a/scribo/scribo/core/component_info.hh +++ b/scribo/scribo/core/component_info.hh @@ -47,7 +47,6 @@ namespace scribo class component_info { typedef mln::util::object_id<scribo::ComponentId, unsigned> component_id_t; - typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t; public: component_info(); @@ -69,9 +68,6 @@ namespace scribo component::Type type() const; void update_type(component::Type type); - // The line it is rattached to. 0 means an invalid line. - line_id_t line_id() const; - bool is_valid() const; private: @@ -82,8 +78,6 @@ namespace scribo component::Tag tag_; component::Type type_; - - line_id_t line_id_; }; @@ -109,7 +103,7 @@ namespace scribo const mln::point2d& mass_center, unsigned card) : id_(id), bbox_(bbox), mass_center_(mass_center), card_(card), - tag_(component::None), type_(component::Undefined), line_id_(0) + tag_(component::None), type_(component::Undefined) { } @@ -179,14 +173,6 @@ namespace scribo inline - component_info::line_id_t - component_info::line_id() const - { - return line_id_; - } - - - inline bool component_info::is_valid() const { @@ -204,7 +190,6 @@ namespace scribo << ", mass_center=" << info.mass_center() << ", card=" << info.card() << ", tag=" << info.tag() - << ", line_id=" << info.line_id() << ")" << std::endl; } diff --git a/scribo/scribo/core/component_set.hh b/scribo/scribo/core/component_set.hh index 103826f..7ddcf16 100644 --- a/scribo/scribo/core/component_set.hh +++ b/scribo/scribo/core/component_set.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. // @@ -55,6 +55,8 @@ # include <mln/core/routine/duplicate.hh> +# include <mln/value/next.hh> + # include <scribo/core/macros.hh> # include <scribo/core/component_info.hh> @@ -95,6 +97,8 @@ namespace scribo void fill_infos(const mln::util::array<pair_data_t>& attribs); + // Useful while constructing incrementaly (XML loading). + void soft_init(const mln_value(L) ncomps); L ima_; mln_value(L) ncomps_; @@ -128,6 +132,9 @@ namespace scribo /// Constructor without argument. component_set(); + // Constructor from internal data. + component_set(const mln::util::tracked_ptr<data_t>& data); + /// Constructor from an image \p ima and the number of labels \p ncomps. component_set(const L& ima, const mln_value(L)& ncomps); @@ -348,6 +355,19 @@ namespace scribo } + template <typename L> + inline + void + component_set_data<L>::soft_init(const mln_value(L) ncomps) + { + mln_precondition(infos_.nelements() == 0); + + ncomps_ = ncomps; + infos_.reserve(ncomps_); + infos_.append(component_info()); // Component 0, i.e. the background. + } + + } // end of namespace mln::internal @@ -361,6 +381,13 @@ namespace scribo template <typename L> inline + component_set<L>::component_set(const mln::util::tracked_ptr<data_t>& data) + { + data_ = data; + } + + template <typename L> + inline component_set<L>::component_set(const L& ima, const mln_value(L)& ncomps) { data_ = new internal::component_set_data<L>(ima, ncomps); @@ -400,7 +427,7 @@ namespace scribo const component_info& component_set<L>::info(const mln_value(L)& id) const { - return this->data_->infos_[id]; + return data_->infos_[id]; } template <typename L> @@ -408,7 +435,7 @@ namespace scribo component_info& component_set<L>::info(const mln_value(L)& id) { - return this->data_->infos_[id]; + return data_->infos_[id]; } // template <typename L> @@ -416,7 +443,7 @@ namespace scribo // const component_info& // component_set<L>::operator()(const mln_value(L)& id) const // { -// return this->data_->infos_[id]; +// return data_->infos_[id]; // } // template <typename L> @@ -424,7 +451,7 @@ namespace scribo // component_info& // component_set<L>::operator()(const mln_value(L)& id) // { -// return this->data_->infos_[id]; +// return data_->infos_[id]; // } template <typename L> @@ -432,7 +459,7 @@ namespace scribo const component_info& component_set<L>::operator()(const component_id_t& id) const { - return this->data_->infos_[id]; + return data_->infos_[id]; } template <typename L> @@ -440,7 +467,7 @@ namespace scribo component_info& component_set<L>::operator()(const component_id_t& id) { - return this->data_->infos_[id]; + return data_->infos_[id]; } @@ -476,7 +503,7 @@ namespace scribo const L& component_set<L>::labeled_image() const { - return this->data_->ima_; + return data_->ima_; } @@ -485,7 +512,7 @@ namespace scribo bool component_set<L>::is_valid() const { - return this->data_->ima_.is_valid(); + return data_ != 0 && data_->ima_.is_valid(); } @@ -503,7 +530,7 @@ namespace scribo L& component_set<L>::labeled_image_() { - return this->data_->ima_; + return data_->ima_; } @@ -512,7 +539,7 @@ namespace scribo mln_concrete(L) component_set<L>::valid_comps_image_() const { - mln::util::array<bool> f(mln::value::next(this->data_->ncomps_)); + mln::util::array<bool> f(mln::value::next(data_->ncomps_)); f(0) = true; for_all_comps(c, (*this)) @@ -520,8 +547,8 @@ namespace scribo mln_value(L) new_ncomps; mln_concrete(L) - output = mln::labeling::relabel(this->data_->ima_, - this->data_->ncomps_, + output = mln::labeling::relabel(data_->ima_, + data_->ncomps_, new_ncomps, f); @@ -534,7 +561,7 @@ namespace scribo bool component_set<L>::has_separators() const { - return this->data_->separators_.is_valid(); + return data_->separators_.is_valid(); } @@ -544,9 +571,9 @@ namespace scribo component_set<L>::add_separators(const mln_ch_value(L, bool)& ima) { if (! has_separators()) - this->data_->separators_ = ima; + data_->separators_ = ima; else - mln::logical::or_inplace(this->data_->separators_, ima); + mln::logical::or_inplace(data_->separators_, ima); } @@ -555,7 +582,7 @@ namespace scribo const mln_ch_value(L, bool)& component_set<L>::separators() const { - return this->data_->separators_; + return data_->separators_; } @@ -564,7 +591,7 @@ namespace scribo void component_set<L>::clear_separators() { - this->data_->separators_.destroy(); + data_->separators_.destroy(); } diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh index f112410..e5ac825 100644 --- a/scribo/scribo/core/document.hh +++ b/scribo/scribo/core/document.hh @@ -91,16 +91,24 @@ namespace scribo const component_set<L>& whitespace_seps_comps() const; void set_whitespace_separators(const image2d<bool>& whitespace_seps); + bool has_line_seps() const; + const mln::image2d<bool>& line_seps() const; + const component_set<L>& line_seps_comps() const; + void set_line_separators(const image2d<bool>& line_seps); + + private: const char *filename_; mln::image2d<mln::value::rgb8> image_; - line_set<L> lines_; paragraph_set<L> parset_; component_set<L> elements_; mln::image2d<bool> whitespace_seps_; component_set<L> whitespace_seps_comps_; + + mln::image2d<bool> line_seps_; + component_set<L> line_seps_comps_; }; @@ -201,7 +209,6 @@ namespace scribo return parset_.lines(); } - template <typename L> const paragraph_set<L>& document<L>::paragraphs() const @@ -294,6 +301,43 @@ namespace scribo } + template <typename L> + bool + document<L>::has_line_seps() const + { + return line_seps_.is_valid(); + } + + + template <typename L> + const mln::image2d<bool>& + document<L>::line_seps() const + { + return line_seps_; + } + + + template <typename L> + const component_set<L>& + document<L>::line_seps_comps() const + { + return line_seps_comps_; + } + + + template <typename L> + void + document<L>::set_line_separators(const image2d<bool>& line_seps) + { + line_seps_ = line_seps; + + mln_value(L) ncomps; + line_seps_comps_ = primitive::extract::components(line_seps, + mln::c8(), ncomps); + } + + + # endif // ! MLN_INCLUDE_ONLY diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh index 54a5094..c82160a 100644 --- a/scribo/scribo/core/line_info.hh +++ b/scribo/scribo/core/line_info.hh @@ -58,12 +58,76 @@ namespace scribo // Forward declarations. template <typename L> class line_set; + template <typename L> class line_info; typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t; + + namespace internal + { + /// Data structure for \c scribo::line_info<I>. + template <typename L> + struct line_info_data + { + line_info_data(); + line_info_data(const line_set<L>& holder, + const mln::util::array<component_id_t>& comps); + + + bool hidden_; + line::Tag tag_; + mln::box2d bbox_; + mln::box2d ebbox_; + mln::util::array<component_id_t> components_; + + // Values relative to the line bbox. + int baseline_; + int meanline_; + + // Values relative to the baseline. + unsigned x_height_; + int d_height_; + int a_height_; + + // Character related stats. + unsigned char_space_; + unsigned char_width_; + + // Words related stats. + unsigned word_space_; + + // Reading direction + line::ReadingDirection reading_direction_; + + // Line type + line::Type type_; + + // Is this line in reverse video? + bool reverse_video_; + + // Text orientation + float orientation_; + + // Text reading orientation + float reading_orientation_; + + bool indented_; + + std::string text_; + + // Line set holding this element. + line_set<L> holder_; + + }; + + } // end of namespace scribo::internal + + + template <typename L> class line_info { + typedef internal::line_info_data<L> data_t; typedef mln::util::object_id<scribo::ComponentId, unsigned> component_id_t; typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t; @@ -74,6 +138,8 @@ namespace scribo line_info(); + line_info(const line_id_t& id, data_t* data); + line_info(const line_set<L>& holder, const line_id_t& id, const mln::util::array<component_id_t>& comps); @@ -134,9 +200,10 @@ namespace scribo const std::string& text() const; void update_text(const std::string& str); - bool is_valid() const; + bool is_textline() const; + /// Hidden status. /// /// When a line is hidden, it should not be used in routines @@ -180,6 +247,9 @@ namespace scribo /// Returns the delta used to compute the extended bbox. int delta_of_line() const; + /// Update the extended bbox. + void update_ebbox(); + private: // Members void copy_data(const line_info<L>& other); @@ -189,81 +259,59 @@ namespace scribo /// Update bbox and ebbox_ attributes. void update_bbox_and_ebox(line_info<L>& other); - /// Update the extended bbox. - void update_ebbox(); - mln::box2d merged_ebbox(const scribo::line_info<L>& info_l, const scribo::line_info<L>& info); void update_components_type(component::Type type); private: // Attributes - // WARNING: NEVER FORGET TO UPDATE COPY CONSTRUCTOR REDEFINITION!!!! - line_id_t id_; - bool hidden_; - line::Tag tag_; - mln::box2d bbox_; - mln::box2d ebbox_; - mln::util::array<component_id_t> components_; - - // Values relative to the line bbox. - int baseline_; - int meanline_; - - // Values relative to the baseline. - unsigned x_height_; - int d_height_; - int a_height_; - - // WARNING: NEVER FORGET TO UPDATE COPY CONSTRUCTOR REDEFINITION!!!! - - // Character related stats. - unsigned char_space_; - unsigned char_width_; - - // Words related stats. - unsigned word_space_; - - // Reading direction - line::ReadingDirection reading_direction_; - - // Line type - line::Type type_; + mln::util::tracked_ptr<data_t> data_; + }; - // Is this line in reverse video? - bool reverse_video_; - // Text orientation - float orientation_; + template <typename L> + std::ostream& + operator<<(std::ostream& ostr, const line_info<L>& info); - // Text reading orientation - float reading_orientation_; - bool indented_; +# ifndef MLN_INCLUDE_ONLY - std::string text_; + namespace internal + { - // Line set holding this element. - line_set<L> holder_; + template <typename L> + line_info_data<L>::line_info_data() + { + hidden_ = false; + } - // WARNING: NEVER FORGET TO UPDATE COPY CONSTRUCTOR REDEFINITION!!!! - }; + template <typename L> + line_info_data<L>::line_info_data(const line_set<L>& holder, + const mln::util::array<component_id_t>& comps) + : hidden_(false), tag_(line::None), components_(comps), + type_(line::Undefined), holder_(holder) + { + // FIXME: set valid information for these attributes in + // force_stats_update. + word_space_ = 0; + reading_direction_ = line::LeftToRight; + reverse_video_ = false; - template <typename L> - std::ostream& - operator<<(std::ostream& ostr, const line_info<L>& info); + orientation_ = 0.; + reading_orientation_ = 0.; + indented_ = false; + } -# ifndef MLN_INCLUDE_ONLY + } // end of namespace scribo::internal template <typename L> line_info<L>::line_info() - : id_(0), hidden_(false) + : id_(0) { - } template <typename L> @@ -275,47 +323,24 @@ namespace scribo if (! is_valid()) id_ = other.id(); - hidden_ = other.hidden_; - - tag_ = other.tag(); - bbox_ = other.bbox(); - ebbox_ = other.ebbox(); - components_ = other.components(); - - baseline_ = other.baseline(); - meanline_ = other.meanline(); - - x_height_ = other.x_height(); - d_height_ = other.d_height(); - a_height_ = other.a_height(); - - char_space_ = other.char_space(); - char_width_ = other.char_width(); - - word_space_ = other.word_space(); - - reading_direction_ = other.reading_direction(); - - type_ = other.type(); - - reverse_video_ = other.reverse_video(); - - orientation_ = other.orientation(); - - reading_orientation_ = other.reading_orientation(); - - indented_ = other.indented(); + data_ = other.data_; + } - text_ = other.text(); - holder_ = other.holder(); + template <typename L> + inline + line_info<L>::line_info(const line_id_t& id, data_t *data) + : id_(id), data_(data) + { } + template <typename L> inline line_info<L>::line_info(const line_info<L>& other) - : id_(0), hidden_(false) + : id_(0) { + //data_->hidden_ = false; copy_data(other); } @@ -357,22 +382,10 @@ namespace scribo line_info<L>::line_info(const line_set<L>& holder, const line_id_t& id, const mln::util::array<component_id_t>& comps) - : id_(id), hidden_(false), tag_(line::None), components_(comps), - type_(line::Undefined), holder_(holder) + : id_(id) { - + data_ = new data_t(holder, comps); force_stats_update(); - - // FIXME: set valid information for these attributes in - // force_stats_update. - word_space_ = 0; - reading_direction_ = line::LeftToRight; - reverse_video_ = false; - - orientation_ = 0.; - reading_orientation_ = 0.; - - indented_ = false; } @@ -397,7 +410,7 @@ namespace scribo line::Tag line_info<L>::tag() const { - return tag_; + return data_->tag_; } @@ -405,7 +418,7 @@ namespace scribo void line_info<L>::update_tag(line::Tag tag) { - tag_ = tag; + data_->tag_ = tag; } @@ -413,14 +426,14 @@ namespace scribo const mln::box2d& line_info<L>::bbox() const { - return bbox_; + return data_->bbox_; } template <typename L> const mln::box2d& line_info<L>::ebbox() const { - return ebbox_; + return data_->ebbox_; } @@ -428,14 +441,14 @@ namespace scribo const mln::util::array<typename line_info<L>::component_id_t>& line_info<L>::components() const { - return components_; + return data_->components_; } template <typename L> unsigned line_info<L>::card() const { - return components_.size(); + return data_->components_.size(); } @@ -443,7 +456,7 @@ namespace scribo int line_info<L>::baseline() const { - return baseline_; + return data_->baseline_; } @@ -451,7 +464,7 @@ namespace scribo int line_info<L>::meanline() const { - return meanline_; + return data_->meanline_; } @@ -459,7 +472,7 @@ namespace scribo int line_info<L>::ascent() const { - return baseline_ - a_height() + 1; + return data_->baseline_ - a_height() + 1; } @@ -467,7 +480,7 @@ namespace scribo int line_info<L>::descent() const { - return baseline_ - d_height(); + return data_->baseline_ - d_height(); } @@ -475,7 +488,7 @@ namespace scribo unsigned line_info<L>::x_height() const { - return x_height_; + return data_->x_height_; } @@ -483,7 +496,7 @@ namespace scribo int line_info<L>::d_height() const { - return d_height_; + return data_->d_height_; } @@ -491,7 +504,7 @@ namespace scribo int line_info<L>::a_height() const { - return a_height_; + return data_->a_height_; } @@ -499,7 +512,7 @@ namespace scribo unsigned line_info<L>::char_space() const { - return char_space_; + return data_->char_space_; } @@ -507,7 +520,7 @@ namespace scribo unsigned line_info<L>::char_width() const { - return char_width_; + return data_->char_width_; } @@ -515,7 +528,7 @@ namespace scribo unsigned line_info<L>::word_space() const { - return word_space_; + return data_->word_space_; } @@ -523,14 +536,14 @@ namespace scribo line::ReadingDirection line_info<L>::reading_direction() const { - return reading_direction_; + return data_->reading_direction_; } template <typename L> line::Type line_info<L>::type() const { - return type_; + return data_->type_; } @@ -538,10 +551,10 @@ namespace scribo void line_info<L>::update_components_type(component::Type type) { - for_all_elements(i, components_) + for_all_elements(i, data_->components_) { - unsigned c = components_[i]; - holder_.components_()(c).update_type(type); + unsigned c = data_->components_[i]; + data_->holder_.components_()(c).update_type(type); } } @@ -550,7 +563,7 @@ namespace scribo void line_info<L>::update_type(line::Type type) { - type_ = type; + data_->type_ = type; // Some line types may involve updating components type as well. if (type == line::Punctuation) @@ -564,7 +577,7 @@ namespace scribo bool line_info<L>::reverse_video() const { - return reverse_video_; + return data_->reverse_video_; } @@ -572,7 +585,7 @@ namespace scribo float line_info<L>::orientation() const { - return orientation_; + return data_->orientation_; } @@ -580,7 +593,7 @@ namespace scribo float line_info<L>::reading_orientation() const { - return reading_orientation_; + return data_->reading_orientation_; } @@ -588,21 +601,21 @@ namespace scribo bool line_info<L>::indented() const { - return indented_; + return data_->indented_; } template <typename L> bool line_info<L>::has_text() const { - return !text_.empty(); + return !data_->text_.empty(); } template <typename L> const std::string& line_info<L>::text() const { - return text_; + return data_->text_; } @@ -610,7 +623,7 @@ namespace scribo void line_info<L>::update_text(const std::string& str) { - text_ = str; + data_->text_ = str; } @@ -624,9 +637,19 @@ namespace scribo template <typename L> bool + line_info<L>::is_textline() const + { + return is_valid() + && !is_hidden() + && type() == line::Text; + } + + + template <typename L> + bool line_info<L>::is_hidden() const { - return hidden_; + return data_->hidden_; } @@ -634,7 +657,7 @@ namespace scribo void line_info<L>::set_hidden(bool b) { - hidden_ = b; + data_->hidden_ = b; } @@ -665,8 +688,8 @@ namespace scribo void line_info<L>::update_ebbox() { - int A = a_height_ - x_height_; - int D = - d_height_; + int A = data_->a_height_ - data_->x_height_; + int D = - data_->d_height_; if (A <= 2 && D > 2) A = D; if (D <= 2 && A > 2) @@ -674,10 +697,12 @@ namespace scribo int delta = delta_of_line(); - ebbox_ = mln::make::box2d(meanline_ - A, bbox().pmin().col() - delta, - baseline_ + D, bbox().pmax().col() + delta); + data_->ebbox_ = mln::make::box2d(data_->meanline_ - A, + bbox().pmin().col() - delta, + data_->baseline_ + D, + bbox().pmax().col() + delta); - ebbox_.crop_wrt(holder_.components().labeled_image().domain()); + data_->ebbox_.crop_wrt(data_->holder_.components().labeled_image().domain()); } @@ -729,20 +754,20 @@ namespace scribo // Adjusting ebboxes with the highest delta and merging ebboxes. int d_delta = other.delta_of_line() - this->delta_of_line(); if (d_delta < 0) // other.delta_of_line() < this->delta_of_line() - ebbox_.merge(enlarge(other.ebbox(), - d_delta)); + data_->ebbox_.merge(enlarge(other.ebbox(), - d_delta)); else { - mln::box2d b = ebbox_; - ebbox_ = other.bbox(); - ebbox_.merge(enlarge(b, d_delta)); + mln::box2d b = data_->ebbox_; + data_->ebbox_ = other.bbox(); + data_->ebbox_.merge(enlarge(b, d_delta)); } - ebbox_.crop_wrt(holder_.components().labeled_image().domain()); + data_->ebbox_.crop_wrt(data_->holder_.components().labeled_image().domain()); } else // /other/ IS NOT a text line. { - ebbox_.merge(other.ebbox()); - ebbox_.merge(merged_ebbox(*this, other)); + data_->ebbox_.merge(other.ebbox()); + data_->ebbox_.merge(merged_ebbox(*this, other)); } } else // /this/ is NOT a text line @@ -755,15 +780,15 @@ namespace scribo } update_type(line::Text); - ebbox_.merge(other.ebbox()); - ebbox_.merge(merged_ebbox(other, *this)); + data_->ebbox_.merge(other.ebbox()); + data_->ebbox_.merge(merged_ebbox(other, *this)); } // Merging bboxes. - bbox_.merge(other.bbox()); + data_->bbox_.merge(other.bbox()); // Make sure the ebbox is included in the image domain. - ebbox_.crop_wrt(holder_.components().labeled_image().domain()); + data_->ebbox_.crop_wrt(data_->holder_.components().labeled_image().domain()); } @@ -771,14 +796,14 @@ namespace scribo void line_info<L>::fast_merge(line_info<L>& other, bool hide) { - tag_ = line::Needs_Precise_Stats_Update; + data_->tag_ = line::Needs_Precise_Stats_Update; other.update_tag(line::Merged); other.set_hidden(hide); // Update bbox and ebbox update_bbox_and_ebox(other); - components_.append(other.components()); + data_->components_.append(other.components()); } @@ -795,7 +820,7 @@ namespace scribo line_info<L>::force_stats_update() { typedef mln_site(L) P; - const component_set<L>& comp_set = holder_.components(); + const component_set<L>& comp_set = data_->holder_.components(); // Init. typedef mln::value::int_u<12> median_data_t; @@ -814,21 +839,21 @@ namespace scribo // Workaround to avoid overflow with int_u<12> in median accumulators. // // FIXME: not optimal... - for_all_elements(i, components_) + for_all_elements(i, data_->components_) { - unsigned c = components_(i); + unsigned c = data_->components_(i); // Ignore punctuation for stats computation but not for bbox // computation. - if (holder_.components()(c).type() == component::Punctuation) + if (data_->holder_.components()(c).type() == component::Punctuation) continue; ref_line = mln::math::min(comp_set(c).bbox().pmin().row(), ref_line); } - for_all_elements(i, components_) + for_all_elements(i, data_->components_) { - unsigned c = components_(i); + unsigned c = data_->components_(i); const mln::box2d& bb = comp_set(c).bbox(); @@ -837,7 +862,7 @@ namespace scribo // Ignore punctuation for stats computation but not for bbox // computation. - if (holder_.components()(c).type() == component::Punctuation) + if (data_->holder_.components()(c).type() == component::Punctuation) continue; @@ -853,11 +878,11 @@ namespace scribo // (right link) (left link) // Space between characters. - if (holder_.links()(c) != c) + if (data_->holder_.links()(c) != c) { int space = bb.pmin().col() - - comp_set(holder_.links()(c)).bbox().pmax().col() - 1; + - comp_set(data_->holder_.links()(c)).bbox().pmax().col() - 1; // -- Ignore overlapped characters. if (space > 0) @@ -884,31 +909,31 @@ namespace scribo // Finalization { - tag_ = line::None; - bbox_ = bbox.to_result(); + data_->tag_ = line::None; + data_->bbox_ = bbox.to_result(); // Char space if (char_space.card() < 2) - char_space_ = 0; + data_->char_space_ = 0; else - char_space_ = char_space.to_result(); + data_->char_space_ = char_space.to_result(); // Char width if (card() == 2) - char_width_ = (comp_set(components_[0]).bbox().width() - + comp_set(components_[1]).bbox().width()) / 2; + data_->char_width_ = (comp_set(data_->components_[0]).bbox().width() + + comp_set(data_->components_[1]).bbox().width()) / 2; else - char_width_ = char_width.to_result(); + data_->char_width_ = char_width.to_result(); mln::def::coord absolute_baseline_r = baseline.to_result() + ref_line, absolute_meanline_r = meanline.to_result() + ref_line; - baseline_ = absolute_baseline_r; - meanline_ = absolute_meanline_r; - x_height_ = baseline_ - meanline_ + 1; - d_height_ = baseline_ - bbox.to_result().pmax().row(); - a_height_ = baseline_ - bbox.to_result().pmin().row() + 1; + data_->baseline_ = absolute_baseline_r; + data_->meanline_ = absolute_meanline_r; + data_->x_height_ = data_->baseline_ - data_->meanline_ + 1; + data_->d_height_ = data_->baseline_ - bbox.to_result().pmax().row(); + data_->a_height_ = data_->baseline_ - bbox.to_result().pmin().row() + 1; //FIXME // @@ -929,7 +954,7 @@ namespace scribo const line_set<L>& line_info<L>::holder() const { - return holder_; + return data_->holder_; } diff --git a/scribo/scribo/core/line_links.hh b/scribo/scribo/core/line_links.hh index 85c45e8..de62158 100644 --- a/scribo/scribo/core/line_links.hh +++ b/scribo/scribo/core/line_links.hh @@ -139,8 +139,8 @@ namespace scribo template <typename L> line_links<L>::line_links() + : data_(0) { - data_ = new data_t(); } diff --git a/scribo/scribo/core/line_set.hh b/scribo/scribo/core/line_set.hh index 29795b2..bfa9240 100644 --- a/scribo/scribo/core/line_set.hh +++ b/scribo/scribo/core/line_set.hh @@ -99,6 +99,10 @@ namespace scribo /// Constructor from object groups. line_set(const object_groups<L>& groups); + + /// Constructor useful for delayed construction (loading from file). + line_set(const object_groups<L>& groups, + const mln::util::array<line_info<L> >& line_data); /// @} /// Compute line stats and fill the underlying information. @@ -155,8 +159,14 @@ namespace scribo /// @} + /// Return false if it is not initialized (built with the default + /// constructor). bool is_valid() const; + + void update_line_data_(const mln::util::array<line_info<L> >& line_data); + + private: /// Duplicate the underlying image and create a new line_set. void init_(const line_set<L>& model); @@ -233,6 +243,15 @@ namespace scribo template <typename L> + inline + line_set<L>::line_set(const object_groups<L>& groups, + const mln::util::array<line_info<L> >& line_data) + { + data_ = new internal::line_set_data<L>(line_data, groups); + } + + + template <typename L> void line_set<L>::compute_lines(const object_groups<L>& groups) { @@ -396,7 +415,15 @@ namespace scribo bool line_set<L>::is_valid() const { - return data_->links_.is_valid() && data_->groups_.is_valid(); + return data_ && data_->groups_.is_valid(); + } + + template <typename L> + inline + void + line_set<L>::update_line_data_(const mln::util::array<line_info<L> >& line_data) + { + data_->infos_ = line_data; } template <typename L> diff --git a/scribo/scribo/core/paragraph_info.hh b/scribo/scribo/core/paragraph_info.hh index a8c623a..17f847f 100644 --- a/scribo/scribo/core/paragraph_info.hh +++ b/scribo/scribo/core/paragraph_info.hh @@ -113,6 +113,16 @@ namespace scribo } + template <typename L> + std::ostream& + operator<<(std::ostream& ostr, const paragraph_info<L>& info) + { + return ostr << "paragraph_info(" + << "line_ids=" << info.line_ids() + << ", bbox=" << info.bbox() + << ")" << std::endl; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace scribo diff --git a/scribo/scribo/core/paragraph_set.hh b/scribo/scribo/core/paragraph_set.hh index 355eaa9..6597189 100644 --- a/scribo/scribo/core/paragraph_set.hh +++ b/scribo/scribo/core/paragraph_set.hh @@ -36,6 +36,25 @@ namespace scribo { + namespace internal + { + + /// Data structure for \c scribo::paragraph_set<I>. + template <typename L> + struct paragraph_set_data + { + paragraph_set_data(); + paragraph_set_data(const line_links<L>& llines, unsigned npars); + + mln::util::array<paragraph_info<L> > pars_; + line_set<L> lines_; + line_links<L> links_; + }; + + } // end of namespace scribo::internal + + + /*! \brief Paragraph container. Paragraph ids start from 1. @@ -46,6 +65,7 @@ namespace scribo { public: paragraph_set(); + paragraph_set(internal::paragraph_set_data<L>* data); paragraph_set(const line_links<L>& llinks, unsigned npars); unsigned nelements() const; @@ -57,9 +77,10 @@ namespace scribo const line_set<L>& lines() const; + const line_links<L>& links() const; + private: - mln::util::array<paragraph_info<L> > pars_; - line_set<L> lines_; + mln::util::tracked_ptr< internal::paragraph_set_data<L> > data_; }; @@ -77,37 +98,72 @@ namespace scribo # ifndef MLN_INCLUDE_ONLY + // paragraph_set_data<L> > + + namespace internal + { + + // data< paragraph_set<L> > + + + template <typename L> + inline + paragraph_set_data<L>::paragraph_set_data() + { + } + + + template <typename L> + inline + paragraph_set_data<L>::paragraph_set_data(const line_links<L>& llinks, unsigned npars) + : pars_(npars + 1, paragraph_info<L>(llinks)), links_(llinks) + { + lines_ = llinks.lines(); + } + + } // end of namespace mln::internal + + template <typename L> paragraph_set<L>::paragraph_set() + : data_(0) { } template <typename L> + paragraph_set<L>::paragraph_set(internal::paragraph_set_data<L>* data) + { + data_ = data; + } + + template <typename L> paragraph_set<L>::paragraph_set(const line_links<L>& llinks, unsigned npars) - : pars_(npars + 1, paragraph_info<L>(llinks)) { - lines_ = llinks.lines(); + data_ = new internal::paragraph_set_data<L>(llinks, npars); } template <typename L> unsigned paragraph_set<L>::nelements() const { - return pars_.nelements() - 1; + mln_precondition(data_ != 0); + return data_->pars_.nelements() - 1; } template <typename L> paragraph_info<L>& paragraph_set<L>::operator()(unsigned i) { - return pars_[i]; + mln_precondition(data_ != 0); + return data_->pars_[i]; } template <typename L> const paragraph_info<L>& paragraph_set<L>::operator()(unsigned i) const { - return pars_[i]; + mln_precondition(data_ != 0); + return data_->pars_[i]; } @@ -115,7 +171,7 @@ namespace scribo bool paragraph_set<L>::is_valid() const { - return !pars_.is_empty(); + return data_ && !data_->pars_.is_empty(); } @@ -123,7 +179,17 @@ namespace scribo const line_set<L>& paragraph_set<L>::lines() const { - return lines_; + mln_precondition(data_ != 0); + return data_->lines_; + } + + + template <typename L> + const line_links<L>& + paragraph_set<L>::links() const + { + mln_precondition(data_ != 0); + return data_->links_; } -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-771-gcff396c Add new conversion routines from string to tag.
by Guillaume Lazzara
* scribo/core/tag/component.hh, * scribo/core/tag/line.hh: Here. --- scribo/ChangeLog | 7 +++++++ scribo/scribo/core/tag/component.hh | 35 +++++++++++++++++++++++++++++++++++ scribo/scribo/core/tag/line.hh | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 1 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index ab028c3..ab498cc 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,12 @@ 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Add new conversion routines from string to tag. + + * scribo/core/tag/component.hh, + * scribo/core/tag/line.hh: Here. + +2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Various changes in scribo core structures. * scribo/scribo/core/component_info.hh: Remove useless line_id. diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh index f773932..10b86a6 100644 --- a/scribo/scribo/core/tag/component.hh +++ b/scribo/scribo/core/tag/component.hh @@ -61,6 +61,14 @@ namespace scribo Image }; + + std::ostream& operator<<(std::ostream& ostr, const Tag& tag); + Tag str2tag(const std::string& str); + + std::ostream& operator<<(std::ostream& ostr, const Type& type); + Type str2type(const std::string& str); + + # ifndef MLN_INCLUDE_ONLY @@ -85,6 +93,16 @@ namespace scribo inline + Tag str2tag(const std::string& str) + { + if (str == "Ignored") + return Ignored; + + return None; + } + + + inline std::ostream& operator<<(std::ostream& ostr, const Type& type) { @@ -116,6 +134,23 @@ namespace scribo } + inline + Type str2type(const std::string& str) + { + if (str == "Character") + return Character; + else if (str == "Separator") + return Separator; + else if (str == "Noise") + return Noise; + else if (str == "Punctuation") + return Punctuation; + else if (str == "Image") + return Image; + + return Undefined; + } + # endif // ! MLN_INCLUDE_ONLY diff --git a/scribo/scribo/core/tag/line.hh b/scribo/scribo/core/tag/line.hh index 0444a11..3fb1fdf 100644 --- a/scribo/scribo/core/tag/line.hh +++ b/scribo/scribo/core/tag/line.hh @@ -96,7 +96,7 @@ namespace scribo std::ostream& operator<<(std::ostream& ostr, const Type& type); - + Type str2type(const std::string& str); # ifndef MLN_INCLUDE_ONLY @@ -208,6 +208,38 @@ namespace scribo return ostr << str; } + inline + Type str2type(const std::string& str) + { + if (str == "caption") + return Caption; + else if (str == "credit") + return Credit; + else if (str == "drop-capital") + return DropCapital; + else if (str == "floating") + return Floating; + else if (str == "footer") + return Footer; + else if (str == "header") + return Header; + else if (str == "heading") + return Heading; + else if (str == "page-number") + return PageNumber; + else if (str == "paragraph") + return Paragraph; + + // Values unsupported by the XSD + else if(str == "punctuation") + return Punctuation; + else if (str == "text") + return Text; + + return Undefined; + } + + # endif // ! MLN_INCLUDE_ONLY -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-772-g9ce4470 Improve and cleanup whitespace separator detection.
by Guillaume Lazzara
* scribo/core/tag/anchor.hh: Add new anchors. * scribo/filter/internal/alignment_angle.hh, * scribo/primitive/link/internal/compute_anchor.hh: Support new anchors. * scribo/primitive/extract/separators_nonvisible.hh: Remove dead code and comment debug code. * scribo/toolchain/internal/content_in_doc_functor.hh: Detect horizontal whitespace. --- scribo/ChangeLog | 16 + scribo/scribo/core/tag/anchor.hh | 5 +- scribo/scribo/filter/internal/alignment_angle.hh | 144 +++-- .../primitive/extract/separators_nonvisible.hh | 673 +++++++++----------- .../primitive/link/internal/compute_anchor.hh | 26 +- .../toolchain/internal/content_in_doc_functor.hh | 13 +- 6 files changed, 447 insertions(+), 430 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index ab498cc..d783c5c 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,21 @@ 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Improve and cleanup whitespace separator detection. + + * scribo/core/tag/anchor.hh: Add new anchors. + + * scribo/filter/internal/alignment_angle.hh, + * scribo/primitive/link/internal/compute_anchor.hh: Support new + anchors. + + * scribo/primitive/extract/separators_nonvisible.hh: Remove dead + code and comment debug code. + + * scribo/toolchain/internal/content_in_doc_functor.hh: Detect + horizontal whitespace. + +2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> + Add new conversion routines from string to tag. * scribo/core/tag/component.hh, diff --git a/scribo/scribo/core/tag/anchor.hh b/scribo/scribo/core/tag/anchor.hh index 262a32d..bb6780c 100644 --- a/scribo/scribo/core/tag/anchor.hh +++ b/scribo/scribo/core/tag/anchor.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -43,9 +44,11 @@ namespace scribo ActualRight, Right, TopLeft, + TopStrictLeft, TopRight, BottomLeft, BottomRight, + BottomStrictRight, Invalid }; diff --git a/scribo/scribo/filter/internal/alignment_angle.hh b/scribo/scribo/filter/internal/alignment_angle.hh index 5b88012..33855a8 100644 --- a/scribo/scribo/filter/internal/alignment_angle.hh +++ b/scribo/scribo/filter/internal/alignment_angle.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory // (LRDE) // // This file is part of Olena. @@ -73,76 +73,98 @@ namespace scribo unsigned current_object, unsigned nbh_object, anchor::Type anchor) { - trace::entering("scribo::filter::internal::alignment_angle_rad"); + trace::entering("scribo::filter::internal::alignment_angle"); mln_precondition(comps.is_valid()); - float dr, dc; + float dr, dc, result = 0; if (nbh_object == current_object) return 0; - // Center - if (anchor == anchor::Center) + switch(anchor) { - dr = math::abs(comps(current_object).bbox().pcenter().row() - - comps(nbh_object).bbox().pcenter().row()); - dc = math::abs(comps(current_object).bbox().pcenter().col() - - comps(nbh_object).bbox().pcenter().col()); - - return std::atan(dr / dc); - } - - // Top - else if (anchor == anchor::Top) - { - dr = math::abs(comps(current_object).bbox().pmin().row() - - comps(nbh_object).bbox().pmin().row()); - dc = math::abs(comps(current_object).bbox().pcenter().col() - - comps(nbh_object).bbox().pcenter().col()); - - return std::atan(dr / dc); + // Center + case anchor::Center: + { + dr = math::abs(comps(current_object).bbox().pcenter().row() + - comps(nbh_object).bbox().pcenter().row()); + dc = math::abs(comps(current_object).bbox().pcenter().col() + - comps(nbh_object).bbox().pcenter().col()); + + result = std::atan(dr / dc); + } + break; + + // Mass Center + case anchor::MassCenter: + { + dr = math::abs(comps(current_object).mass_center().row() + - comps(nbh_object).mass_center().row()); + dc = math::abs(comps(current_object).mass_center().col() + - comps(nbh_object).mass_center().col()); + + result = std::atan(dr / dc); + } + break; + + // Top + case anchor::TopStrictLeft: + case anchor::Top: + { + dr = math::abs(comps(current_object).bbox().pmin().row() + - comps(nbh_object).bbox().pmin().row()); + dc = math::abs(comps(current_object).bbox().pcenter().col() + - comps(nbh_object).bbox().pcenter().col()); + + result = std::atan(dr / dc); + } + break; + + // Bottom + case anchor::BottomStrictRight: + case anchor::Bottom: + { + dr = math::abs(comps(current_object).bbox().pmax().row() + - comps(nbh_object).bbox().pmax().row()); + dc = math::abs(comps(current_object).bbox().pcenter().col() + - comps(nbh_object).bbox().pcenter().col()); + + result = std::atan(dr / dc); + } + break; + + // Left + case anchor::Left: + { + dr = math::abs(comps(current_object).bbox().pcenter().row() + - comps(nbh_object).bbox().pcenter().row()); + dc = math::abs(comps(current_object).bbox().pmin().col() + - comps(nbh_object).bbox().pmin().col()); + + result = std::atan(dc / dr); + } + break; + + // Right + case anchor::Right: + { + dr = math::abs(comps(current_object).bbox().pcenter().row() + - comps(nbh_object).bbox().pcenter().row()); + dc = math::abs(comps(current_object).bbox().pmax().col() + - comps(nbh_object).bbox().pmax().col()); + + result = std::atan(dc / dr); + } + break; + + default: + trace::warning("scribo::filter::internal::alignment_angle," + " Invalid anchor value... Aborting computation."); } - // Bottom - else if (anchor == anchor::Bottom) - { - dr = math::abs(comps(current_object).bbox().pmax().row() - - comps(nbh_object).bbox().pmax().row()); - dc = math::abs(comps(current_object).bbox().pcenter().col() - - comps(nbh_object).bbox().pcenter().col()); - - return std::atan(dr / dc); - } - - // Left - else if (anchor == anchor::Left) - { - dr = math::abs(comps(current_object).bbox().pcenter().row() - - comps(nbh_object).bbox().pcenter().row()); - dc = math::abs(comps(current_object).bbox().pmin().col() - - comps(nbh_object).bbox().pmin().col()); - - return std::atan(dc / dr); - } - - // Right - else if (anchor == anchor::Right) - { - dr = math::abs(comps(current_object).bbox().pcenter().row() - - comps(nbh_object).bbox().pcenter().row()); - dc = math::abs(comps(current_object).bbox().pmax().col() - - comps(nbh_object).bbox().pmax().col()); - - return std::atan(dc / dr); - } - - else - trace::warning("Invalid anchor value... Aborting computation."); - - trace::exiting("scribo::filter::internal::alignment_angle_rad"); - return 0; - + trace::exiting("scribo::filter::internal::alignment_angle"); + return result; } # endif // ! MLN_INCLUDE_ONLY diff --git a/scribo/scribo/primitive/extract/separators_nonvisible.hh b/scribo/scribo/primitive/extract/separators_nonvisible.hh index 81ebd64..4e31650 100644 --- a/scribo/scribo/primitive/extract/separators_nonvisible.hh +++ b/scribo/scribo/primitive/extract/separators_nonvisible.hh @@ -86,6 +86,8 @@ #include <scribo/preprocessing/denoise_fg.hh> #include <scribo/preprocessing/rotate_90.hh> +#include <scribo/primitive/link/internal/compute_anchor.hh> + #include <scribo/primitive/link/internal/dmax_default.hh> #include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh> @@ -128,80 +130,6 @@ namespace scribo namespace internal { - template <typename L> - void filter_bad_groups(object_groups<L>& top_groups, - object_groups<L>& bot_groups) - { - const component_set<L>& comps = top_groups.components(); - const L& lbl = comps.labeled_image(); - - for_all_groups(c, top_groups) - { - box2d b = comps(c).bbox(); - b.enlarge(0, comps(c).bbox().height()); - b.crop_wrt(lbl.domain()); - - typedef mln_value(L) V; - - const V* top_ptr = & lbl(b.pmin()); - const V* bot_ptr = & lbl(point2d(b.pmax().row(), b.pmin().col())); - - unsigned ntop = 0, nbot = 0; - for (unsigned n = 0; n < b.width(); ++n) - { - if (*top_ptr) - ++ntop; - if (*bot_ptr) - ++nbot; - } - - if (ntop / b.width() > 0.50f) - top_groups(c) = c; - - if (nbot / b.width() > 0.50f) - bot_groups(c) = c; - } - - } - - - template <typename L> - mln_site(L) - my_anchors(const component_set<L>& comps, - unsigned current_object, - anchor::Type anchor) - { - mln_site(L) sp;// = comps(current_object).bbox().pcenter(); - - unsigned h = comps(current_object).bbox().height(); - - switch (anchor) - { - default: - return sp; - - - // Bounding box top center - case anchor::Top: // FIXME: rename as TopLeft - sp.col() = comps(current_object).bbox().pmin().col(); - sp.row() = comps(current_object).bbox().pmin().row() - + math::min(2u, (h + 1) / 2 - 1); - break; - - - // Bounding box bottom center - case anchor::Bottom: // FIXME: rename as BottomLeft - sp.col() = comps(current_object).bbox().pmax().col(); - sp.row() = comps(current_object).bbox().pmax().row() - - math::min(2u, (h + 1) / 2 - 1); - break; - } - - return sp; - } - - - using namespace primitive::link::internal; template <typename L, typename E> @@ -225,12 +153,17 @@ namespace scribo anchor::Horizontal, dmax_default(dmax)), anchor(anchor_), - debug_(data::convert(value::rgb8(), input)), - debug_angle_(data::convert(value::rgb8(), input)), _debug_(debug) { + (void) input; // FIXME : remove this argument min_alpha_rad = (min_angle / 180.0f) * math::pi; max_alpha_rad = (max_angle / 180.0f) * math::pi; + + // if (_debug_) + // { + // debug_ = data::convert(value::rgb8(), input); + // debug_angle_ = data::convert(value::rgb8(), input); + // } } void compute_next_site_(P& p) @@ -247,7 +180,8 @@ namespace scribo mln_site(L) start_point_(unsigned current_object, anchor::Type anchor) { - return my_anchors(this->components_, current_object, anchor); + return link::internal::compute_anchor(this->components_, + current_object, anchor); } @@ -303,27 +237,29 @@ namespace scribo { super_::validate_link_(current_object, start_point, p, anchor); - if (_debug_) - { - mln_site(L) - p1 = my_anchors(this->components_, current_object, anchor), - p2 = my_anchors(this->components_, this->labeled_image_(p), - anchor); - mln::draw::line(debug_, p1, p2, literal::green); - - - float - angle = filter::internal::alignment_angle(this->components_, - current_object, - this->labeled_image_(p), - anchor); - angle = (angle * 180.0f) / math::pi; - angle = angle * 20.0f + 1.0f; - mln::draw::line(debug_angle_, p1, p2, - value::rgb8(unsigned(angle), - unsigned(angle), - unsigned(angle))); - } + // if (_debug_) + // { + // mln_site(L) + // p1 = link::internal::compute_anchor(this->components_, + // current_object, anchor), + // p2 = link::internal::compute_anchor(this->components_, + // this->labeled_image_(p), + // anchor); + // mln::draw::line(debug_, p1, p2, literal::green); + + + // float + // angle = filter::internal::alignment_angle(this->components_, + // current_object, + // this->labeled_image_(p), + // anchor); + // angle = (angle * 180.0f) / math::pi; + // angle = angle * 20.0f + 1.0f; + // mln::draw::line(debug_angle_, p1, p2, + // value::rgb8(unsigned(angle), + // unsigned(angle), + // unsigned(angle))); + // } } void invalidate_link_(unsigned current_object, @@ -333,33 +269,36 @@ namespace scribo { super_::invalidate_link_(current_object, start_point, p, anchor); - if (_debug_) - { - if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0) - { - mln_site(L) - p1 = my_anchors(this->components_, current_object, anchor), - p2 = my_anchors(this->components_, this->labeled_image_(p), - anchor); - if (this->labeled_image_.domain().has(p2) && norm::l1_distance(p1.to_vec(), p2.to_vec()) < 300) - { - mln::draw::line(debug_, p1, p2, literal::red); - } - - - float - angle = filter::internal::alignment_angle(this->components_, - current_object, - this->labeled_image_(p), - anchor); - angle = (angle * 180.0f) / math::pi; - angle = angle * 20.0f + 1.0f; - mln::draw::line(debug_angle_, p1, p2, - value::rgb8(unsigned(angle), - unsigned(angle), - unsigned(angle))); - } - } + // if (_debug_) + // { + // if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0) + // { + // mln_site(L) + // p1 = link::internal::compute_anchor(this->components_, + // current_object, anchor), + // p2 = link::internal::compute_anchor(this->components_, + // this->labeled_image_(p), + // anchor); + // if (this->labeled_image_.domain().has(p2) + // && norm::l1_distance(p1.to_vec(), p2.to_vec()) < 300) + // { + // mln::draw::line(debug_, p1, p2, literal::red); + // } + + + // float + // angle = filter::internal::alignment_angle(this->components_, + // current_object, + // this->labeled_image_(p), + // anchor); + // angle = (angle * 180.0f) / math::pi; + // angle = angle * 20.0f + 1.0f; + // mln::draw::line(debug_angle_, p1, p2, + // value::rgb8(unsigned(angle), + // unsigned(angle), + // unsigned(angle))); + // } + // } } @@ -368,8 +307,8 @@ namespace scribo anchor::Type anchor; - mln_ch_value(L, value::rgb8) debug_; - mln_ch_value(L, value::rgb8) debug_angle_; + // mln_ch_value(L, value::rgb8) debug_; + // mln_ch_value(L, value::rgb8) debug_angle_; bool _debug_; }; @@ -392,7 +331,8 @@ namespace scribo float max_angle, anchor::Type anchor, bool debug) - : super_(input, components, dmax, min_angle, max_angle, anchor, debug) + : super_(input, components, dmax, min_angle, + max_angle, anchor, debug) { } @@ -427,7 +367,8 @@ namespace scribo float max_angle, anchor::Type anchor, bool debug) - : super_(input, components, dmax, min_angle, max_angle, anchor, debug) + : super_(input, components, dmax, min_angle, + max_angle, anchor, debug) { } @@ -455,6 +396,8 @@ namespace scribo mln_concrete(I) separators_nonvisible(const Image<I>& in_) { + trace::entering("scribo::primitive::extract::separators_nonvisible"); + const I& in = exact(in_); mln_precondition(in.is_valid()); typedef mln_value(I) Vi; @@ -469,42 +412,35 @@ namespace scribo util::timer t; util::timer gt; - // Load (OK) - t.start(); - float t_ = t; - std::cout << "Image loaded - " << t_ << std::endl; - gt.start(); - // Remove horizontal lines. - t.restart(); + // // Remove horizontal lines. + // t.restart(); - mln_concrete(I) hlines = primitive::extract::lines_h_pattern(in, 50, 3); - mln_concrete(I) input = primitive::remove::separators(in, hlines); + // mln_concrete(I) hlines = primitive::extract::lines_h_pattern(in, 50, 3); + // mln_concrete(I) input = primitive::remove::separators(in, hlines); - t_ = t; - std::cout << "Horizontal lines removed - " << t_ << std::endl; + // t_ = t; + // std::cout << "Horizontal lines removed - " << t_ << std::endl; // Closing structural - Connect characters. - t.restart(); + t.start(); win::hline2d vl(17); - mln_concrete(I) input_clo = morpho::closing::structural(input, vl); + mln_concrete(I) input_clo = morpho::closing::structural(in, vl); -// input_clo = scribo::preprocessing::rotate_90(input_clo, true); - - t_ = t; + float t_ = t; std::cout << "closing_structural - " << t_ << std::endl; - if (_debug_) - { - // Restore input orientation. - input = scribo::preprocessing::rotate_90(input, false); + // if (_debug_) + // { + // // Restore input orientation. + // input = scribo::preprocessing::rotate_90(input, false); - io::pbm::save(input_clo, "input_clo.pbm"); - } + // io::pbm::save(input_clo, "input_clo.pbm"); + // } // Rotate (OK) t.restart(); @@ -526,9 +462,9 @@ namespace scribo t_ = t; std::cout << "extract::components - " << t_ << std::endl; - if (_debug_) - io::pgm::save(data::convert(value::int_u8(), components.labeled_image()), - "lbl.pgm"); + // if (_debug_) + // io::pgm::save(data::convert(value::int_u8(), components.labeled_image()), + // "lbl.pgm"); unsigned dmax = 5; @@ -543,39 +479,42 @@ namespace scribo { // Right internal::single_right_dmax_ratio_aligned_functor<L> - functor(input_clo, components, dmax, min_angle, max_angle, anchor::Top, _debug_); -// top_right = primitive::link::impl::compute_fastest(functor, anchor::Top); - top_right = primitive::link::compute(functor, anchor::Top); + functor(input_clo, components, dmax, min_angle, max_angle, + anchor::TopStrictLeft, _debug_); +// top_right = primitive::link::impl::compute_fastest(functor, anchor::TopStrictLeft); + top_right = primitive::link::compute(functor, anchor::TopStrictLeft); t.stop(); - if (_debug_) - { - io::ppm::save(functor.debug_, "right_top.ppm"); - io::ppm::save(functor.debug_angle_, "right_top_angle.ppm"); - } + // if (_debug_) + // { + // io::ppm::save(functor.debug_, "right_top.ppm"); + // io::ppm::save(functor.debug_angle_, "right_top_angle.ppm"); + // } t.resume(); // Left internal::single_left_dmax_ratio_aligned_functor<L> - lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Top, _debug_); - top_left = primitive::link::compute(lfunctor, anchor::Top); + lfunctor(input_clo, components, dmax, min_angle, max_angle, + anchor::TopStrictLeft, _debug_); + top_left = primitive::link::compute(lfunctor, anchor::TopStrictLeft); t.stop(); - if (_debug_) - { - io::ppm::save(lfunctor.debug_, "left_top.ppm"); - io::ppm::save(lfunctor.debug_angle_, "left_top_angle.ppm"); + // if (_debug_) + // { + // io::ppm::save(lfunctor.debug_, "left_top.ppm"); + // io::ppm::save(lfunctor.debug_angle_, "left_top_angle.ppm"); - mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_); - data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output); + // mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_); + // data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) + // | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output); - io::ppm::save(output, "left_right_top.ppm"); - } + // io::ppm::save(output, "left_right_top.ppm"); + // } t.resume(); } @@ -585,105 +524,53 @@ namespace scribo { // Right internal::single_right_dmax_ratio_aligned_functor<L> - functor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom, _debug_); - bot_right = primitive::link::compute(functor, anchor::Bottom); + functor(input_clo, components, dmax, min_angle, max_angle, + anchor::BottomStrictRight, _debug_); + bot_right = primitive::link::compute(functor, anchor::BottomStrictRight); t.stop(); - if (_debug_) - { - io::ppm::save(functor.debug_, "right_bot.ppm"); - io::ppm::save(functor.debug_angle_, "right_bot_angle.ppm"); - } + // if (_debug_) + // { + // io::ppm::save(functor.debug_, "right_bot.ppm"); + // io::ppm::save(functor.debug_angle_, "right_bot_angle.ppm"); + // } t.resume(); // Left internal::single_left_dmax_ratio_aligned_functor<L> - lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom, _debug_); - bot_left = primitive::link::compute(lfunctor, anchor::Bottom); + lfunctor(input_clo, components, dmax, min_angle, max_angle, + anchor::BottomStrictRight, _debug_); + bot_left = primitive::link::compute(lfunctor, anchor::BottomStrictRight); t.stop(); - if (_debug_) - { - io::ppm::save(lfunctor.debug_, "left_bot.ppm"); - io::ppm::save(lfunctor.debug_angle_, "left_bot_angle.ppm"); - } + // if (_debug_) + // { + // io::ppm::save(lfunctor.debug_, "left_bot.ppm"); + // io::ppm::save(lfunctor.debug_angle_, "left_bot_angle.ppm"); - if (_debug_) - { - mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_); - data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output); + // mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_); + // data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) + // | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output); - io::ppm::save(output, "left_right_bot.ppm"); - } + // io::ppm::save(output, "left_right_bot.ppm"); + // } } t_ = t; std::cout << "links - " << t_ << std::endl; - + // Merge links and build CC groups t.restart(); - std::cout << "group - top" << std::endl; object_groups<L> top_groups = primitive::group::from_double_link_any(top_left, top_right); - std::cout << "group - bot" << std::endl; object_groups<L> bot_groups = primitive::group::from_double_link_any(bot_left, bot_right); t_ = t; std::cout << "group - " << t_ << std::endl; - t.restart(); - util::array<accu::shape::bbox<point2d> > - btop_accu(top_groups.nelements()), - bbot_accu(bot_groups.nelements()); - - - for_all_groups(c, top_groups) - { - btop_accu(top_groups(c)).take(components(c).bbox()); - bbot_accu(bot_groups(c)).take(components(c).bbox()); - } - t_ = t; - std::cout << "groups to group bboxes - " << t_ << std::endl; - - - - if (_debug_) - { - - mln_ch_value(I, value::rgb8) - wo_filtering = data::convert(value::rgb8(), input); - - for_all_comp_data(d, btop_accu) - { - if (btop_accu(d).is_valid()) - { - mln::draw::line(wo_filtering, - btop_accu(d).to_result().pmin(), - point2d(btop_accu(d).to_result().pmin().row(), - btop_accu(d).to_result().pmax().col()), - literal::green); - - } - } - - for_all_comp_data(d, bbot_accu) - { - if (bbot_accu(d).is_valid()) - { - mln::draw::line(wo_filtering, - point2d(bbot_accu(d).to_result().pmax().row(), - bbot_accu(d).to_result().pmin().col()), - bbot_accu(d).to_result().pmax(), - literal::green); - } - - } - io::ppm::save(wo_filtering, "wo_filtering.ppm"); - } - - + // Filter CC groups t.restart(); top_groups = filter::object_groups_small(top_groups, min_card); bot_groups = filter::object_groups_small(bot_groups, min_card); @@ -691,7 +578,7 @@ namespace scribo std::cout << "small groups - " << t_ << std::endl; - + // Compute group bboxes t.restart(); util::array<accu::shape::bbox<point2d> > top_accu(top_groups.nelements()), @@ -708,78 +595,35 @@ namespace scribo - - - - - t.restart(); mln_concrete(I) separators; initialize(separators, input_clo); + + // FIXME: any way to fill border AND data at the same time? data::fill(separators, false); + extension::fill(separators, false); + t_ = t; std::cout << "Initialize separators image - " << t_ << std::endl; - mln_ch_value(I, value::rgb8) both; - - if (_debug_) - both = data::convert(value::rgb8(), input); - - - t.restart(); for_all_comp_data(d, top_accu) { - if (top_accu(d).is_valid() || btop_accu(d).is_valid()) + if (top_accu(d).is_valid()) { - if (top_accu(d).is_valid()) - { - if (_debug_) - mln::draw::line(both, - top_accu(d).to_result().pmin(), - point2d(top_accu(d).to_result().pmin().row(), - top_accu(d).to_result().pmax().col()), - literal::green); - - mln::draw::line(separators, - top_accu(d).to_result().pmin(), - point2d(top_accu(d).to_result().pmin().row(), - top_accu(d).to_result().pmax().col()), - true); - } - else - if (_debug_ && btop_accu(d).is_valid()) - mln::draw::line(both, - btop_accu(d).to_result().pmin(), - point2d(btop_accu(d).to_result().pmin().row(), - btop_accu(d).to_result().pmax().col()), - literal::yellow); - + mln::draw::line(separators, + top_accu(d).to_result().pmin(), + point2d(top_accu(d).to_result().pmin().row(), + top_accu(d).to_result().pmax().col()), + true); } - if (bot_accu(d).is_valid() || bbot_accu(d).is_valid()) + if (bot_accu(d).is_valid()) { - if (bot_accu(d).is_valid()) - { - if (_debug_) - mln::draw::line(both, - point2d(bot_accu(d).to_result().pmax().row(), - bot_accu(d).to_result().pmin().col()), - bot_accu(d).to_result().pmax(), - literal::green); - - mln::draw::line(separators, - point2d(bot_accu(d).to_result().pmax().row(), - bot_accu(d).to_result().pmin().col()), - bot_accu(d).to_result().pmax(), - true); - } - else - if (_debug_ && bbot_accu(d).is_valid()) - mln::draw::line(both, - point2d(bbot_accu(d).to_result().pmax().row(), - bbot_accu(d).to_result().pmin().col()), - bbot_accu(d).to_result().pmax(), - literal::yellow); + mln::draw::line(separators, + point2d(bot_accu(d).to_result().pmax().row(), + bot_accu(d).to_result().pmin().col()), + bot_accu(d).to_result().pmax(), + true); } } @@ -787,22 +631,112 @@ namespace scribo std::cout << "Drawing output image - " << t_ << std::endl; - if (_debug_) - { - io::ppm::save(both, "both.ppm"); - io::pbm::save(separators, "separators.pbm"); - } + // if (_debug_) + // { + // // Restore input orientation. + // mln_concrete(I) input = scribo::preprocessing::rotate_90(in, false); + + + // // Debug group bboxes (includes all bboxes before filtering) + // util::array<accu::shape::bbox<point2d> > + // btop_accu(top_groups.nelements()), + // bbot_accu(bot_groups.nelements()); + + + // for_all_groups(c, top_groups) + // { + // btop_accu(top_groups(c)).take(components(c).bbox()); + // bbot_accu(bot_groups(c)).take(components(c).bbox()); + // } + + // mln_ch_value(I, value::rgb8) + // wo_filtering = data::convert(value::rgb8(), input); + + // for_all_comp_data(d, btop_accu) + // { + // if (btop_accu(d).is_valid()) + // { + // mln::draw::line(wo_filtering, + // btop_accu(d).to_result().pmin(), + // point2d(btop_accu(d).to_result().pmin().row(), + // btop_accu(d).to_result().pmax().col()), + // literal::green); + + // } + // } + + // for_all_comp_data(d, bbot_accu) + // { + // if (bbot_accu(d).is_valid()) + // { + // mln::draw::line(wo_filtering, + // point2d(bbot_accu(d).to_result().pmax().row(), + // bbot_accu(d).to_result().pmin().col()), + // bbot_accu(d).to_result().pmax(), + // literal::green); + // } + + // } + // io::ppm::save(wo_filtering, "wo_filtering.ppm"); + + // mln_ch_value(I, value::rgb8) both = data::convert(value::rgb8(), input); + + // for_all_comp_data(d, top_accu) + // { + // if (top_accu(d).is_valid() || btop_accu(d).is_valid()) + // { + // if (top_accu(d).is_valid()) + // { + // mln::draw::line(both, + // top_accu(d).to_result().pmin(), + // point2d(top_accu(d).to_result().pmin().row(), + // top_accu(d).to_result().pmax().col()), + // literal::green); + // } + // else + // if (btop_accu(d).is_valid()) + // mln::draw::line(both, + // btop_accu(d).to_result().pmin(), + // point2d(btop_accu(d).to_result().pmin().row(), + // btop_accu(d).to_result().pmax().col()), + // literal::yellow); + + // } + // if (bot_accu(d).is_valid() || bbot_accu(d).is_valid()) + // { + // if (bot_accu(d).is_valid()) + // { + // mln::draw::line(both, + // point2d(bot_accu(d).to_result().pmax().row(), + // bot_accu(d).to_result().pmin().col()), + // bot_accu(d).to_result().pmax(), + // literal::green); + // } + // else + // if (bbot_accu(d).is_valid()) + // mln::draw::line(both, + // point2d(bbot_accu(d).to_result().pmax().row(), + // bbot_accu(d).to_result().pmin().col()), + // bbot_accu(d).to_result().pmax(), + // literal::yellow); + // } + + // } + + // io::ppm::save(both, "both.ppm"); + // io::pbm::save(separators, "separators.pbm"); + // } // Hit or miss { - if (_debug_) - { - mln_concrete(I) input_with_seps = duplicate(input_clo); - data::paste(separators | pw::value(separators), input_with_seps); + // if (_debug_) + // { + // mln_concrete(I) input_with_seps = duplicate(input_clo); + // data::paste(separators | pw::value(separators), input_with_seps); - io::pbm::save(input_with_seps, "input_with_seps.pbm"); - } + // io::pbm::save(input_with_seps, "input_with_seps.pbm"); + // } t.restart(); unsigned length = 25; @@ -819,11 +753,12 @@ namespace scribo typedef mln_ch_value(I,unsigned) J; J tmp = accu::transform_line(accu, input_clo, length, 1); + t_ = t; std::cout << "* accu::transform_line - " << t_ << std::endl; - if (_debug_) - io::pgm::save(data::convert(value::int_u8(), tmp), "tmp.pgm"); + // if (_debug_) + // io::pgm::save(data::convert(value::int_u8(), tmp), "tmp.pgm"); t.restart(); @@ -841,25 +776,53 @@ namespace scribo unsigned invalid_ratio = unsigned(length * 0.30f); - mln_piter(I) p(separators.domain()); - for_all(p) - if (separators(p)) - { - unsigned lbl = sep_lbl(p); + extension::adjust_fill(tmp, 21, 0); + + value::int_u8 *sep_lbl_ptr = sep_lbl.buffer() + sep_lbl.index_of_point(sep_lbl.domain().pmin()); + bool *separators_ptr = separators.buffer() + separators.index_of_point(separators.domain().pmin()); + unsigned *tmp_ptr = tmp.buffer() + tmp.index_of_point(tmp.domain().pmin());; + int idx1 = tmp.delta_index(dp1); + int idx2 = tmp.delta_index(dp2); + + unsigned nrows = separators.nrows(); + unsigned ncols = separators.ncols(); - unsigned - top_count = tmp(p + dp1), - bot_count = tmp(p + dp2); + unsigned row_idx_sep_lbl = sep_lbl.delta_index(dpoint2d(+1, - ncols)); + unsigned row_idx_separators = separators.delta_index(dpoint2d(+1, - ncols)); + unsigned row_idx_tmp = tmp.delta_index(dpoint2d(+1, - ncols)); - // This site is wrapped between two lines of text so we don't - // want it. - if (top_count >= invalid_ratio + 1 - && bot_count >= invalid_ratio + 1) + for (unsigned row = 0; row < nrows; ++row) + { + for (unsigned col = 0; col < ncols; ++col) + { + if (*separators_ptr) { - relbl(lbl) = false; + unsigned lbl = *sep_lbl_ptr; + + unsigned + top_count = *(tmp_ptr + idx1), + bot_count = *(tmp_ptr + idx2); + + // This site is wrapped between two lines of text so we don't + // want it. + if (top_count >= invalid_ratio + 1 + && bot_count >= invalid_ratio + 1) + { + relbl(lbl) = false; + } } + + ++tmp_ptr; + ++sep_lbl_ptr; + ++separators_ptr; } + tmp_ptr += row_idx_tmp; + sep_lbl_ptr += row_idx_sep_lbl; + separators_ptr += row_idx_separators; + } + + t_ = t; std::cout << "* reading data - " << t_ << std::endl; @@ -870,37 +833,35 @@ namespace scribo mln_concrete(I) output = data::convert(bool(), sep_lbl); - if (_debug_) - { - io::pbm::save(output, "separators_hom.pbm"); - io::pbm::save(separators, "separators_filtered.pbm"); - } + // if (_debug_) + // { + // io::pbm::save(output, "separators_hom.pbm"); + // io::pbm::save(separators, "separators_filtered.pbm"); - t.restart(); - value::int_u16 ncomps; - component_set<L> comps = primitive::extract::components(output, c8(), ncomps); - mln_ch_value(I, value::rgb8) both; + // // value::int_u16 ncomps; + // // component_set<L> comps = primitive::extract::components(output, c8(), ncomps); + // // mln_ch_value(I, value::rgb8) both; - both = data::convert(value::rgb8(), input); + // // both = data::convert(value::rgb8(), input); - // Needed since the rotated image origin is (0,0). Rotation does - // not preserve rotated coordinates. - dpoint2d dp(input.domain().pcenter() - input_clo.domain().pcenter()); + // // // Needed since the rotated image origin is (0,0). + // // dpoint2d dp(input.domain().pcenter() - input_clo.domain().pcenter()); + + // // for_all_comps(c, comps) + // // { + // // box2d b = geom::rotate(comps(c).bbox(), -90, input_clo.domain().pcenter()); + // // mln::draw::line(both, + // // b.pmin() + dp, + // // b.pmax() + dp, + // // literal::green); + // // } + // } - for_all_comps(c, comps) - { - box2d b = geom::rotate(comps(c).bbox(), -90, input_clo.domain().pcenter()); - mln::draw::line(both, - b.pmin() + dp, - b.pmax() + dp, - literal::green); - } - t_ = t; - std::cout << "Output image - " << t_ << std::endl; gt.stop(); t_ = gt; - std::cout << "Total time: " << t_ << std::endl; + std::cout << "Non visible separators: " << t_ << std::endl; + trace::exiting("scribo::primitive::extract::separators_nonvisible"); return scribo::preprocessing::rotate_90(output, true); } } diff --git a/scribo/scribo/primitive/link/internal/compute_anchor.hh b/scribo/scribo/primitive/link/internal/compute_anchor.hh index 1c52b91..c1a9106 100644 --- a/scribo/scribo/primitive/link/internal/compute_anchor.hh +++ b/scribo/scribo/primitive/link/internal/compute_anchor.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. // @@ -88,10 +88,8 @@ namespace scribo { typedef mln_site(L) P; - unsigned h = components(current_object).bbox().pmax().row() - - components(current_object).bbox().pmin().row(); - unsigned w = components(current_object).bbox().pmax().col() - - components(current_object).bbox().pmin().col(); + unsigned h = components(current_object).bbox().height(); + unsigned w = components(current_object).bbox().width(); mln_site(L) sp = components(current_object).bbox().pcenter(); @@ -113,6 +111,22 @@ namespace scribo break; + // Bounding box top left + case anchor::TopStrictLeft: + sp.col() = components(current_object).bbox().pmin().col(); + sp.row() = components(current_object).bbox().pmin().row() + + math::min(2u, (h + 1) / 2 - 1); + break; + + + // Bounding box bottom right + case anchor::BottomStrictRight: + sp.col() = components(current_object).bbox().pmax().col(); + sp.row() = components(current_object).bbox().pmax().row() + - math::min(2u, (h + 1) / 2 - 1); + break; + + // Bounding box bottom center case anchor::Bottom: if (h < 30) diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh index ed691e8..48098ba 100644 --- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh @@ -34,11 +34,11 @@ # include <scribo/core/line_set.hh> # include <scribo/core/paragraph_set.hh> -# include <scribo/primitive/extract/elements.hh> +# include <scribo/primitive/extract/non_text.hh> # include <scribo/primitive/extract/components.hh> -# include <scribo/primitive/extract/vertical_separators.hh> +//# include <scribo/primitive/extract/vertical_separators.hh> +# include <scribo/primitive/extract/separators.hh> # include <scribo/primitive/extract/separators_nonvisible.hh> -# include <scribo/primitive/extract/elements.hh> # include <scribo/primitive/identify.hh> @@ -168,16 +168,17 @@ namespace scribo input_cleaned = exact(processed_image); if (enable_line_seps) { - on_new_progress_label("Find vertical separators..."); + on_new_progress_label("Find vertical and horizontal separators..."); - // Vertical separators - separators = primitive::extract::vertical_separators(processed_image, 81); + // Vertical and horizontal separators + separators = primitive::extract::separators(processed_image, 81); on_progress(); on_new_progress_label("Remove separators..."); input_cleaned = primitive::remove::separators(processed_image, separators); + doc.set_line_separators(separators); on_progress(); } -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-758-g11325f7 demo/viewer/runner.cc: Clear arguments on new process.
by Guillaume Lazzara
--- scribo/ChangeLog | 4 ++++ scribo/demo/viewer/runner.cc | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index b19115d..be2e395 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,7 @@ +2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + + * demo/viewer/runner.cc: Clear arguments on new process. + 2011-01-28 Guillaume Lazzara <z(a)lrde.epita.fr> * tests/unit_test/unit-tests.mk: Regen. diff --git a/scribo/demo/viewer/runner.cc b/scribo/demo/viewer/runner.cc index 085ef39..86ff5dc 100644 --- a/scribo/demo/viewer/runner.cc +++ b/scribo/demo/viewer/runner.cc @@ -94,6 +94,7 @@ void runner::stop() void runner::start_demat(const QString& filename) { + args_.clear(); args_ << filename; mode_ = Demat; @@ -191,6 +192,7 @@ void runner::process(const image2d<value::rgb8>& original_ima, void runner::start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile) { + args_.clear(); args_ << imgfile << xmlfile << outfile; mode_ = Export; -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-759-g79b3aaa Improve about dialog in scribo viewer.
by Guillaume Lazzara
* demo/shared/icons/olena_smaller.jpg: New. * demo/shared/shared.qrc: Add new image in resources. * demo/viewer/Makefile.am: Build qrc file. * demo/viewer/help_dialog.cc, * demo/viewer/help_dialog.hh: Make use of the new dialog. * demo/viewer/help_dialog.ui: New. * demo/viewer/viewer.qrc: New. --- scribo/ChangeLog | 17 ++++ scribo/demo/shared/icons/olena_smaller.jpg | Bin 0 -> 8028 bytes scribo/demo/shared/shared.qrc | 3 +- scribo/demo/viewer/Makefile.am | 6 +- scribo/demo/viewer/help_dialog.cc | 43 +-------- scribo/demo/viewer/help_dialog.hh | 11 +-- scribo/demo/viewer/help_dialog.ui | 138 ++++++++++++++++++++++++++++ scribo/demo/viewer/viewer.qrc | 5 + 8 files changed, 173 insertions(+), 50 deletions(-) create mode 100644 scribo/demo/shared/icons/olena_smaller.jpg create mode 100644 scribo/demo/viewer/help_dialog.ui create mode 100644 scribo/demo/viewer/viewer.qrc diff --git a/scribo/ChangeLog b/scribo/ChangeLog index be2e395..620dcfb 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,22 @@ 2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + Improve about dialog in scribo viewer. + + * demo/shared/icons/olena_smaller.jpg: New. + + * demo/shared/shared.qrc: Add new image in resources. + + * demo/viewer/Makefile.am: Build qrc file. + + * demo/viewer/help_dialog.cc, + * demo/viewer/help_dialog.hh: Make use of the new dialog. + + * demo/viewer/help_dialog.ui: New. + + * demo/viewer/viewer.qrc: New. + +2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + * demo/viewer/runner.cc: Clear arguments on new process. 2011-01-28 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/demo/shared/icons/olena_smaller.jpg b/scribo/demo/shared/icons/olena_smaller.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c6b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xG#7<ziG$2{Ch zr#ulH+U@Nxy_fevtNZadeA`@XF-u3oMPE!<INC2MYr04JAS6%w>`ZwnfYV_lcl}+C bgz4Fa|5>K}fG8QRgI>%Sw?|pt^~`?&8`a%< literal 0 HcmV?d00001 diff --git a/scribo/demo/shared/shared.qrc b/scribo/demo/shared/shared.qrc index 051c986..3e1fd85 100644 --- a/scribo/demo/shared/shared.qrc +++ b/scribo/demo/shared/shared.qrc @@ -1,5 +1,6 @@ <RCC> - <qresource prefix="icons" > + <qresource prefix="icons"> + <file>icons/olena_smaller.jpg</file> <file>icons/close.gif</file> <file>icons/image-next-icon.png</file> <file>icons/page-down-icon.png</file> diff --git a/scribo/demo/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am index fa143c9..2c5e4cf 100644 --- a/scribo/demo/viewer/Makefile.am +++ b/scribo/demo/viewer/Makefile.am @@ -63,7 +63,7 @@ BUILT_SOURCES = viewer.moc.cc \ image_scene.moc.cc \ image_view.moc.cc \ image_region.moc.cc \ - help_dialog.moc.cc \ + help_dialog.ui.h \ step_widget.moc.cc \ toolchain_options.moc.cc \ toolchain_options.ui.h \ @@ -74,7 +74,8 @@ BUILT_SOURCES = viewer.moc.cc \ preferences_dialog.ui.h \ general_options.moc.cc \ general_options.ui.h \ - demodir.hh + demodir.hh \ + viewer.qrc.cc noinst_HEADERS = viewer.hh \ @@ -121,5 +122,6 @@ EXTRA_DIST = \ preferences_dialog.ui \ README \ toolchain_options.ui \ + help_dialog.ui \ demodir.hh.in diff --git a/scribo/demo/viewer/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc index 1f4a775..2d5ce6c 100644 --- a/scribo/demo/viewer/help_dialog.cc +++ b/scribo/demo/viewer/help_dialog.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,43 +19,5 @@ HelpDialog::HelpDialog() { - QPushButton *closeButton = new QPushButton(tr("Close")); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); - - QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(closeButton); - - QVBoxLayout *mainLayout = new QVBoxLayout; - - QString help = tr( - "Document layout viewer:\n" - "\n" - "Usage:\n" - " - Choose an image file in the file browser,\n" - "if XML file(s) whose prefix name is the same as\n" - "the image name (i.e.image _name(_ .*)?.xml) is present\n" - "then you can choose the one you want in the step\n" - "chooser to display it on the scene.\n" - "- To load a base 64 encoded XML file,\n" - "its extension has to be .xmlc otherwise \n" - "the program won't recognize it !\n" - " - Select regions to display their properties.\n" - " - Use the mouse or keyboard to move and zoom\n" - " (Arrows, PageUp, PageDown, Home, End).\n" - "\n"); - - - QLabel* label = new QLabel(help); - - mainLayout->addWidget(label); - mainLayout->addLayout(buttonsLayout); - - setLayout(mainLayout); - setWindowTitle(tr("About")); -} - -void HelpDialog::done() -{ - emit close(); + setupUi(this); } diff --git a/scribo/demo/viewer/help_dialog.hh b/scribo/demo/viewer/help_dialog.hh index 41be95d..9f179c6 100644 --- a/scribo/demo/viewer/help_dialog.hh +++ b/scribo/demo/viewer/help_dialog.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,17 +19,13 @@ # define SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH # include <QtGui> +# include <help_dialog.ui.h> -class HelpDialog - : public QDialog +class HelpDialog : public QDialog, private Ui::HelpDialog { - Q_OBJECT - public: HelpDialog(); -public slots: - void done(); }; #endif // ! SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH diff --git a/scribo/demo/viewer/help_dialog.ui b/scribo/demo/viewer/help_dialog.ui new file mode 100644 index 0000000..9ab7e58 --- /dev/null +++ b/scribo/demo/viewer/help_dialog.ui @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>HelpDialog</class> + <widget class="QDialog" name="HelpDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>557</width> + <height>390</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>557</width> + <height>390</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>557</width> + <height>390</height> + </size> + </property> + <property name="windowTitle"> + <string>About</string> + </property> + <property name="windowIcon"> + <iconset resource="viewer.qrc"> + <normaloff>:/icons/shared/icons/olena_smaller.jpg</normaloff>:/icons/shared/icons/olena_smaller.jpg</iconset> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="viewer.qrc">:/icons/shared/icons/olena_smaller.jpg</pixmap> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Document Image Analysis Tool</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This project is powered by <span style=" font-weight:600; font-style:italic;">Milena</span>, a generic image processing library.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">It is part of <span style=" font-weight:600; font-style:italic;">Olena</span>, an Image Processing Platform and its module <span style=" font-weight:600; font-style:italic;">Scribo</span>, a set of tools for Document Image Analysis.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://olena.lrde.epita.fr"><span style=" text-decoration: underline; color:#0057ae;">http://olena.lrde.epita.fr</span></a></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Thanks to Arthur Crépin-Leblond, Samuel Da Mota, Loic Denuziere, </span><span style=" font-size:8pt;">Jérôme Galtier,</span><span style=" font-size:8pt;"> </span><span style=" font-size:8pt;">Florent d'Halluin, </span><span style=" font-size:8pt;">Alex Hamelin, </span><span style=" font-size:8pt;">Damien Lefortier, </span><span style=" font-size:8pt;">Vincent Ordy, </span><span style=" font-size:8pt;">Guillaume Sadegh and</span><span style=" font-size:8pt;"> </span><span style=" font-size:8pt;">Warren Seine </span><span style=" font-size:8pt;">for their contribution.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p align="justify" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt;">This application has been developed in the context of the SCRIBO project of the Free Software Thematic Group, part of the &quot;System@tic Paris-Région&quot; Cluster (France). This project is partially funded by the French Government, its economic development agencies, and by the Paris-Région institutions.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:7pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt;">Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE)</span></p></body></html></string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Ok</set> + </property> + <property name="centerButtons"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="viewer.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>HelpDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>281</x> + <y>391</y> + </hint> + <hint type="destinationlabel"> + <x>240</x> + <y>203</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/scribo/demo/viewer/viewer.qrc b/scribo/demo/viewer/viewer.qrc new file mode 100644 index 0000000..361b332 --- /dev/null +++ b/scribo/demo/viewer/viewer.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="icons"> + <file>../shared/icons/olena_smaller.jpg</file> + </qresource> +</RCC> -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-760-gc96edd6 Add printing support in Scribo viewer.
by Guillaume Lazzara
* demo/viewer/image_scene.cc, * demo/viewer/image_scene.hh: Accept a parent widget. * demo/viewer/image_widget.cc, * demo/viewer/image_widget.hh: Add an accessor to the underlying view. * demo/viewer/viewer.cc, * demo/viewer/viewer.hh: Add print and print preview menu entries --- scribo/ChangeLog | 14 +++++ scribo/demo/viewer/image_scene.cc | 7 ++- scribo/demo/viewer/image_scene.hh | 2 +- scribo/demo/viewer/image_widget.cc | 15 +++++- scribo/demo/viewer/image_widget.hh | 6 ++- scribo/demo/viewer/viewer.cc | 95 ++++++++++++++++++++++++++++++++++-- scribo/demo/viewer/viewer.hh | 9 +++- 7 files changed, 135 insertions(+), 13 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 620dcfb..52006a7 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,17 @@ +2011-02-04 Guillaume Lazzara <z(a)lrde.epita.fr> + + Add printing support in Scribo viewer. + + * demo/viewer/image_scene.cc, + * demo/viewer/image_scene.hh: Accept a parent widget. + + * demo/viewer/image_widget.cc, + * demo/viewer/image_widget.hh: Add an accessor to the underlying + view. + + * demo/viewer/viewer.cc, + * demo/viewer/viewer.hh: Add print and print preview menu entries. + 2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> Improve about dialog in scribo viewer. diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc index 2c56113..a800896 100644 --- a/scribo/demo/viewer/image_scene.cc +++ b/scribo/demo/viewer/image_scene.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,8 +19,8 @@ #include "image_scene.hh" #include "image_region.hh" -ImageScene::ImageScene() - : selected_(0) +ImageScene::ImageScene(QObject *parent) + : QGraphicsScene(parent), selected_(0) { } diff --git a/scribo/demo/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh index 136f1a2..b141478 100644 --- a/scribo/demo/viewer/image_scene.hh +++ b/scribo/demo/viewer/image_scene.hh @@ -27,7 +27,7 @@ class ImageScene Q_OBJECT public: - ImageScene(); + ImageScene(QObject *parent = 0); ~ImageScene(); void mousePressEvent(QGraphicsSceneMouseEvent* event); diff --git a/scribo/demo/viewer/image_widget.cc b/scribo/demo/viewer/image_widget.cc index e9e5e79..f86ff1d 100644 --- a/scribo/demo/viewer/image_widget.cc +++ b/scribo/demo/viewer/image_widget.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -20,6 +21,8 @@ ImageWidget::ImageWidget(QGraphicsScene* scene) : view_ (new ImageView(scene)) { + scene->setParent(view_); + QLabel* title = new QLabel(tr("Layout")); title->setAlignment(Qt::AlignHCenter); @@ -38,6 +41,12 @@ ImageWidget::ImageWidget(QGraphicsScene* scene) setLayout(layout); } + +ImageWidget::~ImageWidget() +{ +} + + void ImageWidget::update() { @@ -45,6 +54,8 @@ ImageWidget::update() view_->scaleUpdate(); } -ImageWidget::~ImageWidget() +ImageView * +ImageWidget::view() const { + return view_; } diff --git a/scribo/demo/viewer/image_widget.hh b/scribo/demo/viewer/image_widget.hh index 826b873..79dd672 100644 --- a/scribo/demo/viewer/image_widget.hh +++ b/scribo/demo/viewer/image_widget.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,6 +19,7 @@ # define SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH # include <QtGui> +# include "image_view.hh" class ImageView; @@ -30,6 +32,8 @@ public: ImageWidget(QGraphicsScene* scene); ~ImageWidget(); + ImageView * view() const; + public slots: void update(); diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc index 46172ce..57a67c2 100644 --- a/scribo/demo/viewer/viewer.cc +++ b/scribo/demo/viewer/viewer.cc @@ -22,10 +22,10 @@ #include "viewer.hh" #include "key_widget.hh" #include "browser_widget.hh" -#include "image_widget.hh" #include "xml_widget.hh" #include "step_widget.hh" #include "image_scene.hh" +#include "image_view.hh" #include "image_region.hh" #include "help_dialog.hh" #include "preferences_dialog.hh" @@ -107,6 +107,23 @@ Viewer::Viewer(int &argc, char** argv) file_menu->addSeparator(); + QAction *preview_print_action = create_action("Printing preview", file_menu, + "Printint preview", "Ctrl+P"); + connect(preview_print_action, SIGNAL(triggered()), + this, SLOT(preview_print())); + file_menu->addAction(preview_print_action); + preview_print_action->setEnabled(false); + + + QAction *print_action = create_action("Print", file_menu, + "Print", "Ctrl+P"); + connect(print_action, SIGNAL(triggered()), + this, SLOT(print())); + file_menu->addAction(print_action); + print_action->setEnabled(false); + + file_menu->addSeparator(); + QAction* quit_action = create_action("Quit", file_menu, "Exit the program.", "Ctrl+q"); @@ -220,10 +237,14 @@ Viewer::Viewer(int &argc, char** argv) step_widget_ = new StepWidget(); XmlWidget* xml_wgt = new XmlWidget(); browser_wgt_ = new BrowserWidget(files_, argc != 2 ? QString() : argv[1]); - ImageWidget* image_wgt = new ImageWidget(scene_); + image_wgt_ = new ImageWidget(scene_); connect(step_widget_, SIGNAL(step_selected(bool)), export_action_, SLOT(setEnabled(bool))); + connect(step_widget_, SIGNAL(step_selected(bool)), + print_action, SLOT(setEnabled(bool))); + connect(step_widget_, SIGNAL(step_selected(bool)), + preview_print_action, SLOT(setEnabled(bool))); scene_->setBackgroundBrush(scene_->palette().window()); @@ -231,7 +252,7 @@ Viewer::Viewer(int &argc, char** argv) v_splitter->addWidget(key_wgt_); v_splitter->addWidget(browser_wgt_); - v_splitter2->addWidget(image_wgt); + v_splitter2->addWidget(image_wgt_); v_splitter2->addWidget(xml_wgt); h_splitter->addWidget(v_splitter); @@ -264,7 +285,7 @@ Viewer::Viewer(int &argc, char** argv) connect(this, SIGNAL(mode_changed(bool)), key_wgt_, SLOT(change_mode(bool))); connect(this, SIGNAL(updated()), - image_wgt, SLOT(update())); + image_wgt_, SLOT(update())); connect(this, SIGNAL(fill_xml(QString)), xml_wgt, SLOT(fill_widget(QString))); @@ -276,7 +297,7 @@ Viewer::Viewer(int &argc, char** argv) connect(scene_, SIGNAL(deselected()), xml_wgt, SLOT(deselect())); - connect(image_wgt, SIGNAL(scaleUpdated(qreal)), + connect(image_wgt_, SIGNAL(scaleUpdated(qreal)), this, SLOT(maybeChangeCacheMode(qreal))); @@ -808,3 +829,67 @@ Viewer::reset_progress_dialog() pdialog_.setLabelText(""); pdialog_.show(); } + + +void +Viewer::print() +{ + QPrinter printer(QPrinter::HighResolution); + configure_printer(printer); + + QPrintDialog dialog(&printer); + dialog.setWindowTitle(tr("Print Document")); + if (dialog.exec() != QDialog::Accepted) + return; + + do_print(&printer); +} + +void +Viewer::preview_print() +{ + QPrinter printer(QPrinter::HighResolution); + configure_printer(printer); + + QPrintPreviewDialog preview(&printer); + connect(&preview, SIGNAL(paintRequested(QPrinter *)), + this, SLOT(do_print(QPrinter *))); + + preview.exec(); +} + +void Viewer::do_print(QPrinter * printer) +{ + QList<QGraphicsItem *> items = image_wgt_->view()->items(); + + QPainter painter(printer); + + QGraphicsItem *item; + QStyleOptionGraphicsItem options; + + // Painting backward objects first. + for (int i = items.size() - 1; i >= 0; --i) + { + item = items.at(i); + + if (item != image_) + { + QRect vport = image_->mapRectFromItem(item, + item->boundingRect()).toRect(); + + painter.translate(std::abs(item->boundingRect().x() - vport.x()), + std::abs(item->boundingRect().y() - vport.y())); + } + + + item->paint(&painter, &options); + painter.resetTransform(); + } +} + +void +Viewer::configure_printer(QPrinter& printer) +{ + printer.setPageSize(QPrinter::A4); + printer.setResolution(300); +} diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh index 3aefaf6..c4b99e8 100644 --- a/scribo/demo/viewer/viewer.hh +++ b/scribo/demo/viewer/viewer.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -21,6 +22,7 @@ # include <QDomNode> # include "common.hh" # include "runner.hh" +# include "image_widget.hh" class ImageScene; class DomModel; @@ -61,6 +63,9 @@ private slots: void run_progress(); void on_xml_saved(const QString& filename); void export_as(); + void print(); + void preview_print(); + void do_print(QPrinter * printer); signals: void updated(); @@ -81,6 +86,7 @@ private: void add_text(QDomNode line); QAction *create_action(QString name, QMenu* menu, QString status, QString shortcut); void reset_progress_dialog(); + void configure_printer(QPrinter& printer); QApplication* app_; QMainWindow* win_; @@ -90,6 +96,7 @@ private: QGraphicsPixmapItem* image_; ImageScene* scene_; + ImageWidget* image_wgt_; QDirModel* files_; DomModel* doc_layout_; -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-761-gd5019dd Display baseline and meanline in Scribo viewer.
by Guillaume Lazzara
* demo/viewer/common.hh: Add new enums. * demo/viewer/key_widget.cc, * demo/viewer/key_widget.hh: Revamp code and add support for more region types. * demo/viewer/viewer.cc, * demo/viewer/viewer.hh: Insert line blocks. --- scribo/ChangeLog | 13 ++++ scribo/demo/viewer/common.hh | 11 ++++ scribo/demo/viewer/key_widget.cc | 123 ++++++++++++++++++------------------- scribo/demo/viewer/key_widget.hh | 4 +- scribo/demo/viewer/viewer.cc | 106 +++++++++++++++++++++++++++++++- scribo/demo/viewer/viewer.hh | 1 + 6 files changed, 190 insertions(+), 68 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 52006a7..03705c9 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,16 @@ +2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> + + Display baseline and meanline in Scribo viewer. + + * demo/viewer/common.hh: Add new enums. + + * demo/viewer/key_widget.cc, + * demo/viewer/key_widget.hh: Revamp code and add support for more + region types. + + * demo/viewer/viewer.cc, + * demo/viewer/viewer.hh: Insert line blocks. + 2011-02-04 Guillaume Lazzara <z(a)lrde.epita.fr> Add printing support in Scribo viewer. diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh index b2d8f7e..46f20c1 100644 --- a/scribo/demo/viewer/common.hh +++ b/scribo/demo/viewer/common.hh @@ -26,6 +26,9 @@ namespace region { Text = 0, Line, + + EndOfTextRegion, + Image, Noise, Separator, @@ -34,6 +37,14 @@ namespace region Graphic, Chart, Maths, + + EndOfMiscRegion, + + Baseline, + Meanline, + + EndOfTypoRegion, + RegionIdCount }; } diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc index 3a4b47b..cc10308 100644 --- a/scribo/demo/viewer/key_widget.cc +++ b/scribo/demo/viewer/key_widget.cc @@ -19,29 +19,31 @@ #include "common.hh" KeyWidget::KeyWidget(const region::KeyMap& key_map) - : items_(new QTreeWidget()), - text_(new QTreeWidgetItem(QStringList("Text"))), - regions_(new QTreeWidgetItem(QStringList("Regions"))) + : items_(new QTreeWidget()) { + item_list_.append(new QTreeWidgetItem(QStringList("Text"))); + item_list_.append(new QTreeWidgetItem(QStringList("Regions"))); + item_list_.append(new QTreeWidgetItem(QStringList("Typographical Lines"))); + QLabel* title = new QLabel(tr("Key")); title->setAlignment(Qt::AlignHCenter); - items_->addTopLevelItem(text_); - items_->addTopLevelItem(regions_); + foreach(QTreeWidgetItem* item, item_list_) + { + items_->addTopLevelItem(item); + item->setCheckState(0, Qt::Checked); + item->setExpanded(true); + } items_->setHeaderHidden(true); - text_->setCheckState(0, Qt::Checked); - text_->setExpanded(true); - - regions_->setCheckState(0, Qt::Checked); - regions_->setExpanded(true); + base_id_.append(0); + base_id_.append(region::EndOfTextRegion + 1); + base_id_.append(region::EndOfMiscRegion + 1); + base_id_.append(region::EndOfTypoRegion + 1); - for (int i = 0; i < 2; ++i) - add_item_(key_map.at(i).first, key_map.at(i).second, - i == region::Line, text_); - - for (int i = 2; i < key_map.size(); ++i) - add_item_(key_map.at(i).first, key_map.at(i).second, false, regions_); + for (int j = 0; j < base_id_.size() - 1; ++j) + for (int i = base_id_.at(j); i < base_id_.at(j + 1) - 1; ++i) + add_item_(key_map.at(i).first, key_map.at(i).second, false, item_list_.at(j)); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(title); @@ -55,11 +57,9 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map) void KeyWidget::update_all() { - for (int i = 0; i < text_->childCount(); ++i) - update(text_->child(i)); - - for (int i = 0; i < regions_->childCount(); ++i) - update(regions_->child(i)); + foreach(QTreeWidgetItem* item, item_list_) + for (int i = 0; i < item->childCount(); ++i) + update(item->child(i)); } void KeyWidget::setAll(bool b) @@ -70,8 +70,8 @@ void KeyWidget::setAll(bool b) else state = Qt::Unchecked; - text_->setCheckState(0, state); - regions_->setCheckState(0, state); + foreach(QTreeWidgetItem* item, item_list_) + item->setCheckState(0, state); } void KeyWidget::setAllCheck(QTreeWidgetItem* parent) @@ -89,20 +89,8 @@ void KeyWidget::setAllCheck(QTreeWidgetItem* parent) void KeyWidget::change_mode(bool b) { - int id_line = region::Line; - - if (b) - { - //text_->child(id_region)->setCheckState(0, Qt::Checked); - // text_->child(id_line)->setCheckState(0, Qt::Checked); - text_->child(id_line)->setHidden(false); - } - else - { - //text_->child(id_region)->setCheckState(0, Qt::Unchecked); - // text_->child(id_line)->setCheckState(0, Qt::Unchecked); - text_->child(id_line)->setHidden(true); - } + item_list_.at(0)->child(region::Line)->setHidden(!b); + // FIXME: we may like to hide also typographical objects. } void @@ -118,43 +106,52 @@ KeyWidget::add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent item->setHidden(b); } - bool +bool KeyWidget::isChecked(region::RegionId id) { - QTreeWidgetItem* item = text_->child(id); - if (item) - return item->checkState(0) == Qt::Checked; - else - { - item = regions_->child(id); - if(item) - return item->checkState(0) == Qt::Checked; - else - return false; - } + QTreeWidgetItem* current_item = 0; + + foreach(QTreeWidgetItem* item, item_list_) + { + current_item = item->child(id); + if (item) + break; + else + current_item = 0; + } + + if (!current_item) + return false; + + return current_item->checkState(0) == Qt::Checked; } void -KeyWidget::update(QTreeWidgetItem* item) +KeyWidget::update(QTreeWidgetItem* item_up) { int id = -1; - if (item == text_ || item == regions_) - { - setAllCheck(item); - } - else + + foreach(QTreeWidgetItem* item, item_list_) + if (item_up == item) + { + setAllCheck(item); + return; + } + + + int i = 0; + foreach(QTreeWidgetItem* item, item_list_) { - id = text_->indexOfChild(item); - if (id == -1) + id = item->indexOfChild(item_up); + if (id != -1) { - // +2 since image region id starts from 0 to the number of - // region type without considering categories. There are 2 - // elements in text category and the rest is in the region's - // one. - id = regions_->indexOfChild(item) + 2; + id += base_id_.at(i); + break; } - emit updated(id, item->checkState(0) == Qt::Checked); + ++i; } + + emit updated(id, item_up->checkState(0) == Qt::Checked); } KeyWidget::~KeyWidget() diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh index fd0b514..1a3518e 100644 --- a/scribo/demo/viewer/key_widget.hh +++ b/scribo/demo/viewer/key_widget.hh @@ -48,8 +48,8 @@ private: void add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent); QTreeWidget* items_; - QTreeWidgetItem* text_; - QTreeWidgetItem* regions_; + QVector<QTreeWidgetItem*> item_list_; + QVector<int> base_id_; }; #endif // ! SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc index 57a67c2..1d48b1a 100644 --- a/scribo/demo/viewer/viewer.cc +++ b/scribo/demo/viewer/viewer.cc @@ -65,6 +65,9 @@ Viewer::Viewer(int &argc, char** argv) key_map_[region::Chart] = qMakePair(tr("Chart"), QColor(0, 204, 255)); key_map_[region::Maths] = qMakePair(tr("Maths"), QColor(170, 0, 255)); + key_map_[region::Baseline] = qMakePair(tr("Baseline"), QColor(128, 0, 255)); + key_map_[region::Meanline] = qMakePair(tr("Meanline"), QColor(128, 0, 255)); + // Region ids region_ids_["text_region"] = region::Text; @@ -78,7 +81,6 @@ Viewer::Viewer(int &argc, char** argv) region_ids_["chart_region"] = region::Chart; region_ids_["maths_region"] = region::Maths; - win_->resize(1152, 864); win_->statusBar(); @@ -154,7 +156,7 @@ Viewer::Viewer(int &argc, char** argv) precise_action_ = create_action("Precise outline", view_menu, "1px outline relative to the image " "(1px relative to the view if off).", - "Ctrl+p"); + "Shift+Ctrl+p"); precise_action_->setCheckable(true); precise_action_->setChecked(false); connect(precise_action_, SIGNAL(toggled(bool)), @@ -432,6 +434,100 @@ Viewer::add_region(QDomNode father, QString attr_id) scene_->addItem(r); } + +void +Viewer::add_typo_lines(QDomNode father, QString attr_id) +{ + // Retrieve typographical information + int baseline = father.toElement().attribute("baseline").toInt(); + int meanline = father.toElement().attribute("meanline").toInt(); + + QRect bbox; + + // Looking for bbox coordinates. + { + QDomNode coords = father.firstChild(); + while (!coords.isNull() && !coords.toElement().tagName().contains("coords")) + coords = coords.nextSibling(); + + if (coords.isNull()) + return; + + + QDomNode point = coords.firstChild(); + QVector<QPoint> points; + + while (!point.isNull()) + { + int x = point.toElement().attribute("x", "0").toInt(); + int y = point.toElement().attribute("y", "0").toInt(); + + points << QPoint(x, y); + point = point.nextSibling(); + } + + QPolygon polygon(points); + bbox = polygon.boundingRect(); + } + + // Creating blocks + + // Baseline + { + QVector<QPoint> points; + points.append(QPoint(bbox.topLeft().x(), baseline)); + points.append(QPoint(bbox.topRight().x(), baseline)); + + ImageRegion* r = new ImageRegion(region::Baseline, + key_map_[region::Baseline].first, + key_map_[region::Baseline].second, + attr_id, points, + outline_action_->isChecked(), + fill_action_->isChecked(), + precise_action_->isChecked(), + key_wgt_->isChecked(region::Baseline)); + + connect(this, SIGNAL(key_updated(int, bool)), + r, SLOT(setDrawIfSameId(int, bool))); + connect(this, SIGNAL(setOutline(bool)), + r, SLOT(setOutline(bool))); + connect(this, SIGNAL(setPrecise(bool)), + r, SLOT(setPrecise(bool))); + connect(this, SIGNAL(setFill(bool)), + r, SLOT(setFill(bool))); + + scene_->addItem(r); + } + + // Meanline + { + QVector<QPoint> points; + points.append(QPoint(bbox.topLeft().x(), meanline)); + points.append(QPoint(bbox.topRight().x(), meanline)); + + ImageRegion* r = new ImageRegion(region::Meanline, + key_map_[region::Meanline].first, + key_map_[region::Meanline].second, + attr_id, points, + outline_action_->isChecked(), + fill_action_->isChecked(), + precise_action_->isChecked(), + key_wgt_->isChecked(region::Meanline)); + + connect(this, SIGNAL(key_updated(int, bool)), + r, SLOT(setDrawIfSameId(int, bool))); + connect(this, SIGNAL(setOutline(bool)), + r, SLOT(setOutline(bool))); + connect(this, SIGNAL(setPrecise(bool)), + r, SLOT(setPrecise(bool))); + connect(this, SIGNAL(setFill(bool)), + r, SLOT(setFill(bool))); + + scene_->addItem(r); + } +} + + void Viewer::load_xml(QString filename) { @@ -557,7 +653,11 @@ Viewer::load_xml(QString filename) if (!line.isNull()) { if (extended_mode_) - add_region(line, attr_id); + { + QString line_id = line.toElement().attribute("id", "none"); + add_region(line, line_id); + add_typo_lines(line, line_id); + } add_text(line); } } diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh index c4b99e8..c68dd02 100644 --- a/scribo/demo/viewer/viewer.hh +++ b/scribo/demo/viewer/viewer.hh @@ -84,6 +84,7 @@ private: QPixmap load_base64(QString xml); void add_region(QDomNode father, QString attr_id); void add_text(QDomNode line); + void add_typo_lines(QDomNode father, QString attr_id); QAction *create_action(QString name, QMenu* menu, QString status, QString shortcut); void reset_progress_dialog(); void configure_printer(QPrinter& printer); -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
last-svn-commit-762-g47af3d9 demo/viewer/xml_widget.cc: Fix data tracking of selected objects.
by Guillaume Lazzara
--- scribo/ChangeLog | 5 ++ scribo/demo/viewer/xml_widget.cc | 117 ++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 03705c9..4c39daf 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,10 @@ 2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> + * demo/viewer/xml_widget.cc: Fix data tracking of selected + objects. + +2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> + Display baseline and meanline in Scribo viewer. * demo/viewer/common.hh: Add new enums. diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc index c45177b..1f2bc83 100644 --- a/scribo/demo/viewer/xml_widget.cc +++ b/scribo/demo/viewer/xml_widget.cc @@ -50,21 +50,14 @@ XmlWidget::select(QString id, QString name) { QDomNode n = node_map_[item_map_[id]]; - if (name.contains("Text line")) - { - n = n.firstChild(); - while (!n.isNull() && !n.toElement().tagName().contains("line")) - n = n.nextSibling(); - } - if (!n.isNull()) - { - QTreeWidgetItem* item = node_map_.key(n); + { + QTreeWidgetItem* item = node_map_.key(n); - tree_->setCurrentItem(item, 0); - item->setExpanded(true); - check_item(item); - } + tree_->setCurrentItem(item, 0); + item->setExpanded(true); + check_item(item); + } } void @@ -73,17 +66,17 @@ XmlWidget::check_item (QTreeWidgetItem* item) QDomNode node = node_map_[item]; if (node.hasAttributes()) + { + property_->clear(); + QDomNamedNodeMap attributes = node.toElement().attributes(); + + for (int i = 0; i < attributes.count(); ++i) { - property_->clear(); - QDomNamedNodeMap attributes = node.toElement().attributes(); - - for (int i = 0; i < attributes.count(); ++i) - { - QStringList values; - values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value(); - property_->addTopLevelItem(new QTreeWidgetItem(values)); - } + QStringList values; + values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value(); + property_->addTopLevelItem(new QTreeWidgetItem(values)); } + } property_->resizeColumnToContents(0); } @@ -91,42 +84,42 @@ XmlWidget::check_item (QTreeWidgetItem* item) void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item) { if (!node.isNull()) + { + QString append; + if (node.toElement().tagName().contains("point")) + { + QString x = node.toElement().attribute("x", "0"); + QString y = node.toElement().attribute("y", "0"); + append.append(" = (" + x + ", " + y + ")"); + } + + QTreeWidgetItem* child = + new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append)); + + if (node.hasAttributes()) + { + QString id = node.toElement().attribute("id", "none"); + item_map_[id] = child; + } + + node_map_[child] = node; + item->addChild(child); + + QDomNode sibling = node.firstChild(); + while (!sibling.isNull()) { - QString append; - if (node.toElement().tagName().contains("point")) - { - QString x = node.toElement().attribute("x", "0"); - QString y = node.toElement().attribute("y", "0"); - append.append(" = (" + x + ", " + y + ")"); - } - - QTreeWidgetItem* child = - new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append)); - - if (node.hasAttributes()) - { - QString id = node.toElement().attribute("id", "none"); - item_map_[id] = child; - } - - node_map_[child] = node; - item->addChild(child); - - QDomNode sibling = node.firstChild(); - while (!sibling.isNull()) - { - if (!sibling.toElement().tagName().contains("data")) - NFS(sibling, child); - else - { - QTreeWidgetItem* child_son = - new QTreeWidgetItem(QStringList("data = base64-encoded")); - - child->addChild(child_son); - } - sibling = sibling.nextSibling(); - } + if (!sibling.toElement().tagName().contains("data")) + NFS(sibling, child); + else + { + QTreeWidgetItem* child_son = + new QTreeWidgetItem(QStringList("data = base64-encoded")); + + child->addChild(child_son); + } + sibling = sibling.nextSibling(); } + } } void XmlWidget::fill_widget(QString xml) @@ -147,17 +140,17 @@ void XmlWidget::fill_widget(QString xml) QDomElement root = doc.documentElement(); QTreeWidgetItem* root_item= - new QTreeWidgetItem(QStringList(root.tagName())); + new QTreeWidgetItem(QStringList(root.tagName())); tree_->addTopLevelItem(root_item); root = root.firstChild().toElement(); while (!root.isNull()) - { - ++i; - NFS(root, root_item); - root = root.nextSibling().toElement(); - } + { + ++i; + NFS(root, root_item); + root = root.nextSibling().toElement(); + } } void -- 1.5.6.5
13Â years, 10Â months
1
0
0
0
← Newer
1
...
291
292
293
294
295
296
297
...
963
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
Results per page:
10
25
50
100
200