Olena-patches
Threads by month
- ----- 2025 -----
- September
- August
- July
- June
- May
- April
- March
- February
- 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
- 9625 discussions

last-svn-commit-763-g1cd8d75 src/text_in_picture.cc: Initialize ImageMagick and fix usage message.
by Guillaume Lazzara 14 Mar '11
by Guillaume Lazzara 14 Mar '11
14 Mar '11
---
scribo/ChangeLog | 5 +++++
scribo/src/text_in_picture.cc | 8 +++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 4c39daf..f3f150f 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * src/text_in_picture.cc: Initialize ImageMagick and fix usage
+ message.
+
2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
* demo/viewer/xml_widget.cc: Fix data tracking of selected
diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc
index 042b8d3..e2f30de 100644
--- a/scribo/src/text_in_picture.cc
+++ b/scribo/src/text_in_picture.cc
@@ -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.
//
@@ -176,7 +176,7 @@ int main(int argc, char* argv[])
if (argc < 3 || argc > 11)
return scribo::debug::usage(argv,
"Find text in a photo.\n\n"
- "Common usage: ./text_in_photo_fast input.*"
+ "Common usage: ./text_in_picture input.*"
" output.ppm 1 1 1 1 1",
"input.ppm output.ppm <bg/fg enabled>"
" <sauvola_ms enabled> "
@@ -197,6 +197,8 @@ int main(int argc, char* argv[])
trace::entering("main");
+ Magick::InitializeMagick(*argv);
+
image2d<value::rgb8> input_rgb;
io::magick::load(input_rgb, argv[1]);
--
1.5.6.5
1
0

last-svn-commit-764-g209645b =Add support for whitespace separators visualization.
by Guillaume Lazzara 14 Mar '11
by Guillaume Lazzara 14 Mar '11
14 Mar '11
* demo/viewer/common.hh,
* demo/viewer/key_widget.cc,
* demo/viewer/step_widget.cc,
* demo/viewer/viewer.cc: Handle visualization.
* scribo/toolchain/internal/content_in_doc_functor.hh,
* scribo/core/document.hh: Store separator information.
* scribo/io/xml/save.hh: Save whitespace separator data.
---
scribo/ChangeLog | 14 ++++++
scribo/demo/viewer/common.hh | 22 +++++++++-
scribo/demo/viewer/key_widget.cc | 6 ++-
scribo/demo/viewer/step_widget.cc | 1 +
scribo/demo/viewer/viewer.cc | 20 ++++++++-
scribo/scribo/core/document.hh | 47 ++++++++++++++++++++
scribo/scribo/io/xml/save.hh | 18 ++++++++
.../toolchain/internal/content_in_doc_functor.hh | 5 ++-
8 files changed, 128 insertions(+), 5 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index f3f150f..ef97bf9 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,17 @@
+2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add support for whitespace separators visualization.
+
+ * demo/viewer/common.hh,
+ * demo/viewer/key_widget.cc,
+ * demo/viewer/step_widget.cc,
+ * demo/viewer/viewer.cc: Handle visualization.
+
+ * scribo/toolchain/internal/content_in_doc_functor.hh,
+ * scribo/core/document.hh: Store separator information.
+
+ * scribo/io/xml/save.hh: Save whitespace separator data.
+
2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr>
* src/text_in_picture.cc: Initialize ImageMagick and fix usage
diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh
index 46f20c1..3b11ba5 100644
--- a/scribo/demo/viewer/common.hh
+++ b/scribo/demo/viewer/common.hh
@@ -24,14 +24,30 @@ namespace region
enum RegionId
{
+ // Text regions
+ // -------------
+
Text = 0,
+
+ // Extension
Line,
EndOfTextRegion,
+ // Separators
+ // ----------
+
+ Separator,
+
+ // Extension
+ WhitespaceSeparator,
+
+ EndOfSepsRegion,
+
+ // Misc regions.
+ // -------------
Image,
Noise,
- Separator,
Table,
LineDrawing,
Graphic,
@@ -40,6 +56,10 @@ namespace region
EndOfMiscRegion,
+ // Typographical lines
+ // -------------------
+
+ // Extension
Baseline,
Meanline,
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index cc10308..3b07617 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -22,8 +22,9 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map)
: 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")));
+ item_list_.append(new QTreeWidgetItem(QStringList("Separators")));
+ item_list_.append(new QTreeWidgetItem(QStringList("Misc. Regions")));
+ item_list_.append(new QTreeWidgetItem(QStringList("Typographical lines")));
QLabel* title = new QLabel(tr("Key"));
title->setAlignment(Qt::AlignHCenter);
@@ -38,6 +39,7 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map)
base_id_.append(0);
base_id_.append(region::EndOfTextRegion + 1);
+ base_id_.append(region::EndOfSepsRegion + 1);
base_id_.append(region::EndOfMiscRegion + 1);
base_id_.append(region::EndOfTypoRegion + 1);
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
index 77e9bd3..19b5d0f 100644
--- a/scribo/demo/viewer/step_widget.cc
+++ b/scribo/demo/viewer/step_widget.cc
@@ -59,6 +59,7 @@ void StepWidget::activate(QListWidgetItem* item)
key = iter.key();
value = iter.value();
+ qDebug() << "Loading " << value;
emit load_xml(value);
}
else
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 1d48b1a..f34b3e7 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -51,8 +51,11 @@ Viewer::Viewer(int &argc, char** argv)
pdialog_(win_)
{
// Key map
+ // --------
key_map_[region::Text] = qMakePair(tr("Text Region"), QColor(0, 200, 0));
+
+ // Extension
key_map_[region::Line] = qMakePair(tr("Text line"), QColor(255, 0, 0));
key_map_[region::Image] = qMakePair(tr("Image"), QColor(255, 120, 0));
@@ -65,13 +68,23 @@ 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));
+ // Extension
+ key_map_[region::WhitespaceSeparator] = qMakePair(tr("Whitespace Separator"), QColor(0, 0, 128));
+
+ // Extension
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;
+
+ // Extension
region_ids_["line"] = region::Line;
+
region_ids_["image_region"] = region::Image;
region_ids_["noise_region"] = region::Noise;
region_ids_["separator_region"] = region::Separator;
@@ -81,6 +94,11 @@ Viewer::Viewer(int &argc, char** argv)
region_ids_["chart_region"] = region::Chart;
region_ids_["maths_region"] = region::Maths;
+ // Extension
+ region_ids_["whitespace_separator_region"] = region::WhitespaceSeparator;
+
+
+
win_->resize(1152, 864);
win_->statusBar();
@@ -572,7 +590,7 @@ Viewer::load_xml(QString filename)
while (!region.isNull())
{
- if (region.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table|text)_region")))
+ if (region.toElement().tagName().contains(QRegExp("(whitespace_separator|image|graphic|chart|separator|table|text)_region")))
{
QString attr_id = region.toElement().attribute("id", "none");
add_region(region, attr_id);
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index b547da4..f112410 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -32,6 +32,7 @@
/// \brief Describes document content.
# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/neighb2d.hh>
# include <mln/value/rgb8.hh>
# include <mln/io/magick/load.hh>
@@ -39,6 +40,8 @@
# include <scribo/core/line_set.hh>
# include <scribo/core/paragraph_set.hh>
+# include <scribo/primitive/extract/components.hh>
+
namespace scribo
{
@@ -83,6 +86,11 @@ namespace scribo
const mln::image2d<value::rgb8>& image() const;
void set_image(const mln::image2d<value::rgb8>& image);
+ bool has_whitespace_seps() const;
+ const mln::image2d<bool>& whitespace_seps() const;
+ const component_set<L>& whitespace_seps_comps() const;
+ void set_whitespace_separators(const image2d<bool>& whitespace_seps);
+
private:
const char *filename_;
mln::image2d<mln::value::rgb8> image_;
@@ -90,6 +98,9 @@ namespace scribo
line_set<L> lines_;
paragraph_set<L> parset_;
component_set<L> elements_;
+
+ mln::image2d<bool> whitespace_seps_;
+ component_set<L> whitespace_seps_comps_;
};
@@ -247,6 +258,42 @@ namespace scribo
}
+ template <typename L>
+ bool
+ document<L>::has_whitespace_seps() const
+ {
+ return whitespace_seps_.is_valid();
+ }
+
+
+ template <typename L>
+ const mln::image2d<bool>&
+ document<L>::whitespace_seps() const
+ {
+ return whitespace_seps_;
+ }
+
+
+ template <typename L>
+ const component_set<L>&
+ document<L>::whitespace_seps_comps() const
+ {
+ return whitespace_seps_comps_;
+ }
+
+
+ template <typename L>
+ void
+ document<L>::set_whitespace_separators(const image2d<bool>& whitespace_seps)
+ {
+ whitespace_seps_ = whitespace_seps;
+
+ mln_value(L) ncomps;
+ whitespace_seps_comps_ = primitive::extract::components(whitespace_seps,
+ mln::c8(), ncomps);
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index 41d4fef..7011e87 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -364,6 +364,24 @@ namespace scribo
}
+ // Whitespace seraparators
+ if (doc.has_whitespace_seps())
+ {
+ const component_set<L>&
+ whitespace_seps_comps = doc.whitespace_seps_comps();
+
+ for_all_comps(c, whitespace_seps_comps)
+ {
+ file << " <whitespace_separator_region id=\"wss"
+ << whitespace_seps_comps(c).id()
+ << "\">" << std::endl;
+
+ internal::print_box_coords(file, whitespace_seps_comps(c).bbox(), " ");
+
+ file << " </whitespace_separator_region>" << std::endl;
+ }
+ }
+
file << " </page>" << std::endl;
file << "</pcGts>" << std::endl;
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index fb7cd7c..b8aa56d 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -237,7 +237,10 @@ namespace scribo
if (enable_line_seps)
components.add_separators(separators);
if (enable_whitespace_seps)
+ {
components.add_separators(whitespaces);
+ doc.set_whitespace_separators(whitespaces);
+ }
if (enable_debug)
mln::io::pbm::save(components.separators(),
@@ -251,7 +254,7 @@ namespace scribo
on_progress();
- /// Linking potential objects
+ /// Linking objects
on_new_progress_label("Linking objects...");
object_links<L> left_link
--
1.5.6.5
1
0

14 Mar '11
* scribo/scribo/convert/from_base64.hh,
* scribo/scribo/convert/to_base64.hh: New routines.
* scribo/tests/Makefile.am,
* scribo/tests/convert/Makefile.am,
* scribo/tests/convert/base64.cc: New associated test.
---
scribo/ChangeLog | 11 ++
scribo/scribo/convert/from_base64.hh | 217 ++++++++++++++++++++++++++++
scribo/scribo/convert/to_base64.hh | 185 ++++++++++++++++++++++++
scribo/tests/Makefile.am | 1 +
scribo/tests/{core => convert}/Makefile.am | 8 +-
scribo/tests/convert/base64.cc | 89 ++++++++++++
6 files changed, 507 insertions(+), 4 deletions(-)
create mode 100644 scribo/scribo/convert/from_base64.hh
create mode 100644 scribo/scribo/convert/to_base64.hh
copy scribo/tests/{core => convert}/Makefile.am (84%)
create mode 100644 scribo/tests/convert/base64.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index ef97bf9..9cbfca1 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add Base64 conversion routines.
+
+ * scribo/scribo/convert/from_base64.hh,
+ * scribo/scribo/convert/to_base64.hh: New routines.
+
+ * scribo/tests/Makefile.am,
+ * scribo/tests/convert/Makefile.am,
+ * scribo/tests/convert/base64.cc: New associated test.
+
2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Add support for whitespace separators visualization.
diff --git a/scribo/scribo/convert/from_base64.hh b/scribo/scribo/convert/from_base64.hh
new file mode 100644
index 0000000..8c14a0f
--- /dev/null
+++ b/scribo/scribo/convert/from_base64.hh
@@ -0,0 +1,217 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+
+#ifndef SCRIBO_CONVERT_FROM_BASE64_HH
+# define SCRIBO_CONVERT_FROM_BASE64_HH
+
+/*! \file
+
+ \brief Decode base64 raw data and convert it to an image.
+
+ Based on Bob Trower's code.
+ http://base64.sourceforge.net/b64.c
+
+ LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated
+ documentation files (the "Software"), to deal in the
+ Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall
+ be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <cstdio>
+#include <cstdlib>
+
+# include <mln/border/resize.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/util/array.hh>
+
+
+
+namespace scribo
+{
+
+ namespace convert
+ {
+
+ using namespace mln;
+
+ template <typename I>
+ void from_base64(const util::array<unsigned char>& data64,
+ Image<I>& output);
+
+
+# if defined HAVE_QT
+
+ template <typename I>
+ void from_base64(const QString& data64, Image<I>& output_);
+
+# endif // ! HAVE_QT
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ /*
+ ** Translation Table to decode
+ */
+ static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
+
+ /*
+ ** decodeblock
+ **
+ ** decode 4 '6-bit' characters into 3 8-bit binary bytes
+ */
+ inline
+ void
+ decodeblock(unsigned char in[4], unsigned char out[3])
+ {
+ out[ 0 ] = (unsigned char) (in[0] << 2 | in[1] >> 4);
+ out[ 1 ] = (unsigned char) (in[1] << 4 | in[2] >> 2);
+ out[ 2 ] = (unsigned char) (((in[2] << 6) & 0xc0) | in[3]);
+ }
+
+
+ template <typename V, typename I>
+ void
+ from_base64_(const V& data64, const unsigned length, Image<I>& output_)
+ {
+ trace::entering("scribo::convert::from_base64_");
+
+ mln_precondition(exact(output_).is_valid());
+ using namespace internal;
+
+ I& output = exact(output_);
+
+ unsigned char in[4], out[3], v;
+ int i, len;
+
+ border::resize(output, 0); // Make sure there is no border!
+
+ unsigned char *ptr = (unsigned char *)output.buffer();
+ unsigned char *end_ptr = (unsigned char *)(output.buffer() + output.nelements());
+
+ for (unsigned idx = 0; idx < length;)
+ {
+ for(len = 0, i = 0; i < 4 && idx < length; i++)
+ {
+ v = 0;
+ while(idx < length && v == 0)
+ {
+ v = (unsigned char) data64[idx++];
+ v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]);
+ if(v)
+ {
+ v = (unsigned char) ((v == '$') ? 0 : v - 61);
+ }
+ }
+ if(idx < length)
+ {
+ len++;
+ if(v)
+ {
+ in[ i ] = (unsigned char) (v - 1);
+ }
+ }
+ else
+ {
+ in[i] = 0;
+ }
+ }
+ if(len)
+ {
+ decodeblock(in, out);
+ for(i = 0; i < len - 1 && ptr != end_ptr; i++)
+ {
+ *ptr++ = out[i];
+ }
+ }
+ }
+
+ trace::exiting("scribo::convert::to_base64_");
+ }
+
+
+ } // end of namespace scribo::convert::internal
+
+
+ template <typename I>
+ void
+ from_base64(const util::array<unsigned char>& data64, Image<I>& output_)
+ {
+ trace::entering("scribo::convert::from_base64");
+
+ internal::from_base64_(data64, data64.nelements(), output_);
+
+ trace::exiting("scribo::convert::to_base64");
+ }
+
+
+# if defined HAVE_QT
+
+ template <typename I>
+ void
+ from_base64(const QString& data64, Image<I>& output_)
+ {
+ trace::entering("scribo::convert::from_base64");
+
+ QByteArray data64_ = data64.toAscii();
+ internal::from_base64_(data64_.constData(), data64_.size(), output_);
+
+ trace::exiting("scribo::convert::to_base64");
+ }
+
+# endif // ! HAVE_QT
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace scribo::convert
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_CONVERT_FROM_BASE64_HH
diff --git a/scribo/scribo/convert/to_base64.hh b/scribo/scribo/convert/to_base64.hh
new file mode 100644
index 0000000..8df3ed2
--- /dev/null
+++ b/scribo/scribo/convert/to_base64.hh
@@ -0,0 +1,185 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+
+#ifndef SCRIBO_CONVERT_TO_BASE64_HH
+# define SCRIBO_CONVERT_TO_BASE64_HH
+
+/*! \file
+
+ \brief Encode an image into base64 raw data.
+
+ Based on Bob Trower's code.
+ http://base64.sourceforge.net/b64.c
+
+ LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated
+ documentation files (the "Software"), to deal in the
+ Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall
+ be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+# include <cstdio>
+# include <cstdlib>
+
+# include <mln/border/resize.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/util/array.hh>
+
+
+# define B64_DEF_LINE_SIZE 72
+
+namespace scribo
+{
+
+ namespace convert
+ {
+
+ using namespace mln;
+
+
+ template <typename I>
+ void
+ to_base64(const Image<I>& input, util::array<unsigned char>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ /*
+ ** Translation Table as described in RFC1113
+ */
+ static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ /*
+ ** encodeblock
+ **
+ ** encode 3 8-bit binary bytes as 4 '6-bit' characters
+ */
+ inline
+ void
+ encodeblock(unsigned char in[3], unsigned char out[4], int len)
+ {
+ out[0] = cb64[ in[0] >> 2 ];
+ out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
+ out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
+ out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
+ }
+
+ } // end of namespace scribo::convert::internal
+
+
+
+ template <typename I>
+ void
+ to_base64(const Image<I>& input_, util::array<unsigned char>& output)
+ {
+ trace::entering("scribo::convert::to_base64");
+
+ mln_precondition(exact(input_).is_valid());
+ using namespace internal;
+
+ const I& input = exact(input_);
+
+ unsigned char in[3], out[4];
+ int i, len, blocksout = 0;
+
+ // FIXME: Take border into account while moving pointer and
+ // remove that call.
+ border::resize(input, 0);
+
+ const unsigned char
+ *end_ptr = (unsigned char *) (input.buffer() + input.nelements()),
+ *ptr = (unsigned char *)input.buffer();
+
+ while(ptr != end_ptr)
+ {
+ len = 0;
+ for(i = 0; i < 3; ++i)
+ {
+ if (ptr != end_ptr)
+ {
+ in[i] = (unsigned char) *ptr++;
+ ++len;
+ }
+ else
+ {
+ in[i] = 0;
+ for(++i; i < 3; ++i)
+ in[i] = 0;
+ }
+ }
+ if(len)
+ {
+ encodeblock(in, out, len);
+ for(i = 0; i < 4; ++i)
+ output.append(out[i]);
+ ++blocksout;
+ }
+ if(blocksout >= (B64_DEF_LINE_SIZE/4) || ptr == end_ptr)
+ {
+ if(blocksout)
+ {
+ output.append('\r');
+ output.append('\n');
+ }
+ blocksout = 0;
+ }
+ }
+
+ trace::exiting("scribo::convert::to_base64");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+# undef B64_DEF_LINE_SIZE
+
+ } // end of namespace scribo::convert
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_CONVERT_TO_BASE64_HH
diff --git a/scribo/tests/Makefile.am b/scribo/tests/Makefile.am
index 1cb222b..09768b1 100644
--- a/scribo/tests/Makefile.am
+++ b/scribo/tests/Makefile.am
@@ -29,6 +29,7 @@ EXTRA_DIST = \
SUBDIRS = \
binarization \
+ convert \
core \
filter \
preprocessing \
diff --git a/scribo/tests/core/Makefile.am b/scribo/tests/convert/Makefile.am
similarity index 84%
copy from scribo/tests/core/Makefile.am
copy to scribo/tests/convert/Makefile.am
index 356cc31..c4c912c 100644
--- a/scribo/tests/core/Makefile.am
+++ b/scribo/tests/convert/Makefile.am
@@ -1,5 +1,4 @@
-# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-# (LRDE).
+# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -20,8 +19,9 @@
include $(top_srcdir)/scribo/tests/tests.mk
-check_PROGRAMS = line_info
+check_PROGRAMS = \
+ base64
-line_info_SOURCES = line_info.cc
+base64_SOURCES = base64.cc
TESTS = $(check_PROGRAMS)
diff --git a/scribo/tests/convert/base64.cc b/scribo/tests/convert/base64.cc
new file mode 100644
index 0000000..18d08d9
--- /dev/null
+++ b/scribo/tests/convert/base64.cc
@@ -0,0 +1,89 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+
+/// \file
+
+#include <cstdio>
+#include <cstdlib>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
+
+#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+
+#include <mln/value/int_u16.hh>
+
+#include <scribo/convert/to_base64.hh>
+#include <scribo/convert/from_base64.hh>
+
+#include "tests/data.hh"
+
+using namespace mln;
+
+int main()
+{
+
+ // PBM
+ {
+ image2d<bool> ima;
+ io::pbm::load(ima, SCRIBO_IMG_DIR "/wildly.pbm");
+
+ util::array<unsigned char> out64;
+ scribo::convert::to_base64(ima, out64);
+
+ image2d<bool> outbin(ima.domain());
+ scribo::convert::from_base64(out64, outbin);
+
+ mln_assertion(outbin == ima);
+ }
+
+ // PGM (8bits)
+ {
+ image2d<value::int_u8> ima;
+ io::pgm::load(ima, SCRIBO_IMG_DIR "/text_to_group.pgm");
+
+ util::array<unsigned char> out64;
+ scribo::convert::to_base64(ima, out64);
+
+ image2d<value::int_u8> outbin(ima.domain());
+ scribo::convert::from_base64(out64, outbin);
+
+ mln_assertion(outbin == ima);
+ }
+
+ // PGM (30bits)
+ {
+ image2d<value::int_u<30> > ima(3, 3);
+ debug::iota(ima, 100000);
+
+ util::array<unsigned char> out64;
+ scribo::convert::to_base64(ima, out64);
+
+ image2d<value::int_u<30> > outbin(ima.domain());
+ scribo::convert::from_base64(out64, outbin);
+
+ mln_assertion(outbin == ima);
+ }
+
+
+ return 0;
+}
--
1.5.6.5
1
0

last-svn-commit-766-ge05c9c3 configure.ac: configure scribo/tests/convert.
by Guillaume Lazzara 14 Mar '11
by Guillaume Lazzara 14 Mar '11
14 Mar '11
---
ChangeLog | 4 ++++
configure.ac | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3eb76e4..9fedefa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * configure.ac: configure scribo/tests/convert.
+
2011-03-14 Thierry GERAUD <thierry.geraud(a)lrde.epita.fr>
* milena/mln/labeling/regional_maxima.hh
diff --git a/configure.ac b/configure.ac
index d22f65f..e30f010 100644
--- a/configure.ac
+++ b/configure.ac
@@ -343,6 +343,7 @@ AC_CONFIG_FILES([scribo/tests/data.hh])
AC_CONFIG_FILES([
scribo/tests/Makefile
scribo/tests/binarization/Makefile
+ scribo/tests/convert/Makefile
scribo/tests/core/Makefile
scribo/tests/filter/Makefile
scribo/tests/preprocessing/Makefile
--
1.5.6.5
1
0

14 Mar '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch next-build-test has been updated
via db7457153f9ac3811483be20a4d8981e31443785 (commit)
via 4e7a87b8c9aa19b264a9eaae5fd4eacd7ff7b947 (commit)
via 76d581414104c04a8954b083b24cf9caf58154e7 (commit)
via 1e74eb51d3243487f13ea104079737c53ac0361b (commit)
via 2d12896ac7a0e42de83bed33c3dde02bbae4b6e5 (commit)
via 6adf703bc7b05f9ff00719b7cbbc845a234d3f9d (commit)
via b71d6973bdcfda3c47cc9a4211339555a6cf0a27 (commit)
via 2f870e06bc47707e86500bfb905e013545d81ee0 (commit)
via 4b5b9f8ea9ff23a59ee7bdca6297a57b5b16bdc1 (commit)
via 3f14376ad38b8967e5af7d63ddac93989f58ac39 (commit)
via 8ee4c1acd45d4bd6c1a8805fe41de65c1153ba17 (commit)
via 8aaa787401d5d6681ab824550216d5abee24c324 (commit)
via 3038605191b650a8a86d10ffb986d165bca13f31 (commit)
via eae112f79b28e0e6f217b6cfe130a4a1dc1ca0c4 (commit)
via 294c4219261707af15a0d5593ddefd6f86851c44 (commit)
via 80b10b678600c73da186ebe4662652096c98673b (commit)
via 1a5cc61c52a905239876107d1ac2143a62e23968 (commit)
via 500be97a841a57b0cf6f580d6573a6ef1f941803 (commit)
via 3f06d28a852c01e7f49ec0320a2cdf254ad11ec4 (commit)
via 07b076ce0ba19ac3741350db76a881252cab9313 (commit)
via d045991c53396fcbf462e8824b9bd68657c3824b (commit)
via 9721b83ee36739262562acd9a53019351e476044 (commit)
via 2cd9b0158f329056d6baf732c8c94da4a58f9477 (commit)
via 00e84b1ea30ed7f4d9adb3e46576f0da37d4701b (commit)
via 7a467ce53641d6df7084ad28c230b59e741b3158 (commit)
via c4bfbf3039ad1bc22e9d6a84898e1aa30204b165 (commit)
via 88a5659a616bb9a61144ce29447da7c78afd1d16 (commit)
via 55dec68d501bf9aea0237bc734f8e34a2c2b8659 (commit)
via 525a77d49f93c4d8af8f0f98311a59fa91ad37f5 (commit)
via be7296a994a74454aed04e9ac5697b1ebf7f1239 (commit)
via 3e799ae9a6155fe25743f551e029b8f407ba5f87 (commit)
via c6aef9e87ecd21dc02545f3ff234dfa37c49ef0e (commit)
via 71e09952f8956d7969923783e4d11785ed69ac70 (commit)
via f4cad33327251f4d0d7c9f03ba309b0472671685 (commit)
via 38639f48cf630d9773a72825adf3e1c2bd33d699 (commit)
via 08507d9f6ee6460473604cd94e1cc094ca4dcb6f (commit)
via 300d0d76ad8aba7dbf1f793b8bfbbc32b80016a8 (commit)
via b37a853c16b36dc73376fbc32562772a0a1778eb (commit)
via 5127a7b422860a30f96a86f71f5bb1e6961894fa (commit)
via b1fe7b822ef9667e06e4a61465cca47a19c728d8 (commit)
via 67e03b2fa427dbcea04133c7c62ed6b9e3b40770 (commit)
via 37420bc1bc21b94431344d5ed978f6b537333816 (commit)
via 9fc92d2022701f48b1471d7899df48eefe5c3281 (commit)
via 36bdfe6bd32b4e4fc6f5e4ca6443de39ea7ed1d5 (commit)
via 09b76a65da9f752c14797fe845b5d9f3c2e9e193 (commit)
via 9ce4470df6ec50f7c5776cc78c9ef8b804579b27 (commit)
via cff396c972728565d654eab1ff4258ef18fa51c6 (commit)
via b9a628915f1d9728cacca0049eccb7272427164d (commit)
via 7bdf8a260b084ca369db30a705dd5c3e8a1ecec3 (commit)
via 26501abd4604deb0a0670c6b8bf3a212145477b3 (commit)
via c027c16fdbc3ffe8b1623764a56bd9cfad77a8bc (commit)
via e05c9c33f0bf1a7a3b2499f872f2a4167ceba41f (commit)
via a192077679cb7736a2dc6f096bac377b0f4453ba (commit)
via 209645b7fdd312ecf6b9f6e37281e6b1122792b5 (commit)
via 1cd8d75d23d5d2a54b1847d7ea6bae714b39b37f (commit)
via 47af3d9cb24e89d843ca9648f55db11b575b4bc7 (commit)
via d5019dd2432f7e82eb2ac079a3ab14576b8badb8 (commit)
via c96edd6fb6f8e3ab339b1b565941007a5da9a4c7 (commit)
via 79b3aaa9765b6a9f86d71ddf55d3556d4f922cfd (commit)
via 11325f7f2dd2278993de4dd4a11e9a136617a398 (commit)
from c4bfdc8ca94fc3283920876a447bf21b1efaf9bb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
db74571 Regen generated files.
4e7a87b mln/labeling/colorize.hh: Add a missing inline.
76d5814 Add more from_to overloards.
1e74eb5 build-aux/build_unit_test.sh: Define HAVE_* for unit-tests.
2d12896 Regen generated files.
6adf703 tests/toolchain/nepomuk/Makefile.am: Add MAGICKXX flags.
b71d697 scribo/core/def/lbl_type.hh: Use int_u<n> as label type.
2f870e0 Set unit tests dependencies.
4b5b9f8 New debug tools.
3f14376 New non-text components extraction routine.
8ee4c1a Introduce result image output.
8aaa787 Save image edge coordinates in XML output.
3038605 scribo/filter/object_links_aligned.hh: New.
eae112f scribo/primitive/extract/separators_nonvisible.hh: Cleanup and improve debug support.
294c421 Various small fixes.
80b10b6 Introduce a new component linking method.
1a5cc61 Spread anchor value to more methods in link functors.
500be97 Introduce a logger class.
3f06d28 Introduce a logger class.
07b076c Introduce new anchors.
d045991 Rename document serializer base class.
9721b83 Store more information in scribo::document.
2cd9b01 Rename line_info::components() to line_info::component_ids.
00e84b1 Some changes in debug routines.
7a467ce Add HAVE_QT guards.
c4bfbf3 Small fixes in viewer.
88a5659 scribo/io/xml/internal/extended_page_xml_visitor.hh: Save separators data.
55dec68 scribo/io/xml/internal/full_xml_visitor.hh: Do not copy image data.
525a77d Make OCR step optional in viewer.
be7296a scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR step optional.
3e799ae Compress image data in XML output.
c6aef9e Small fixes in Scribo.
71e0995 Regen mk files.
f4cad33 scribo/primitive/extract/non_text.hh: Remove debug.
38639f4 Add new debug tools.
08507d9 scribo/text/extract_lines.hh: Update code.
300d0d7 Make use of mln::fun::v2v::rgb_to_luma.
b37a853 mln/labeling/fill_holes.hh: Improve speed.
5127a7b mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion.
b1fe7b8 scribo/io/xml/load.hh: New XML loader.
67e03b2 Make XML output more flexible.
37420bc Set component type during component extraction.
9fc92d2 configure.ac: scribo/src/primitive/remove.
36bdfe6 Add new tools in Scribo.
09b76a6 Small fixes in Scribo.
9ce4470 Improve and cleanup whitespace separator detection.
cff396c Add new conversion routines from string to tag.
b9a6289 Various changes in scribo core structures.
7bdf8a2 Rename files in Scribo.
26501ab mln/util/array.hh: Add last() method.
c027c16 Add an optional base index for debug::iota.
e05c9c3 configure.ac: configure scribo/tests/convert.
a192077 Add Base64 conversion routines.
209645b =Add support for whitespace separators visualization.
1cd8d75 src/text_in_picture.cc: Initialize ImageMagick and fix usage message.
47af3d9 demo/viewer/xml_widget.cc: Fix data tracking of selected objects.
d5019dd Display baseline and meanline in Scribo viewer.
c96edd6 Add printing support in Scribo viewer.
79b3aaa Improve about dialog in scribo viewer.
11325f7 demo/viewer/runner.cc: Clear arguments on new process.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 12 +
build-aux/build_unit_test.sh | 2 +-
configure.ac | 2 +
milena/ChangeLog | 38 +
milena/headers.mk | 2 +
milena/mln/convert/impl/from_unsigned_to_value.hh | 26 +-
milena/mln/debug/iota.hh | 22 +-
milena/mln/debug/iota.spe.hh | 9 +-
milena/mln/fun/v2v/rgb_to_luma.hh | 72 ++
milena/mln/labeling/colorize.hh | 3 +-
milena/mln/labeling/fill_holes.hh | 17 +-
milena/mln/util/array.hh | 25 +-
milena/mln/value/label.hh | 20 +-
milena/tests/unit_test/unit-tests.mk | 30 +-
scribo/ChangeLog | 616 +++++++++++++++
scribo/demo/shared/icons/olena_smaller.jpg | Bin 0 -> 8028 bytes
scribo/demo/shared/shared.qrc | 3 +-
scribo/demo/viewer/Makefile.am | 26 +-
scribo/demo/viewer/common.hh | 33 +-
scribo/demo/viewer/config.cc | 28 +-
scribo/demo/viewer/config.hh | 11 +-
scribo/demo/viewer/help_dialog.cc | 43 +-
scribo/demo/viewer/help_dialog.hh | 11 +-
scribo/demo/viewer/help_dialog.ui | 138 ++++
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/key_widget.cc | 125 ++--
scribo/demo/viewer/key_widget.hh | 4 +-
scribo/demo/viewer/main.cc | 5 +-
scribo/demo/viewer/ocr_options.cc | 74 ++
scribo/demo/viewer/ocr_options.hh | 40 +
scribo/demo/viewer/ocr_options.ui | 62 ++
scribo/demo/viewer/preferences_dialog.cc | 26 +-
scribo/demo/viewer/preprocessing_options.cc | 66 ++
scribo/demo/viewer/preprocessing_options.hh | 38 +
scribo/demo/viewer/preprocessing_options.ui | 76 ++
scribo/demo/viewer/runner.cc | 10 +-
scribo/demo/viewer/segmentation_options.cc | 56 ++
scribo/demo/viewer/segmentation_options.hh | 37 +
scribo/demo/viewer/segmentation_options.ui | 52 ++
scribo/demo/viewer/step_widget.cc | 1 +
scribo/demo/viewer/toolchain_options.cc | 75 --
scribo/demo/viewer/toolchain_options.hh | 37 -
scribo/demo/viewer/toolchain_options.ui | 121 ---
scribo/demo/viewer/viewer.cc | 227 ++++++-
scribo/demo/viewer/viewer.hh | 10 +-
scribo/demo/viewer/viewer.qrc | 5 +
scribo/demo/viewer/xml_widget.cc | 117 ++--
scribo/headers.mk | 35 +-
scribo/scribo/convert/from_base64.hh | 221 ++++++
scribo/scribo/convert/to_base64.hh | 185 +++++
scribo/scribo/core/component_info.hh | 26 +-
scribo/scribo/core/component_set.hh | 122 ++-
scribo/scribo/core/concept/serializable.hh | 64 ++
scribo/scribo/core/concept/serialize_visitor.hh | 49 ++
scribo/scribo/core/def/lbl_type.hh | 12 +-
scribo/scribo/core/document.hh | 171 ++++-
scribo/scribo/core/internal/doc_serializer.hh | 140 ++++
scribo/scribo/core/line_info.hh | 419 ++++++-----
scribo/scribo/core/line_links.hh | 10 +-
scribo/scribo/core/line_set.hh | 29 +-
scribo/scribo/core/macros.hh | 7 +-
scribo/scribo/core/object_groups.hh | 4 +-
scribo/scribo/core/object_links.hh | 8 +-
scribo/scribo/core/paragraph_info.hh | 19 +
scribo/scribo/core/paragraph_set.hh | 116 +++-
scribo/scribo/core/tag/anchor.hh | 11 +-
scribo/scribo/core/tag/component.hh | 51 ++-
scribo/scribo/core/tag/line.hh | 34 +-
scribo/scribo/debug/alignment_decision_image.hh | 87 +--
scribo/scribo/debug/all.hh | 7 +-
scribo/scribo/debug/bboxes_image.hh | 166 ++++
scribo/scribo/debug/char_space_image.hh | 8 +-
scribo/scribo/debug/linked_bboxes_image.hh | 262 +++++++
scribo/scribo/debug/links_image.hh | 106 +++
scribo/scribo/debug/logger.hh | 293 ++++++++
scribo/scribo/debug/save_bboxes_image.hh | 174 -----
scribo/scribo/debug/save_linked_bboxes_image.hh | 277 -------
.../scribo/debug/several_links_decision_image.hh | 179 -----
scribo/scribo/filter/internal/alignment_angle.hh | 146 +++--
scribo/scribo/filter/object_links_aligned.hh | 114 +++
.../scribo/filter/object_links_bottom_aligned.hh | 8 +-
.../filter/object_links_non_aligned_simple.hh | 3 +-
scribo/scribo/filter/object_links_top_aligned.hh | 7 +-
scribo/scribo/fun/v2v/highlight.hh | 77 ++
scribo/scribo/io/img/internal/debug_img_visitor.hh | 263 +++++++
scribo/scribo/io/img/internal/draw_edges.hh | 97 +++
scribo/scribo/io/img/internal/full_img_visitor.hh | 194 +++++
.../scribo/io/img/internal/non_text_img_visitor.hh | 162 ++++
scribo/scribo/io/img/internal/text_img_visitor.hh | 164 ++++
scribo/scribo/io/img/save.hh | 242 ++++++
.../io/xml/internal/extended_page_xml_visitor.hh | 304 ++++++++
scribo/scribo/io/xml/internal/full_xml_visitor.hh | 469 ++++++++++++
scribo/scribo/io/xml/internal/page_xml_visitor.hh | 224 ++++++
scribo/scribo/io/xml/internal/print_box_coords.hh | 95 +++
.../scribo/io/xml/internal/print_image_coords.hh | 94 +++
.../scribo/io/xml/internal/print_page_preambule.hh | 100 +++
scribo/scribo/io/xml/load.hh | 529 +++++++++++++
scribo/scribo/io/xml/save.hh | 383 ++--------
scribo/scribo/make/text_blocks_image.hh | 136 ++++
scribo/scribo/make/text_components_image.hh | 101 +++
scribo/scribo/preprocessing/rotate_90.hh | 25 +-
scribo/scribo/primitive/extract/components.hh | 18 +-
scribo/scribo/primitive/extract/elements.hh | 236 ------
.../primitive/extract/horizontal_separators.hh | 27 +-
scribo/scribo/primitive/extract/internal/union.hh | 246 ++++++
scribo/scribo/primitive/extract/non_text.hh | 369 +++++++++
scribo/scribo/primitive/extract/non_text_kmean.hh | 224 ++++++
scribo/scribo/primitive/extract/separators.hh | 9 +-
.../primitive/extract/separators_nonvisible.hh | 790 ++++++--------------
scribo/scribo/primitive/identify.hh | 30 +-
.../primitive/link/internal/compute_anchor.hh | 42 +-
scribo/scribo/primitive/link/internal/find_link.hh | 5 +-
.../primitive/link/internal/link_functor_base.hh | 31 +-
.../link_single_dmax_ratio_aligned_base.hh | 268 +++++++
.../link/internal/link_single_dmax_ratio_base.hh | 7 +-
.../with_single_left_link_dmax_ratio_aligned.hh | 217 ++++++
.../primitive/link/with_single_right_link.hh | 16 +-
.../with_single_right_link_dmax_ratio_aligned.hh | 69 +--
.../primitive/link/with_single_right_link_top.hh | 28 +-
scribo/scribo/table/extract.hh | 6 +-
scribo/scribo/text/extract_lines.hh | 73 ++-
scribo/scribo/text/merging.hh | 6 +-
scribo/scribo/text/recognition.hh | 6 +-
scribo/scribo/toolchain/content_in_doc.hh | 10 +-
.../toolchain/internal/content_in_doc_functor.hh | 260 ++++---
.../toolchain/internal/text_in_doc_functor.hh | 107 ++--
.../internal/text_in_doc_preprocess_functor.hh | 7 +-
scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +-
scribo/scribo/toolchain/text_in_doc.hh | 11 +-
scribo/scribo/toolchain/text_in_picture.hh | 20 +-
scribo/src/Makefile.am | 32 +-
scribo/src/binarization/ppm_sauvola.cc | 9 +-
scribo/src/binarization/ppm_sauvola_ms.cc | 9 +-
scribo/src/binarization/ppm_sauvola_ms_fg.cc | 8 +-
scribo/src/binarization/ppm_sauvola_ms_split.cc | 5 +-
scribo/src/binarization/sauvola.cc | 4 +-
scribo/src/binarization/sauvola_debug.cc | 8 +-
scribo/src/binarization/sauvola_ms.cc | 9 +-
scribo/src/binarization/sauvola_ms_debug.cc | 9 +-
scribo/src/binarization/sauvola_ms_fg.cc | 8 +-
scribo/src/content_in_doc.cc | 28 +-
scribo/src/debug/Makefile.am | 66 ++-
scribo/src/debug/non_text_mask.cc | 26 +
scribo/src/debug/show_components_bboxes.cc | 59 ++
scribo/src/debug/show_groups_bboxes.cc | 91 +++
.../src/debug/show_info_median_inter_characters.cc | 12 +-
scribo/src/debug/show_info_x_height.cc | 12 +-
scribo/src/debug/show_links_bottom_aligned.cc | 16 +-
.../src/debug/show_links_bottom_aligned_2angles.cc | 100 +++
scribo/src/debug/show_links_center_aligned.cc | 6 +-
scribo/src/debug/show_links_several_right.cc | 90 ---
.../src/debug/show_links_several_right_overlap.cc | 6 +-
scribo/src/debug/show_links_single_down.cc | 5 +-
.../debug/show_links_single_down_left_aligned.cc | 11 +-
.../debug/show_links_single_down_right_aligned.cc | 14 +-
scribo/src/debug/show_links_single_left.cc | 5 +-
.../src/debug/show_links_single_left_dmax_ratio.cc | 5 +-
scribo/src/debug/show_links_single_right.cc | 5 +-
.../debug/show_links_single_right_dmax_ratio.cc | 5 +-
scribo/src/debug/show_links_single_up.cc | 5 +-
.../src/debug/show_links_single_up_left_aligned.cc | 15 +-
.../debug/show_links_single_up_right_aligned.cc | 15 +-
scribo/src/debug/show_links_top_aligned.cc | 18 +-
scribo/src/debug/show_links_top_aligned_2angles.cc | 100 +++
scribo/src/debug/show_paragraph_blocks.cc | 185 +++++
scribo/src/debug/show_separators.cc | 98 +++
scribo/src/debug/show_stoppers.cc | 124 +++
scribo/src/debug/show_text_lines.cc | 130 ++++
scribo/src/non_text_components.cc | 128 ++++
scribo/src/pbm_text_in_doc.cc | 16 +-
scribo/src/preprocessing/rotate.cc | 1 +
scribo/src/preprocessing/rotate_90.cc | 1 +
scribo/src/primitive/extract/Makefile.am | 28 +-
...scontinued_hlines.cc => discontinued_hlines.cc} | 0
...discontinued_lines.cc => discontinued_lines.cc} | 0
...scontinued_vlines.cc => discontinued_vlines.cc} | 0
.../src/primitive/extract/separators_nonvisible.cc | 64 ++
.../{extract_thick_hlines.cc => thick_hlines.cc} | 0
.../{extract_thick_vlines.cc => thick_vlines.cc} | 0
.../src/primitive/group/group_from_double_link.cc | 28 +-
.../group/group_from_double_several_links.cc | 25 +-
.../group/group_from_several_left_links.cc | 23 +-
.../src/primitive/group/group_from_single_link.cc | 36 +-
scribo/src/primitive/remove/Makefile.am | 23 +
scribo/src/primitive/remove/separators.cc | 63 ++
scribo/src/text_in_picture.cc | 32 +-
scribo/src/text_in_picture_neg.cc | 7 +-
scribo/src/text_recognition_in_picture.cc | 11 +-
scribo/tests/Makefile.am | 1 +
scribo/tests/convert/Makefile.am | 27 +
scribo/tests/convert/base64.cc | 89 +++
scribo/tests/filter/components_large.cc | 8 +-
scribo/tests/filter/components_small.cc | 8 +-
scribo/tests/toolchain/nepomuk/Makefile.am | 5 +-
scribo/tests/unit_test/Makefile.am | 7 +-
.../cond_tests_magickxx_qt_tesseract_tiff | 2 +
scribo/tests/unit_test/cond_tests_qt | 3 +
.../tests/unit_test/cond_tests_qt_tesseract_tiff | 2 +-
scribo/tests/unit_test/unit-tests.mk | 114 +++-
202 files changed, 11626 insertions(+), 3338 deletions(-)
create mode 100644 milena/mln/fun/v2v/rgb_to_luma.hh
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/ocr_options.cc
create mode 100644 scribo/demo/viewer/ocr_options.hh
create mode 100644 scribo/demo/viewer/ocr_options.ui
create mode 100644 scribo/demo/viewer/preprocessing_options.cc
create mode 100644 scribo/demo/viewer/preprocessing_options.hh
create mode 100644 scribo/demo/viewer/preprocessing_options.ui
create mode 100644 scribo/demo/viewer/segmentation_options.cc
create mode 100644 scribo/demo/viewer/segmentation_options.hh
create mode 100644 scribo/demo/viewer/segmentation_options.ui
delete mode 100644 scribo/demo/viewer/toolchain_options.cc
delete mode 100644 scribo/demo/viewer/toolchain_options.hh
delete mode 100644 scribo/demo/viewer/toolchain_options.ui
create mode 100644 scribo/demo/viewer/viewer.qrc
create mode 100644 scribo/scribo/convert/from_base64.hh
create mode 100644 scribo/scribo/convert/to_base64.hh
create mode 100644 scribo/scribo/core/concept/serializable.hh
create mode 100644 scribo/scribo/core/concept/serialize_visitor.hh
create mode 100644 scribo/scribo/core/internal/doc_serializer.hh
create mode 100644 scribo/scribo/debug/bboxes_image.hh
create mode 100644 scribo/scribo/debug/linked_bboxes_image.hh
create mode 100644 scribo/scribo/debug/links_image.hh
create mode 100644 scribo/scribo/debug/logger.hh
delete mode 100644 scribo/scribo/debug/save_bboxes_image.hh
delete mode 100644 scribo/scribo/debug/save_linked_bboxes_image.hh
delete mode 100644 scribo/scribo/debug/several_links_decision_image.hh
create mode 100644 scribo/scribo/filter/object_links_aligned.hh
create mode 100644 scribo/scribo/fun/v2v/highlight.hh
create mode 100644 scribo/scribo/io/img/internal/debug_img_visitor.hh
create mode 100644 scribo/scribo/io/img/internal/draw_edges.hh
create mode 100644 scribo/scribo/io/img/internal/full_img_visitor.hh
create mode 100644 scribo/scribo/io/img/internal/non_text_img_visitor.hh
create mode 100644 scribo/scribo/io/img/internal/text_img_visitor.hh
create mode 100644 scribo/scribo/io/img/save.hh
create mode 100644 scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
create mode 100644 scribo/scribo/io/xml/internal/full_xml_visitor.hh
create mode 100644 scribo/scribo/io/xml/internal/page_xml_visitor.hh
create mode 100644 scribo/scribo/io/xml/internal/print_box_coords.hh
create mode 100644 scribo/scribo/io/xml/internal/print_image_coords.hh
create mode 100644 scribo/scribo/io/xml/internal/print_page_preambule.hh
create mode 100644 scribo/scribo/io/xml/load.hh
create mode 100644 scribo/scribo/make/text_blocks_image.hh
create mode 100644 scribo/scribo/make/text_components_image.hh
delete mode 100644 scribo/scribo/primitive/extract/elements.hh
create mode 100644 scribo/scribo/primitive/extract/internal/union.hh
create mode 100644 scribo/scribo/primitive/extract/non_text.hh
create mode 100644 scribo/scribo/primitive/extract/non_text_kmean.hh
create mode 100644 scribo/scribo/primitive/link/internal/link_single_dmax_ratio_aligned_base.hh
create mode 100644 scribo/scribo/primitive/link/with_single_left_link_dmax_ratio_aligned.hh
create mode 100644 scribo/src/debug/non_text_mask.cc
create mode 100644 scribo/src/debug/show_components_bboxes.cc
create mode 100644 scribo/src/debug/show_groups_bboxes.cc
create mode 100644 scribo/src/debug/show_links_bottom_aligned_2angles.cc
delete mode 100644 scribo/src/debug/show_links_several_right.cc
create mode 100644 scribo/src/debug/show_links_top_aligned_2angles.cc
create mode 100644 scribo/src/debug/show_paragraph_blocks.cc
create mode 100644 scribo/src/debug/show_separators.cc
create mode 100644 scribo/src/debug/show_stoppers.cc
create mode 100644 scribo/src/debug/show_text_lines.cc
create mode 100644 scribo/src/non_text_components.cc
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%)
create mode 100644 scribo/src/primitive/extract/separators_nonvisible.cc
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%)
create mode 100644 scribo/src/primitive/remove/Makefile.am
create mode 100644 scribo/src/primitive/remove/separators.cc
create mode 100644 scribo/tests/convert/Makefile.am
create mode 100644 scribo/tests/convert/base64.cc
create mode 100644 scribo/tests/unit_test/cond_tests_magickxx_qt_tesseract_tiff
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
* scribo/debug/logger.hh: New.
* scribo/toolchain/internal/content_in_doc_functor.hh,
* scribo/toolchain/internal/text_in_doc_functor.hh,
* scribo/toolchain/nepomuk/text_extraction.hh,
* scribo/toolchain/text_in_doc.hh,
* src/content_in_doc.cc,
* src/pbm_text_in_doc.cc,
* src/primitive/extract/separators_nonvisible.cc Make use of that
class for saving debug images.
---
scribo/ChangeLog | 15 ++
scribo/scribo/toolchain/content_in_doc.hh | 10 +-
.../toolchain/internal/content_in_doc_functor.hh | 202 ++++++++++++-------
.../toolchain/internal/text_in_doc_functor.hh | 107 ++++++-----
scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +-
scribo/scribo/toolchain/text_in_doc.hh | 11 +-
scribo/src/content_in_doc.cc | 21 +--
scribo/src/pbm_text_in_doc.cc | 16 +-
.../src/primitive/extract/separators_nonvisible.cc | 8 +-
9 files changed, 234 insertions(+), 165 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 50c49e7..bd7b036 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -4,6 +4,21 @@
* scribo/debug/logger.hh: New.
+ * scribo/toolchain/internal/content_in_doc_functor.hh,
+ * scribo/toolchain/internal/text_in_doc_functor.hh,
+ * scribo/toolchain/nepomuk/text_extraction.hh,
+ * scribo/toolchain/text_in_doc.hh,
+ * src/content_in_doc.cc,
+ * src/pbm_text_in_doc.cc,
+ * src/primitive/extract/separators_nonvisible.cc Make use of that
+ class for saving debug images.
+
+2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Introduce a logger class.
+
+ * scribo/debug/logger.hh: New.
+
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Introduce new anchors.
diff --git a/scribo/scribo/toolchain/content_in_doc.hh b/scribo/scribo/toolchain/content_in_doc.hh
index f2938d9..4469afa 100644
--- a/scribo/scribo/toolchain/content_in_doc.hh
+++ b/scribo/scribo/toolchain/content_in_doc.hh
@@ -45,10 +45,10 @@ namespace scribo
document<mln_ch_value(I, def::lbl_type)>
content_in_doc(const Image<I>& input, const Image<J>& input_preproc,
bool denoise,
- const std::string& language = std::string("eng"),
bool find_line_seps = true,
bool find_whitespace_seps = true,
- bool debug = false);
+ bool enable_ocr = true,
+ const std::string& language = std::string("eng"));
# ifndef MLN_INCLUDE_ONLY
@@ -58,10 +58,10 @@ namespace scribo
document<mln_ch_value(I, def::lbl_type)>
content_in_doc(const Image<I>& input, const Image<J>& input_preproc,
bool denoise,
- const std::string& language = std::string("eng"),
bool find_line_seps = true,
bool find_whitespace_seps = true,
- bool debug = false)
+ bool enable_ocr = true,
+ const std::string& language = std::string("eng"))
{
mln_precondition(input.is_valid());
mln_precondition(input_preproc.is_valid());
@@ -70,8 +70,8 @@ namespace scribo
f.enable_denoising = denoise;
f.enable_line_seps = find_line_seps;
f.enable_whitespace_seps = find_whitespace_seps;
- f.enable_debug = debug;
f.ocr_language = language;
+ f.enable_ocr = enable_ocr;
document<mln_ch_value(I, def::lbl_type)> doc = f(input, input_preproc);
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index 3e6668f..624a54e 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -27,8 +27,6 @@
#ifndef SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
# define SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
-# include <mln/io/ppm/save.hh>
-
# include <scribo/core/def/lbl_type.hh>
# include <scribo/core/document.hh>
# include <scribo/core/line_set.hh>
@@ -37,6 +35,8 @@
# include <scribo/primitive/extract/non_text.hh>
# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/extract/separators.hh>
+# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/horizontal_separators.hh>
# include <scribo/primitive/extract/separators_nonvisible.hh>
# include <scribo/primitive/identify.hh>
@@ -62,8 +62,9 @@
# include <scribo/make/debug_filename.hh>
-# include <scribo/debug/save_bboxes_image.hh>
-# include <scribo/debug/save_linked_bboxes_image.hh>
+# include <scribo/debug/decision_image.hh>
+# include <scribo/debug/bboxes_image.hh>
+# include <scribo/debug/linked_bboxes_image.hh>
# include <scribo/debug/bboxes_enlarged_image.hh>
# include <scribo/debug/mean_and_base_lines_image.hh>
# include <scribo/debug/looks_like_a_text_line_image.hh>
@@ -87,7 +88,7 @@ namespace scribo
struct content_in_doc_functor
: public Toolchain_Functor
{
- typedef value::label<30> V;
+ typedef scribo::def::lbl_type V;
typedef mln_ch_value(I,V) L;
content_in_doc_functor(const char *doc_filename);
@@ -112,7 +113,6 @@ namespace scribo
bool enable_line_seps;
bool enable_whitespace_seps;
bool enable_ocr;
- bool enable_debug;
bool save_doc_as_xml;
scribo::io::xml::Format xml_format;
@@ -138,7 +138,6 @@ namespace scribo
enable_line_seps(true),
enable_whitespace_seps(true),
enable_ocr(true),
- enable_debug(false),
save_doc_as_xml(false),
xml_format(scribo::io::xml::PageExtended),
ocr_language("eng"),
@@ -209,21 +208,30 @@ namespace scribo
on_progress();
}
- if (enable_debug)
+
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ if (enable_whitespace_seps)
+ debug::logger().log_image(debug::AuxiliaryResults,
+ whitespaces, "whitespaces");
+
+ // Debug
+ if (enable_line_seps)
{
- if (enable_whitespace_seps)
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ doc.vline_seps(),
+ "vseparators");
- if (enable_line_seps)
- {
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ doc.hline_seps(),
+ "hseparators");
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
- }
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned,
+ "input_wo_separators");
}
+# endif // ! SCRIBO_NDEBUG
+
// Denoise
if (enable_denoising)
@@ -232,9 +240,11 @@ namespace scribo
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
- if (enable_debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "denoised");
+# endif // ! SCRIBO_NDEBUG
on_progress();
}
@@ -244,7 +254,8 @@ namespace scribo
V ncomponents;
component_set<L>
- components = scribo::primitive::extract::components(input_cleaned, c8(),
+ components = scribo::primitive::extract::components(input_cleaned,
+ c8(),
ncomponents);
on_progress();
@@ -258,9 +269,12 @@ namespace scribo
doc.set_whitespace_separators(whitespaces);
}
- if (enable_debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ debug::logger().log_image(debug::AuxiliaryResults,
+ components.separators(),
+ "all_separators");
+# endif // ! SCRIBO_NDEBUG
on_new_progress_label("Filtering components");
@@ -274,24 +288,34 @@ namespace scribo
on_new_progress_label("Linking objects...");
object_links<L> left_link
- = primitive::link::with_single_left_link_dmax_ratio(components,
- primitive::link::internal::dmax_width_and_height(1),
- anchor::MassCenter);
- object_links<L> right_link
- = primitive::link::with_single_right_link_dmax_ratio(components,
- primitive::link::internal::dmax_width_and_height(1),
- anchor::MassCenter);
+ = primitive::link::with_single_left_link_dmax_ratio(
+ components,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
- if (enable_debug)
+ object_links<L> right_link
+ = primitive::link::with_single_right_link_dmax_ratio(
+ components,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
+
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- debug::save_linked_bboxes_image(processed_image, left_link, right_link,
- literal::blue,
- literal::cyan,
- literal::yellow,
- literal::green,
- anchor::MassCenter,
- scribo::make::debug_filename("object_links.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ debug::linked_bboxes_image(processed_image,
+ left_link,
+ right_link,
+ literal::blue,
+ literal::cyan,
+ literal::yellow,
+ literal::green,
+ anchor::MassCenter),
+ "object_links");
}
+# endif // ! SCRIBO_NDEBUG
// Validating left and right links.
@@ -309,16 +333,20 @@ namespace scribo
= filter::object_links_bbox_h_ratio(merged_links, 2.5f);
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
mln_ch_value(I,value::rgb8)
hratio_decision_image = scribo::debug::decision_image(processed_image,
merged_links,
hratio_filtered_links,
anchor::MassCenter);
- mln::io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
+ // Debug
+ debug::logger().log_image(debug::AuxiliaryResults,
+ hratio_decision_image,
+ "hratio_links_decision_image");
}
+# endif // ! SCRIBO_NDEBUG
on_progress();
@@ -336,28 +364,35 @@ namespace scribo
//===== DEBUG =====
-
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
// Bboxes image.
- scribo::debug::save_bboxes_image(processed_image, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(processed_image, lines),
+ "step1_bboxes");
// Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_enlarged_image(processed_image, lines),
+ "step1_bboxes_enlarged");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines),
- scribo::make::debug_filename("step1_looks_like_a_text_line.ppm"));
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(processed_image, lines),
+ "step1_looks_like_a_text_line");
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines),
- scribo::make::debug_filename("step1_x_height.ppm"));
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(processed_image, lines),
+ "step1_x_height");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
@@ -366,23 +401,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines),
- scribo::make::debug_filename("step2_x_height.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(processed_image, lines),
+ "step2_x_height");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines),
- scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(processed_image, lines),
+ "step2_looks_like_a_text_line");
// Bboxes image.
- scribo::debug::save_bboxes_image(processed_image, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(processed_image, lines),
+ "step2_bboxes");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -404,20 +445,25 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image);
+ image2d<value::rgb8>
+ debug = data::convert(value::rgb8(), original_image);
for_all_lines(l, lines)
{
if (! lines(l).is_textline())
continue;
mln::draw::box(debug, lines(l).bbox(), literal::blue);
- mln::draw::line(debug, lines(l).bbox().pcenter(), lines(llinks(l)).bbox().pcenter(), literal::green);
+ mln::draw::line(debug, lines(l).bbox().pcenter(),
+ lines(llinks(l)).bbox().pcenter(), literal::green);
}
- mln::io::ppm::save(debug, scribo::make::debug_filename("links_raw.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "links_raw");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -428,22 +474,26 @@ namespace scribo
llinks = scribo::filter::line_links_x_height(llinks);
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image);
+ image2d<value::rgb8>
+ debug = data::convert(value::rgb8(), original_image);
for_all_links(i, llinks)
if (llinks(i) && llinks(i) != i)
mln::draw::line(debug, lines(i).bbox().pcenter(),
lines(llinks(i)).bbox().pcenter(), literal::red);
- mln::io::ppm::save(debug, scribo::make::debug_filename("links.ppm"));
-
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "links");
for (unsigned i = 1; i < llinks.nelements(); ++i)
llinks(i) = scribo::make::internal::find_root(llinks, i);
debug = data::convert(value::rgb8(), original_image);
- mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements());
+ mln::util::array<accu::shape::bbox<point2d> >
+ nbbox(llinks.nelements());
+
for_all_lines(i, lines)
{
if (! lines(i).is_textline())
@@ -464,8 +514,10 @@ namespace scribo
mln::draw::box(debug, b, literal::green);
}
- mln::io::ppm::save(debug, scribo::make::debug_filename("par.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "par");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -482,7 +534,7 @@ namespace scribo
// Extract other Elements
on_new_progress_label("Extracting Elements");
component_set<L>
- elements = scribo::primitive::extract::non_text(doc, original_image);
+ elements = scribo::primitive::extract::non_text(doc, 3);
on_progress();
diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
index 16e981d..62074f0 100644
--- a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
@@ -27,8 +27,6 @@
#ifndef SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
# define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
-# include <mln/io/ppm/save.hh>
-
# include <scribo/core/def/lbl_type.hh>
# include <scribo/primitive/extract/components.hh>
@@ -54,8 +52,10 @@
# include <scribo/make/debug_filename.hh>
-# include <scribo/debug/save_bboxes_image.hh>
-# include <scribo/debug/save_linked_bboxes_image.hh>
+# include <scribo/debug/logger.hh>
+# include <scribo/debug/decision_image.hh>
+# include <scribo/debug/bboxes_image.hh>
+# include <scribo/debug/linked_bboxes_image.hh>
# include <scribo/debug/bboxes_enlarged_image.hh>
# include <scribo/debug/mean_and_base_lines_image.hh>
# include <scribo/debug/looks_like_a_text_line_image.hh>
@@ -77,7 +77,7 @@ namespace scribo
struct text_in_doc_functor
: public Toolchain_Functor
{
- typedef value::label<30> V;
+ typedef scribo::def::lbl_type V;
typedef mln_ch_value(I,V) L;
text_in_doc_functor();
@@ -97,7 +97,6 @@ namespace scribo
bool enable_denoising;
bool enable_line_seps;
bool enable_whitespace_seps;
- bool enable_debug;
//============
// Parameters
@@ -118,7 +117,6 @@ namespace scribo
: enable_denoising(true),
enable_line_seps(true),
enable_whitespace_seps(true),
- enable_debug(false),
ocr_language("eng")
{
}
@@ -164,19 +162,19 @@ namespace scribo
on_progress();
}
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
if (enable_whitespace_seps)
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ whitespaces, "whitespaces");
if (enable_line_seps)
{
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ separators, "vseparators");
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "input_wo_vseparators");
}
}
@@ -187,9 +185,9 @@ namespace scribo
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
- if (enable_debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
+ if (debug::logger().is_enabled())
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "denoised");
on_progress();
}
@@ -210,9 +208,9 @@ namespace scribo
if (enable_whitespace_seps)
components.add_separators(whitespaces);
- if (enable_debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
+ if (debug::logger().is_enabled())
+ debug::logger().log_image(debug::AuxiliaryResults,
+ components.separators(), "all_separators");
on_new_progress_label("Filtering components");
@@ -234,15 +232,19 @@ namespace scribo
primitive::link::internal::dmax_width_and_height(1),
anchor::MassCenter);
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
- debug::save_linked_bboxes_image(input, left_link, right_link,
- literal::blue,
- literal::cyan,
- literal::yellow,
- literal::green,
- anchor::MassCenter,
- scribo::make::debug_filename("object_links.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ debug::linked_bboxes_image(input,
+ left_link,
+ right_link,
+ literal::blue,
+ literal::cyan,
+ literal::yellow,
+ literal::green,
+ anchor::MassCenter),
+ "object_links");
}
@@ -261,15 +263,16 @@ namespace scribo
= filter::object_links_bbox_h_ratio(merged_links, 2.5f);
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
mln_ch_value(I,value::rgb8)
hratio_decision_image = scribo::debug::decision_image(input,
merged_links,
hratio_filtered_links,
anchor::MassCenter);
- io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ hratio_decision_image,
+ "hratio_links_decision_image");
}
on_progress();
@@ -289,25 +292,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
// Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(input, lines),
+ "step1_bboxes");
// Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_enlarged_image(input, lines),
+ "step1_bboxes_enlarged");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines),
- scribo::make::debug_filename("step1_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(input, lines),
+ "step1_looks_like_a_text_line");
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines),
- scribo::make::debug_filename("step1_x_height.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(input, lines),
+ "step1_x_height");
}
//===== END OF DEBUG =====
@@ -320,27 +327,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines),
- scribo::make::debug_filename("step2_x_height.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(input, lines),
+ "step2_x_height");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines),
- scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(input, lines),
+ "step2_looks_like_a_text_line");
// Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(input, lines),
+ "step2_bboxes");
}
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str());
diff --git a/scribo/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/scribo/toolchain/nepomuk/text_extraction.hh
index 6def090..51d5ca8 100644
--- a/scribo/scribo/toolchain/nepomuk/text_extraction.hh
+++ b/scribo/scribo/toolchain/nepomuk/text_extraction.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.
//
@@ -121,8 +122,7 @@ namespace scribo
// Run document toolchain.
lines_bg = scribo::toolchain::text_in_doc(input_bin,
true,
- language.toUtf8().data(),
- false);
+ language.toUtf8().data());
// Negate document.
logical::not_inplace(input_bin);
@@ -130,8 +130,7 @@ namespace scribo
// Run document toolchain.
lines_fg = scribo::toolchain::text_in_doc(input_bin,
true,
- language.toUtf8().data(),
- false);
+ language.toUtf8().data());
}
diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh
index e6ba69e..9f20b39 100644
--- a/scribo/scribo/toolchain/text_in_doc.hh
+++ b/scribo/scribo/toolchain/text_in_doc.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.
//
@@ -47,8 +47,7 @@ namespace scribo
text_in_doc(const Image<I>& input, bool denoise,
const std::string& language = std::string("eng"),
bool find_line_seps = true,
- bool find_whitespace_seps = true,
- bool debug = false);
+ bool find_whitespace_seps = true);
# ifndef MLN_INCLUDE_ONLY
@@ -59,14 +58,12 @@ namespace scribo
text_in_doc(const Image<I>& input, bool denoise,
const std::string& language = std::string("eng"),
bool find_line_seps = true,
- bool find_whitespace_seps = true,
- bool debug = false)
+ bool find_whitespace_seps = true)
{
internal::text_in_doc_functor<I> f;
f.enable_denoising = denoise;
f.enable_line_seps = find_line_seps;
f.enable_whitespace_seps = find_whitespace_seps;
- f.enable_debug = debug;
f.ocr_language = language;
line_set<mln_ch_value(I, def::lbl_type)> lines = f(input);
diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc
index d8d4e52..81ec4fb 100644
--- a/scribo/src/content_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -40,8 +40,7 @@
#include <scribo/core/document.hh>
#include <scribo/debug/usage.hh>
-
-#include <scribo/make/debug_filename.hh>
+#include <scribo/debug/logger.hh>
#include <scribo/preprocessing/crop_without_localization.hh>
#include <scribo/preprocessing/crop.hh>
@@ -79,13 +78,12 @@ int main(int argc, char* argv[])
"input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] [language] [find_lines] [find_whitespaces] [K] [debug_dir]",
args_desc);
- bool debug = false;
-
// Enable debug output.
if (argc == 9 || argc == 13)
{
+ scribo::debug::logger().set_filename_prefix(argv[argc - 1]);
+ scribo::debug::logger().set_level(scribo::debug::All);
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
- debug = true;
}
trace::entering("main");
@@ -109,7 +107,6 @@ int main(int argc, char* argv[])
std::cout << "Using K = " << K << std::endl;
}
- image2d<bool> tmp_fg;
input_preproc = toolchain::text_in_doc_preprocess(input, false, K);
}
@@ -130,9 +127,8 @@ int main(int argc, char* argv[])
input_preproc = preprocessing::crop_without_localization(input_preproc, roi);
crop_shift = point2d(minr, minc);
- if (debug)
- mln::io::pbm::save(input_preproc,
- scribo::make::debug_filename("input_preproc_cropped.pbm"));
+ scribo::debug::logger().log_image(scribo::debug::Results, input_preproc,
+ "input_preproc_cropped.pbm");
}
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
@@ -159,7 +155,7 @@ int main(int argc, char* argv[])
<< " ocr_language = " << language
<< " | find_lines_seps = " << find_line_seps
<< " | find_whitespace_seps = " << find_whitespace_seps
- << " | debug = " << debug
+ << " | debug = " << scribo::debug::logger().is_enabled()
<< std::endl;
// Run document toolchain.
@@ -167,11 +163,12 @@ int main(int argc, char* argv[])
// Text
std::cout << "Analysing document..." << std::endl;
document<L>
- doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, language,
+ doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise,
find_line_seps, find_whitespace_seps,
- debug);
+ !language.empty(), language);
// Saving results
+ std::cout << "Saving results..." << std::endl;
scribo::io::xml::save(doc, argv[2], scribo::io::xml::PageExtended);
scribo::io::xml::save(doc, "page.xml", scribo::io::xml::Page);
scribo::io::xml::save(doc, "full.xml", scribo::io::xml::Full);
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc
index 2726ead..42b7d88 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/pbm_text_in_doc.cc
@@ -45,8 +45,6 @@
#include <scribo/debug/usage.hh>
-#include <scribo/make/debug_filename.hh>
-
#include <scribo/preprocessing/crop_without_localization.hh>
#include <scribo/io/text_boxes/save.hh>
@@ -83,13 +81,12 @@ int main(int argc, char* argv[])
"input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <language> <find_lines> <find_whitespaces> <debug_dir>",
args_desc);
- bool debug = false;
-
// Enable debug output.
if (argc == 8 || argc == 12)
{
+ scribo::debug::logger().set_filename_prefix(argv[argc - 1]);
+ scribo::debug::logger().set_level(scribo::debug::All);
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
- debug = true;
}
trace::entering("main");
@@ -116,9 +113,8 @@ int main(int argc, char* argv[])
input = preprocessing::crop_without_localization(input, roi);
crop_shift = point2d(minr, minc);
- if (debug)
- mln::io::pbm::save(input,
- scribo::make::debug_filename("input_cropped.pbm"));
+ scribo::debug::logger().log_image(scribo::debug::Results, input,
+ "input_cropped.pbm");
}
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
@@ -146,14 +142,14 @@ int main(int argc, char* argv[])
<< " ocr language = " << language
<< " | find_lines_seps = " << find_line_seps
<< " | find_whitespace_seps = " << find_whitespace_seps
- << " | debug = " << debug
+ << " | debug = " << scribo::debug::logger().is_enabled()
<< std::endl;
// Run document toolchain.
line_set<L>
lines = scribo::toolchain::text_in_doc(input, denoise,
language, find_line_seps,
- find_whitespace_seps, debug);
+ find_whitespace_seps);
scribo::document<L> doc;
doc.set_filename(argv[1]);
diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc
index d50cc73..177047c 100644
--- a/scribo/src/primitive/extract/separators_nonvisible.cc
+++ b/scribo/src/primitive/extract/separators_nonvisible.cc
@@ -34,6 +34,7 @@ const char *args_desc[][2] =
{
{ "input.pbm", "A binary image." },
{ "output.pbm", "Output image." },
+ { "enable_debug", "0 or 1 (default 0)" },
{0, 0}
};
@@ -43,10 +44,10 @@ int main(int argc, char *argv[])
using namespace mln;
using namespace scribo;
- if (argc != 3)
+ if (argc != 3 && argc != 4)
return scribo::debug::usage(argv,
"Extract non visible separators (whitespaces)",
- "input.pbm output.pbm",
+ "input.pbm output.pbm [enable_debug]",
args_desc);
trace::entering("main");
@@ -54,6 +55,9 @@ int main(int argc, char *argv[])
image2d<bool> input;
io::pbm::load(input, argv[1]);
+ if (argc > 3 && atoi(argv[3]))
+ scribo::debug::logger().set_level(scribo::debug::All);
+
io::pbm::save(primitive::extract::separators_nonvisible(input), argv[2]);
trace::exiting("main");
--
1.5.6.5
1
0
* scribo/debug/logger.hh: New.
* scribo/toolchain/internal/content_in_doc_functor.hh,
* scribo/toolchain/internal/text_in_doc_functor.hh,
* scribo/toolchain/nepomuk/text_extraction.hh,
* scribo/toolchain/text_in_doc.hh,
* src/content_in_doc.cc,
* src/pbm_text_in_doc.cc,
* src/primitive/extract/separators_nonvisible.cc Make use of that
class for saving debug images.
---
scribo/ChangeLog | 15 ++
scribo/scribo/toolchain/content_in_doc.hh | 10 +-
.../toolchain/internal/content_in_doc_functor.hh | 202 ++++++++++++-------
.../toolchain/internal/text_in_doc_functor.hh | 107 ++++++-----
scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +-
scribo/scribo/toolchain/text_in_doc.hh | 11 +-
scribo/src/content_in_doc.cc | 21 +--
scribo/src/pbm_text_in_doc.cc | 16 +-
.../src/primitive/extract/separators_nonvisible.cc | 8 +-
9 files changed, 234 insertions(+), 165 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 50c49e7..bd7b036 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -4,6 +4,21 @@
* scribo/debug/logger.hh: New.
+ * scribo/toolchain/internal/content_in_doc_functor.hh,
+ * scribo/toolchain/internal/text_in_doc_functor.hh,
+ * scribo/toolchain/nepomuk/text_extraction.hh,
+ * scribo/toolchain/text_in_doc.hh,
+ * src/content_in_doc.cc,
+ * src/pbm_text_in_doc.cc,
+ * src/primitive/extract/separators_nonvisible.cc Make use of that
+ class for saving debug images.
+
+2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Introduce a logger class.
+
+ * scribo/debug/logger.hh: New.
+
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Introduce new anchors.
diff --git a/scribo/scribo/toolchain/content_in_doc.hh b/scribo/scribo/toolchain/content_in_doc.hh
index f2938d9..4469afa 100644
--- a/scribo/scribo/toolchain/content_in_doc.hh
+++ b/scribo/scribo/toolchain/content_in_doc.hh
@@ -45,10 +45,10 @@ namespace scribo
document<mln_ch_value(I, def::lbl_type)>
content_in_doc(const Image<I>& input, const Image<J>& input_preproc,
bool denoise,
- const std::string& language = std::string("eng"),
bool find_line_seps = true,
bool find_whitespace_seps = true,
- bool debug = false);
+ bool enable_ocr = true,
+ const std::string& language = std::string("eng"));
# ifndef MLN_INCLUDE_ONLY
@@ -58,10 +58,10 @@ namespace scribo
document<mln_ch_value(I, def::lbl_type)>
content_in_doc(const Image<I>& input, const Image<J>& input_preproc,
bool denoise,
- const std::string& language = std::string("eng"),
bool find_line_seps = true,
bool find_whitespace_seps = true,
- bool debug = false)
+ bool enable_ocr = true,
+ const std::string& language = std::string("eng"))
{
mln_precondition(input.is_valid());
mln_precondition(input_preproc.is_valid());
@@ -70,8 +70,8 @@ namespace scribo
f.enable_denoising = denoise;
f.enable_line_seps = find_line_seps;
f.enable_whitespace_seps = find_whitespace_seps;
- f.enable_debug = debug;
f.ocr_language = language;
+ f.enable_ocr = enable_ocr;
document<mln_ch_value(I, def::lbl_type)> doc = f(input, input_preproc);
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index 3e6668f..624a54e 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -27,8 +27,6 @@
#ifndef SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
# define SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
-# include <mln/io/ppm/save.hh>
-
# include <scribo/core/def/lbl_type.hh>
# include <scribo/core/document.hh>
# include <scribo/core/line_set.hh>
@@ -37,6 +35,8 @@
# include <scribo/primitive/extract/non_text.hh>
# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/extract/separators.hh>
+# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/horizontal_separators.hh>
# include <scribo/primitive/extract/separators_nonvisible.hh>
# include <scribo/primitive/identify.hh>
@@ -62,8 +62,9 @@
# include <scribo/make/debug_filename.hh>
-# include <scribo/debug/save_bboxes_image.hh>
-# include <scribo/debug/save_linked_bboxes_image.hh>
+# include <scribo/debug/decision_image.hh>
+# include <scribo/debug/bboxes_image.hh>
+# include <scribo/debug/linked_bboxes_image.hh>
# include <scribo/debug/bboxes_enlarged_image.hh>
# include <scribo/debug/mean_and_base_lines_image.hh>
# include <scribo/debug/looks_like_a_text_line_image.hh>
@@ -87,7 +88,7 @@ namespace scribo
struct content_in_doc_functor
: public Toolchain_Functor
{
- typedef value::label<30> V;
+ typedef scribo::def::lbl_type V;
typedef mln_ch_value(I,V) L;
content_in_doc_functor(const char *doc_filename);
@@ -112,7 +113,6 @@ namespace scribo
bool enable_line_seps;
bool enable_whitespace_seps;
bool enable_ocr;
- bool enable_debug;
bool save_doc_as_xml;
scribo::io::xml::Format xml_format;
@@ -138,7 +138,6 @@ namespace scribo
enable_line_seps(true),
enable_whitespace_seps(true),
enable_ocr(true),
- enable_debug(false),
save_doc_as_xml(false),
xml_format(scribo::io::xml::PageExtended),
ocr_language("eng"),
@@ -209,21 +208,30 @@ namespace scribo
on_progress();
}
- if (enable_debug)
+
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ if (enable_whitespace_seps)
+ debug::logger().log_image(debug::AuxiliaryResults,
+ whitespaces, "whitespaces");
+
+ // Debug
+ if (enable_line_seps)
{
- if (enable_whitespace_seps)
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ doc.vline_seps(),
+ "vseparators");
- if (enable_line_seps)
- {
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ doc.hline_seps(),
+ "hseparators");
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
- }
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned,
+ "input_wo_separators");
}
+# endif // ! SCRIBO_NDEBUG
+
// Denoise
if (enable_denoising)
@@ -232,9 +240,11 @@ namespace scribo
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
- if (enable_debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "denoised");
+# endif // ! SCRIBO_NDEBUG
on_progress();
}
@@ -244,7 +254,8 @@ namespace scribo
V ncomponents;
component_set<L>
- components = scribo::primitive::extract::components(input_cleaned, c8(),
+ components = scribo::primitive::extract::components(input_cleaned,
+ c8(),
ncomponents);
on_progress();
@@ -258,9 +269,12 @@ namespace scribo
doc.set_whitespace_separators(whitespaces);
}
- if (enable_debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ debug::logger().log_image(debug::AuxiliaryResults,
+ components.separators(),
+ "all_separators");
+# endif // ! SCRIBO_NDEBUG
on_new_progress_label("Filtering components");
@@ -274,24 +288,34 @@ namespace scribo
on_new_progress_label("Linking objects...");
object_links<L> left_link
- = primitive::link::with_single_left_link_dmax_ratio(components,
- primitive::link::internal::dmax_width_and_height(1),
- anchor::MassCenter);
- object_links<L> right_link
- = primitive::link::with_single_right_link_dmax_ratio(components,
- primitive::link::internal::dmax_width_and_height(1),
- anchor::MassCenter);
+ = primitive::link::with_single_left_link_dmax_ratio(
+ components,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
- if (enable_debug)
+ object_links<L> right_link
+ = primitive::link::with_single_right_link_dmax_ratio(
+ components,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
+
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- debug::save_linked_bboxes_image(processed_image, left_link, right_link,
- literal::blue,
- literal::cyan,
- literal::yellow,
- literal::green,
- anchor::MassCenter,
- scribo::make::debug_filename("object_links.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ debug::linked_bboxes_image(processed_image,
+ left_link,
+ right_link,
+ literal::blue,
+ literal::cyan,
+ literal::yellow,
+ literal::green,
+ anchor::MassCenter),
+ "object_links");
}
+# endif // ! SCRIBO_NDEBUG
// Validating left and right links.
@@ -309,16 +333,20 @@ namespace scribo
= filter::object_links_bbox_h_ratio(merged_links, 2.5f);
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
mln_ch_value(I,value::rgb8)
hratio_decision_image = scribo::debug::decision_image(processed_image,
merged_links,
hratio_filtered_links,
anchor::MassCenter);
- mln::io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
+ // Debug
+ debug::logger().log_image(debug::AuxiliaryResults,
+ hratio_decision_image,
+ "hratio_links_decision_image");
}
+# endif // ! SCRIBO_NDEBUG
on_progress();
@@ -336,28 +364,35 @@ namespace scribo
//===== DEBUG =====
-
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
// Bboxes image.
- scribo::debug::save_bboxes_image(processed_image, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(processed_image, lines),
+ "step1_bboxes");
// Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_enlarged_image(processed_image, lines),
+ "step1_bboxes_enlarged");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines),
- scribo::make::debug_filename("step1_looks_like_a_text_line.ppm"));
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(processed_image, lines),
+ "step1_looks_like_a_text_line");
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines),
- scribo::make::debug_filename("step1_x_height.ppm"));
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(processed_image, lines),
+ "step1_x_height");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
@@ -366,23 +401,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines),
- scribo::make::debug_filename("step2_x_height.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(processed_image, lines),
+ "step2_x_height");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines),
- scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(processed_image, lines),
+ "step2_looks_like_a_text_line");
// Bboxes image.
- scribo::debug::save_bboxes_image(processed_image, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(processed_image, lines),
+ "step2_bboxes");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -404,20 +445,25 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image);
+ image2d<value::rgb8>
+ debug = data::convert(value::rgb8(), original_image);
for_all_lines(l, lines)
{
if (! lines(l).is_textline())
continue;
mln::draw::box(debug, lines(l).bbox(), literal::blue);
- mln::draw::line(debug, lines(l).bbox().pcenter(), lines(llinks(l)).bbox().pcenter(), literal::green);
+ mln::draw::line(debug, lines(l).bbox().pcenter(),
+ lines(llinks(l)).bbox().pcenter(), literal::green);
}
- mln::io::ppm::save(debug, scribo::make::debug_filename("links_raw.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "links_raw");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -428,22 +474,26 @@ namespace scribo
llinks = scribo::filter::line_links_x_height(llinks);
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image);
+ image2d<value::rgb8>
+ debug = data::convert(value::rgb8(), original_image);
for_all_links(i, llinks)
if (llinks(i) && llinks(i) != i)
mln::draw::line(debug, lines(i).bbox().pcenter(),
lines(llinks(i)).bbox().pcenter(), literal::red);
- mln::io::ppm::save(debug, scribo::make::debug_filename("links.ppm"));
-
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "links");
for (unsigned i = 1; i < llinks.nelements(); ++i)
llinks(i) = scribo::make::internal::find_root(llinks, i);
debug = data::convert(value::rgb8(), original_image);
- mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements());
+ mln::util::array<accu::shape::bbox<point2d> >
+ nbbox(llinks.nelements());
+
for_all_lines(i, lines)
{
if (! lines(i).is_textline())
@@ -464,8 +514,10 @@ namespace scribo
mln::draw::box(debug, b, literal::green);
}
- mln::io::ppm::save(debug, scribo::make::debug_filename("par.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "par");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -482,7 +534,7 @@ namespace scribo
// Extract other Elements
on_new_progress_label("Extracting Elements");
component_set<L>
- elements = scribo::primitive::extract::non_text(doc, original_image);
+ elements = scribo::primitive::extract::non_text(doc, 3);
on_progress();
diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
index 16e981d..62074f0 100644
--- a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
@@ -27,8 +27,6 @@
#ifndef SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
# define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
-# include <mln/io/ppm/save.hh>
-
# include <scribo/core/def/lbl_type.hh>
# include <scribo/primitive/extract/components.hh>
@@ -54,8 +52,10 @@
# include <scribo/make/debug_filename.hh>
-# include <scribo/debug/save_bboxes_image.hh>
-# include <scribo/debug/save_linked_bboxes_image.hh>
+# include <scribo/debug/logger.hh>
+# include <scribo/debug/decision_image.hh>
+# include <scribo/debug/bboxes_image.hh>
+# include <scribo/debug/linked_bboxes_image.hh>
# include <scribo/debug/bboxes_enlarged_image.hh>
# include <scribo/debug/mean_and_base_lines_image.hh>
# include <scribo/debug/looks_like_a_text_line_image.hh>
@@ -77,7 +77,7 @@ namespace scribo
struct text_in_doc_functor
: public Toolchain_Functor
{
- typedef value::label<30> V;
+ typedef scribo::def::lbl_type V;
typedef mln_ch_value(I,V) L;
text_in_doc_functor();
@@ -97,7 +97,6 @@ namespace scribo
bool enable_denoising;
bool enable_line_seps;
bool enable_whitespace_seps;
- bool enable_debug;
//============
// Parameters
@@ -118,7 +117,6 @@ namespace scribo
: enable_denoising(true),
enable_line_seps(true),
enable_whitespace_seps(true),
- enable_debug(false),
ocr_language("eng")
{
}
@@ -164,19 +162,19 @@ namespace scribo
on_progress();
}
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
if (enable_whitespace_seps)
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ whitespaces, "whitespaces");
if (enable_line_seps)
{
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ separators, "vseparators");
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "input_wo_vseparators");
}
}
@@ -187,9 +185,9 @@ namespace scribo
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
- if (enable_debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
+ if (debug::logger().is_enabled())
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "denoised");
on_progress();
}
@@ -210,9 +208,9 @@ namespace scribo
if (enable_whitespace_seps)
components.add_separators(whitespaces);
- if (enable_debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
+ if (debug::logger().is_enabled())
+ debug::logger().log_image(debug::AuxiliaryResults,
+ components.separators(), "all_separators");
on_new_progress_label("Filtering components");
@@ -234,15 +232,19 @@ namespace scribo
primitive::link::internal::dmax_width_and_height(1),
anchor::MassCenter);
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
- debug::save_linked_bboxes_image(input, left_link, right_link,
- literal::blue,
- literal::cyan,
- literal::yellow,
- literal::green,
- anchor::MassCenter,
- scribo::make::debug_filename("object_links.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ debug::linked_bboxes_image(input,
+ left_link,
+ right_link,
+ literal::blue,
+ literal::cyan,
+ literal::yellow,
+ literal::green,
+ anchor::MassCenter),
+ "object_links");
}
@@ -261,15 +263,16 @@ namespace scribo
= filter::object_links_bbox_h_ratio(merged_links, 2.5f);
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
mln_ch_value(I,value::rgb8)
hratio_decision_image = scribo::debug::decision_image(input,
merged_links,
hratio_filtered_links,
anchor::MassCenter);
- io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ hratio_decision_image,
+ "hratio_links_decision_image");
}
on_progress();
@@ -289,25 +292,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
// Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(input, lines),
+ "step1_bboxes");
// Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_enlarged_image(input, lines),
+ "step1_bboxes_enlarged");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines),
- scribo::make::debug_filename("step1_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(input, lines),
+ "step1_looks_like_a_text_line");
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines),
- scribo::make::debug_filename("step1_x_height.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(input, lines),
+ "step1_x_height");
}
//===== END OF DEBUG =====
@@ -320,27 +327,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines),
- scribo::make::debug_filename("step2_x_height.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(input, lines),
+ "step2_x_height");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines),
- scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(input, lines),
+ "step2_looks_like_a_text_line");
// Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(input, lines),
+ "step2_bboxes");
}
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str());
diff --git a/scribo/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/scribo/toolchain/nepomuk/text_extraction.hh
index 6def090..51d5ca8 100644
--- a/scribo/scribo/toolchain/nepomuk/text_extraction.hh
+++ b/scribo/scribo/toolchain/nepomuk/text_extraction.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.
//
@@ -121,8 +122,7 @@ namespace scribo
// Run document toolchain.
lines_bg = scribo::toolchain::text_in_doc(input_bin,
true,
- language.toUtf8().data(),
- false);
+ language.toUtf8().data());
// Negate document.
logical::not_inplace(input_bin);
@@ -130,8 +130,7 @@ namespace scribo
// Run document toolchain.
lines_fg = scribo::toolchain::text_in_doc(input_bin,
true,
- language.toUtf8().data(),
- false);
+ language.toUtf8().data());
}
diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh
index e6ba69e..9f20b39 100644
--- a/scribo/scribo/toolchain/text_in_doc.hh
+++ b/scribo/scribo/toolchain/text_in_doc.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.
//
@@ -47,8 +47,7 @@ namespace scribo
text_in_doc(const Image<I>& input, bool denoise,
const std::string& language = std::string("eng"),
bool find_line_seps = true,
- bool find_whitespace_seps = true,
- bool debug = false);
+ bool find_whitespace_seps = true);
# ifndef MLN_INCLUDE_ONLY
@@ -59,14 +58,12 @@ namespace scribo
text_in_doc(const Image<I>& input, bool denoise,
const std::string& language = std::string("eng"),
bool find_line_seps = true,
- bool find_whitespace_seps = true,
- bool debug = false)
+ bool find_whitespace_seps = true)
{
internal::text_in_doc_functor<I> f;
f.enable_denoising = denoise;
f.enable_line_seps = find_line_seps;
f.enable_whitespace_seps = find_whitespace_seps;
- f.enable_debug = debug;
f.ocr_language = language;
line_set<mln_ch_value(I, def::lbl_type)> lines = f(input);
diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc
index d8d4e52..81ec4fb 100644
--- a/scribo/src/content_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -40,8 +40,7 @@
#include <scribo/core/document.hh>
#include <scribo/debug/usage.hh>
-
-#include <scribo/make/debug_filename.hh>
+#include <scribo/debug/logger.hh>
#include <scribo/preprocessing/crop_without_localization.hh>
#include <scribo/preprocessing/crop.hh>
@@ -79,13 +78,12 @@ int main(int argc, char* argv[])
"input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] [language] [find_lines] [find_whitespaces] [K] [debug_dir]",
args_desc);
- bool debug = false;
-
// Enable debug output.
if (argc == 9 || argc == 13)
{
+ scribo::debug::logger().set_filename_prefix(argv[argc - 1]);
+ scribo::debug::logger().set_level(scribo::debug::All);
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
- debug = true;
}
trace::entering("main");
@@ -109,7 +107,6 @@ int main(int argc, char* argv[])
std::cout << "Using K = " << K << std::endl;
}
- image2d<bool> tmp_fg;
input_preproc = toolchain::text_in_doc_preprocess(input, false, K);
}
@@ -130,9 +127,8 @@ int main(int argc, char* argv[])
input_preproc = preprocessing::crop_without_localization(input_preproc, roi);
crop_shift = point2d(minr, minc);
- if (debug)
- mln::io::pbm::save(input_preproc,
- scribo::make::debug_filename("input_preproc_cropped.pbm"));
+ scribo::debug::logger().log_image(scribo::debug::Results, input_preproc,
+ "input_preproc_cropped.pbm");
}
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
@@ -159,7 +155,7 @@ int main(int argc, char* argv[])
<< " ocr_language = " << language
<< " | find_lines_seps = " << find_line_seps
<< " | find_whitespace_seps = " << find_whitespace_seps
- << " | debug = " << debug
+ << " | debug = " << scribo::debug::logger().is_enabled()
<< std::endl;
// Run document toolchain.
@@ -167,11 +163,12 @@ int main(int argc, char* argv[])
// Text
std::cout << "Analysing document..." << std::endl;
document<L>
- doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, language,
+ doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise,
find_line_seps, find_whitespace_seps,
- debug);
+ !language.empty(), language);
// Saving results
+ std::cout << "Saving results..." << std::endl;
scribo::io::xml::save(doc, argv[2], scribo::io::xml::PageExtended);
scribo::io::xml::save(doc, "page.xml", scribo::io::xml::Page);
scribo::io::xml::save(doc, "full.xml", scribo::io::xml::Full);
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc
index 2726ead..42b7d88 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/pbm_text_in_doc.cc
@@ -45,8 +45,6 @@
#include <scribo/debug/usage.hh>
-#include <scribo/make/debug_filename.hh>
-
#include <scribo/preprocessing/crop_without_localization.hh>
#include <scribo/io/text_boxes/save.hh>
@@ -83,13 +81,12 @@ int main(int argc, char* argv[])
"input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <language> <find_lines> <find_whitespaces> <debug_dir>",
args_desc);
- bool debug = false;
-
// Enable debug output.
if (argc == 8 || argc == 12)
{
+ scribo::debug::logger().set_filename_prefix(argv[argc - 1]);
+ scribo::debug::logger().set_level(scribo::debug::All);
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
- debug = true;
}
trace::entering("main");
@@ -116,9 +113,8 @@ int main(int argc, char* argv[])
input = preprocessing::crop_without_localization(input, roi);
crop_shift = point2d(minr, minc);
- if (debug)
- mln::io::pbm::save(input,
- scribo::make::debug_filename("input_cropped.pbm"));
+ scribo::debug::logger().log_image(scribo::debug::Results, input,
+ "input_cropped.pbm");
}
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
@@ -146,14 +142,14 @@ int main(int argc, char* argv[])
<< " ocr language = " << language
<< " | find_lines_seps = " << find_line_seps
<< " | find_whitespace_seps = " << find_whitespace_seps
- << " | debug = " << debug
+ << " | debug = " << scribo::debug::logger().is_enabled()
<< std::endl;
// Run document toolchain.
line_set<L>
lines = scribo::toolchain::text_in_doc(input, denoise,
language, find_line_seps,
- find_whitespace_seps, debug);
+ find_whitespace_seps);
scribo::document<L> doc;
doc.set_filename(argv[1]);
diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc
index d50cc73..177047c 100644
--- a/scribo/src/primitive/extract/separators_nonvisible.cc
+++ b/scribo/src/primitive/extract/separators_nonvisible.cc
@@ -34,6 +34,7 @@ const char *args_desc[][2] =
{
{ "input.pbm", "A binary image." },
{ "output.pbm", "Output image." },
+ { "enable_debug", "0 or 1 (default 0)" },
{0, 0}
};
@@ -43,10 +44,10 @@ int main(int argc, char *argv[])
using namespace mln;
using namespace scribo;
- if (argc != 3)
+ if (argc != 3 && argc != 4)
return scribo::debug::usage(argv,
"Extract non visible separators (whitespaces)",
- "input.pbm output.pbm",
+ "input.pbm output.pbm [enable_debug]",
args_desc);
trace::entering("main");
@@ -54,6 +55,9 @@ int main(int argc, char *argv[])
image2d<bool> input;
io::pbm::load(input, argv[1]);
+ if (argc > 3 && atoi(argv[3]))
+ scribo::debug::logger().set_level(scribo::debug::All);
+
io::pbm::save(primitive::extract::separators_nonvisible(input), argv[2]);
trace::exiting("main");
--
1.5.6.5
1
0
* scribo/debug/logger.hh: New.
* scribo/toolchain/internal/content_in_doc_functor.hh,
* scribo/toolchain/internal/text_in_doc_functor.hh,
* scribo/toolchain/nepomuk/text_extraction.hh,
* scribo/toolchain/text_in_doc.hh,
* src/content_in_doc.cc,
* src/pbm_text_in_doc.cc,
* src/primitive/extract/separators_nonvisible.cc Make use of that
class for saving debug images.
---
scribo/ChangeLog | 15 ++
scribo/scribo/toolchain/content_in_doc.hh | 10 +-
.../toolchain/internal/content_in_doc_functor.hh | 202 ++++++++++++-------
.../toolchain/internal/text_in_doc_functor.hh | 107 ++++++-----
scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +-
scribo/scribo/toolchain/text_in_doc.hh | 11 +-
scribo/src/content_in_doc.cc | 21 +--
scribo/src/pbm_text_in_doc.cc | 16 +-
.../src/primitive/extract/separators_nonvisible.cc | 8 +-
9 files changed, 234 insertions(+), 165 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a377ba0..1e9b57e 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -4,6 +4,21 @@
* scribo/debug/logger.hh: New.
+ * scribo/toolchain/internal/content_in_doc_functor.hh,
+ * scribo/toolchain/internal/text_in_doc_functor.hh,
+ * scribo/toolchain/nepomuk/text_extraction.hh,
+ * scribo/toolchain/text_in_doc.hh,
+ * src/content_in_doc.cc,
+ * src/pbm_text_in_doc.cc,
+ * src/primitive/extract/separators_nonvisible.cc Make use of that
+ class for saving debug images.
+
+2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Introduce a logger class.
+
+ * scribo/debug/logger.hh: New.
+
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Introduce new anchors.
diff --git a/scribo/scribo/toolchain/content_in_doc.hh b/scribo/scribo/toolchain/content_in_doc.hh
index f2938d9..4469afa 100644
--- a/scribo/scribo/toolchain/content_in_doc.hh
+++ b/scribo/scribo/toolchain/content_in_doc.hh
@@ -45,10 +45,10 @@ namespace scribo
document<mln_ch_value(I, def::lbl_type)>
content_in_doc(const Image<I>& input, const Image<J>& input_preproc,
bool denoise,
- const std::string& language = std::string("eng"),
bool find_line_seps = true,
bool find_whitespace_seps = true,
- bool debug = false);
+ bool enable_ocr = true,
+ const std::string& language = std::string("eng"));
# ifndef MLN_INCLUDE_ONLY
@@ -58,10 +58,10 @@ namespace scribo
document<mln_ch_value(I, def::lbl_type)>
content_in_doc(const Image<I>& input, const Image<J>& input_preproc,
bool denoise,
- const std::string& language = std::string("eng"),
bool find_line_seps = true,
bool find_whitespace_seps = true,
- bool debug = false)
+ bool enable_ocr = true,
+ const std::string& language = std::string("eng"))
{
mln_precondition(input.is_valid());
mln_precondition(input_preproc.is_valid());
@@ -70,8 +70,8 @@ namespace scribo
f.enable_denoising = denoise;
f.enable_line_seps = find_line_seps;
f.enable_whitespace_seps = find_whitespace_seps;
- f.enable_debug = debug;
f.ocr_language = language;
+ f.enable_ocr = enable_ocr;
document<mln_ch_value(I, def::lbl_type)> doc = f(input, input_preproc);
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
index 3e6668f..624a54e 100644
--- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -27,8 +27,6 @@
#ifndef SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
# define SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
-# include <mln/io/ppm/save.hh>
-
# include <scribo/core/def/lbl_type.hh>
# include <scribo/core/document.hh>
# include <scribo/core/line_set.hh>
@@ -37,6 +35,8 @@
# include <scribo/primitive/extract/non_text.hh>
# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/extract/separators.hh>
+# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/horizontal_separators.hh>
# include <scribo/primitive/extract/separators_nonvisible.hh>
# include <scribo/primitive/identify.hh>
@@ -62,8 +62,9 @@
# include <scribo/make/debug_filename.hh>
-# include <scribo/debug/save_bboxes_image.hh>
-# include <scribo/debug/save_linked_bboxes_image.hh>
+# include <scribo/debug/decision_image.hh>
+# include <scribo/debug/bboxes_image.hh>
+# include <scribo/debug/linked_bboxes_image.hh>
# include <scribo/debug/bboxes_enlarged_image.hh>
# include <scribo/debug/mean_and_base_lines_image.hh>
# include <scribo/debug/looks_like_a_text_line_image.hh>
@@ -87,7 +88,7 @@ namespace scribo
struct content_in_doc_functor
: public Toolchain_Functor
{
- typedef value::label<30> V;
+ typedef scribo::def::lbl_type V;
typedef mln_ch_value(I,V) L;
content_in_doc_functor(const char *doc_filename);
@@ -112,7 +113,6 @@ namespace scribo
bool enable_line_seps;
bool enable_whitespace_seps;
bool enable_ocr;
- bool enable_debug;
bool save_doc_as_xml;
scribo::io::xml::Format xml_format;
@@ -138,7 +138,6 @@ namespace scribo
enable_line_seps(true),
enable_whitespace_seps(true),
enable_ocr(true),
- enable_debug(false),
save_doc_as_xml(false),
xml_format(scribo::io::xml::PageExtended),
ocr_language("eng"),
@@ -209,21 +208,30 @@ namespace scribo
on_progress();
}
- if (enable_debug)
+
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ if (enable_whitespace_seps)
+ debug::logger().log_image(debug::AuxiliaryResults,
+ whitespaces, "whitespaces");
+
+ // Debug
+ if (enable_line_seps)
{
- if (enable_whitespace_seps)
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ doc.vline_seps(),
+ "vseparators");
- if (enable_line_seps)
- {
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ doc.hline_seps(),
+ "hseparators");
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
- }
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned,
+ "input_wo_separators");
}
+# endif // ! SCRIBO_NDEBUG
+
// Denoise
if (enable_denoising)
@@ -232,9 +240,11 @@ namespace scribo
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
- if (enable_debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "denoised");
+# endif // ! SCRIBO_NDEBUG
on_progress();
}
@@ -244,7 +254,8 @@ namespace scribo
V ncomponents;
component_set<L>
- components = scribo::primitive::extract::components(input_cleaned, c8(),
+ components = scribo::primitive::extract::components(input_cleaned,
+ c8(),
ncomponents);
on_progress();
@@ -258,9 +269,12 @@ namespace scribo
doc.set_whitespace_separators(whitespaces);
}
- if (enable_debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ debug::logger().log_image(debug::AuxiliaryResults,
+ components.separators(),
+ "all_separators");
+# endif // ! SCRIBO_NDEBUG
on_new_progress_label("Filtering components");
@@ -274,24 +288,34 @@ namespace scribo
on_new_progress_label("Linking objects...");
object_links<L> left_link
- = primitive::link::with_single_left_link_dmax_ratio(components,
- primitive::link::internal::dmax_width_and_height(1),
- anchor::MassCenter);
- object_links<L> right_link
- = primitive::link::with_single_right_link_dmax_ratio(components,
- primitive::link::internal::dmax_width_and_height(1),
- anchor::MassCenter);
+ = primitive::link::with_single_left_link_dmax_ratio(
+ components,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
- if (enable_debug)
+ object_links<L> right_link
+ = primitive::link::with_single_right_link_dmax_ratio(
+ components,
+ primitive::link::internal::dmax_width_and_height(1),
+ anchor::MassCenter);
+
+ // Debug
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- debug::save_linked_bboxes_image(processed_image, left_link, right_link,
- literal::blue,
- literal::cyan,
- literal::yellow,
- literal::green,
- anchor::MassCenter,
- scribo::make::debug_filename("object_links.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ debug::linked_bboxes_image(processed_image,
+ left_link,
+ right_link,
+ literal::blue,
+ literal::cyan,
+ literal::yellow,
+ literal::green,
+ anchor::MassCenter),
+ "object_links");
}
+# endif // ! SCRIBO_NDEBUG
// Validating left and right links.
@@ -309,16 +333,20 @@ namespace scribo
= filter::object_links_bbox_h_ratio(merged_links, 2.5f);
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
mln_ch_value(I,value::rgb8)
hratio_decision_image = scribo::debug::decision_image(processed_image,
merged_links,
hratio_filtered_links,
anchor::MassCenter);
- mln::io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
+ // Debug
+ debug::logger().log_image(debug::AuxiliaryResults,
+ hratio_decision_image,
+ "hratio_links_decision_image");
}
+# endif // ! SCRIBO_NDEBUG
on_progress();
@@ -336,28 +364,35 @@ namespace scribo
//===== DEBUG =====
-
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
// Bboxes image.
- scribo::debug::save_bboxes_image(processed_image, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(processed_image, lines),
+ "step1_bboxes");
// Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_enlarged_image(processed_image, lines),
+ "step1_bboxes_enlarged");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines),
- scribo::make::debug_filename("step1_looks_like_a_text_line.ppm"));
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(processed_image, lines),
+ "step1_looks_like_a_text_line");
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines),
- scribo::make::debug_filename("step1_x_height.ppm"));
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(processed_image, lines),
+ "step1_x_height");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
@@ -366,23 +401,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines),
- scribo::make::debug_filename("step2_x_height.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(processed_image, lines),
+ "step2_x_height");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines),
- scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(processed_image, lines),
+ "step2_looks_like_a_text_line");
// Bboxes image.
- scribo::debug::save_bboxes_image(processed_image, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
-
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(processed_image, lines),
+ "step2_bboxes");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -404,20 +445,25 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image);
+ image2d<value::rgb8>
+ debug = data::convert(value::rgb8(), original_image);
for_all_lines(l, lines)
{
if (! lines(l).is_textline())
continue;
mln::draw::box(debug, lines(l).bbox(), literal::blue);
- mln::draw::line(debug, lines(l).bbox().pcenter(), lines(llinks(l)).bbox().pcenter(), literal::green);
+ mln::draw::line(debug, lines(l).bbox().pcenter(),
+ lines(llinks(l)).bbox().pcenter(), literal::green);
}
- mln::io::ppm::save(debug, scribo::make::debug_filename("links_raw.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "links_raw");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -428,22 +474,26 @@ namespace scribo
llinks = scribo::filter::line_links_x_height(llinks);
//===== DEBUG =====
- if (enable_debug)
+# ifndef SCRIBO_NDEBUG
+ if (debug::logger().is_enabled())
{
- image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image);
+ image2d<value::rgb8>
+ debug = data::convert(value::rgb8(), original_image);
for_all_links(i, llinks)
if (llinks(i) && llinks(i) != i)
mln::draw::line(debug, lines(i).bbox().pcenter(),
lines(llinks(i)).bbox().pcenter(), literal::red);
- mln::io::ppm::save(debug, scribo::make::debug_filename("links.ppm"));
-
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "links");
for (unsigned i = 1; i < llinks.nelements(); ++i)
llinks(i) = scribo::make::internal::find_root(llinks, i);
debug = data::convert(value::rgb8(), original_image);
- mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements());
+ mln::util::array<accu::shape::bbox<point2d> >
+ nbbox(llinks.nelements());
+
for_all_lines(i, lines)
{
if (! lines(i).is_textline())
@@ -464,8 +514,10 @@ namespace scribo
mln::draw::box(debug, b, literal::green);
}
- mln::io::ppm::save(debug, scribo::make::debug_filename("par.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ debug, "par");
}
+# endif // ! SCRIBO_NDEBUG
//===== END OF DEBUG =====
on_progress();
@@ -482,7 +534,7 @@ namespace scribo
// Extract other Elements
on_new_progress_label("Extracting Elements");
component_set<L>
- elements = scribo::primitive::extract::non_text(doc, original_image);
+ elements = scribo::primitive::extract::non_text(doc, 3);
on_progress();
diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
index 16e981d..62074f0 100644
--- a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
+++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
@@ -27,8 +27,6 @@
#ifndef SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
# define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
-# include <mln/io/ppm/save.hh>
-
# include <scribo/core/def/lbl_type.hh>
# include <scribo/primitive/extract/components.hh>
@@ -54,8 +52,10 @@
# include <scribo/make/debug_filename.hh>
-# include <scribo/debug/save_bboxes_image.hh>
-# include <scribo/debug/save_linked_bboxes_image.hh>
+# include <scribo/debug/logger.hh>
+# include <scribo/debug/decision_image.hh>
+# include <scribo/debug/bboxes_image.hh>
+# include <scribo/debug/linked_bboxes_image.hh>
# include <scribo/debug/bboxes_enlarged_image.hh>
# include <scribo/debug/mean_and_base_lines_image.hh>
# include <scribo/debug/looks_like_a_text_line_image.hh>
@@ -77,7 +77,7 @@ namespace scribo
struct text_in_doc_functor
: public Toolchain_Functor
{
- typedef value::label<30> V;
+ typedef scribo::def::lbl_type V;
typedef mln_ch_value(I,V) L;
text_in_doc_functor();
@@ -97,7 +97,6 @@ namespace scribo
bool enable_denoising;
bool enable_line_seps;
bool enable_whitespace_seps;
- bool enable_debug;
//============
// Parameters
@@ -118,7 +117,6 @@ namespace scribo
: enable_denoising(true),
enable_line_seps(true),
enable_whitespace_seps(true),
- enable_debug(false),
ocr_language("eng")
{
}
@@ -164,19 +162,19 @@ namespace scribo
on_progress();
}
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
if (enable_whitespace_seps)
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ whitespaces, "whitespaces");
if (enable_line_seps)
{
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ separators, "vseparators");
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "input_wo_vseparators");
}
}
@@ -187,9 +185,9 @@ namespace scribo
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
- if (enable_debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
+ if (debug::logger().is_enabled())
+ debug::logger().log_image(debug::AuxiliaryResults,
+ input_cleaned, "denoised");
on_progress();
}
@@ -210,9 +208,9 @@ namespace scribo
if (enable_whitespace_seps)
components.add_separators(whitespaces);
- if (enable_debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
+ if (debug::logger().is_enabled())
+ debug::logger().log_image(debug::AuxiliaryResults,
+ components.separators(), "all_separators");
on_new_progress_label("Filtering components");
@@ -234,15 +232,19 @@ namespace scribo
primitive::link::internal::dmax_width_and_height(1),
anchor::MassCenter);
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
- debug::save_linked_bboxes_image(input, left_link, right_link,
- literal::blue,
- literal::cyan,
- literal::yellow,
- literal::green,
- anchor::MassCenter,
- scribo::make::debug_filename("object_links.ppm"));
+ debug::logger().log_image(
+ debug::AuxiliaryResults,
+ debug::linked_bboxes_image(input,
+ left_link,
+ right_link,
+ literal::blue,
+ literal::cyan,
+ literal::yellow,
+ literal::green,
+ anchor::MassCenter),
+ "object_links");
}
@@ -261,15 +263,16 @@ namespace scribo
= filter::object_links_bbox_h_ratio(merged_links, 2.5f);
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
mln_ch_value(I,value::rgb8)
hratio_decision_image = scribo::debug::decision_image(input,
merged_links,
hratio_filtered_links,
anchor::MassCenter);
- io::ppm::save(hratio_decision_image,
- scribo::make::debug_filename("hratio_links_decision_image.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ hratio_decision_image,
+ "hratio_links_decision_image");
}
on_progress();
@@ -289,25 +292,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
// Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(input, lines),
+ "step1_bboxes");
// Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_enlarged_image(input, lines),
+ "step1_bboxes_enlarged");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines),
- scribo::make::debug_filename("step1_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(input, lines),
+ "step1_looks_like_a_text_line");
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines),
- scribo::make::debug_filename("step1_x_height.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(input, lines),
+ "step1_x_height");
}
//===== END OF DEBUG =====
@@ -320,27 +327,29 @@ namespace scribo
//===== DEBUG =====
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
// mean and base lines.
- mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines),
- scribo::make::debug_filename("step2_x_height.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::mean_and_base_lines_image(input, lines),
+ "step2_x_height");
// Looks like a text line
- mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines),
- scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::looks_like_a_text_line_image(input, lines),
+ "step2_looks_like_a_text_line");
// Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
+ debug::logger().log_image(debug::AuxiliaryResults,
+ scribo::debug::bboxes_image(input, lines),
+ "step2_bboxes");
}
- if (enable_debug)
+ if (debug::logger().is_enabled())
{
std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str());
diff --git a/scribo/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/scribo/toolchain/nepomuk/text_extraction.hh
index 0447cef..2534ce8 100644
--- a/scribo/scribo/toolchain/nepomuk/text_extraction.hh
+++ b/scribo/scribo/toolchain/nepomuk/text_extraction.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.
//
@@ -121,8 +122,7 @@ namespace scribo
// Run document toolchain.
lines_bg = scribo::toolchain::text_in_doc(input_bin,
true,
- language.toUtf8().data(),
- false);
+ language.toUtf8().data());
// Negate document.
logical::not_inplace(input_bin);
@@ -130,8 +130,7 @@ namespace scribo
// Run document toolchain.
lines_fg = scribo::toolchain::text_in_doc(input_bin,
true,
- language.toUtf8().data(),
- false);
+ language.toUtf8().data());
}
diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh
index e6ba69e..9f20b39 100644
--- a/scribo/scribo/toolchain/text_in_doc.hh
+++ b/scribo/scribo/toolchain/text_in_doc.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.
//
@@ -47,8 +47,7 @@ namespace scribo
text_in_doc(const Image<I>& input, bool denoise,
const std::string& language = std::string("eng"),
bool find_line_seps = true,
- bool find_whitespace_seps = true,
- bool debug = false);
+ bool find_whitespace_seps = true);
# ifndef MLN_INCLUDE_ONLY
@@ -59,14 +58,12 @@ namespace scribo
text_in_doc(const Image<I>& input, bool denoise,
const std::string& language = std::string("eng"),
bool find_line_seps = true,
- bool find_whitespace_seps = true,
- bool debug = false)
+ bool find_whitespace_seps = true)
{
internal::text_in_doc_functor<I> f;
f.enable_denoising = denoise;
f.enable_line_seps = find_line_seps;
f.enable_whitespace_seps = find_whitespace_seps;
- f.enable_debug = debug;
f.ocr_language = language;
line_set<mln_ch_value(I, def::lbl_type)> lines = f(input);
diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc
index d8d4e52..81ec4fb 100644
--- a/scribo/src/content_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -40,8 +40,7 @@
#include <scribo/core/document.hh>
#include <scribo/debug/usage.hh>
-
-#include <scribo/make/debug_filename.hh>
+#include <scribo/debug/logger.hh>
#include <scribo/preprocessing/crop_without_localization.hh>
#include <scribo/preprocessing/crop.hh>
@@ -79,13 +78,12 @@ int main(int argc, char* argv[])
"input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] [language] [find_lines] [find_whitespaces] [K] [debug_dir]",
args_desc);
- bool debug = false;
-
// Enable debug output.
if (argc == 9 || argc == 13)
{
+ scribo::debug::logger().set_filename_prefix(argv[argc - 1]);
+ scribo::debug::logger().set_level(scribo::debug::All);
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
- debug = true;
}
trace::entering("main");
@@ -109,7 +107,6 @@ int main(int argc, char* argv[])
std::cout << "Using K = " << K << std::endl;
}
- image2d<bool> tmp_fg;
input_preproc = toolchain::text_in_doc_preprocess(input, false, K);
}
@@ -130,9 +127,8 @@ int main(int argc, char* argv[])
input_preproc = preprocessing::crop_without_localization(input_preproc, roi);
crop_shift = point2d(minr, minc);
- if (debug)
- mln::io::pbm::save(input_preproc,
- scribo::make::debug_filename("input_preproc_cropped.pbm"));
+ scribo::debug::logger().log_image(scribo::debug::Results, input_preproc,
+ "input_preproc_cropped.pbm");
}
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
@@ -159,7 +155,7 @@ int main(int argc, char* argv[])
<< " ocr_language = " << language
<< " | find_lines_seps = " << find_line_seps
<< " | find_whitespace_seps = " << find_whitespace_seps
- << " | debug = " << debug
+ << " | debug = " << scribo::debug::logger().is_enabled()
<< std::endl;
// Run document toolchain.
@@ -167,11 +163,12 @@ int main(int argc, char* argv[])
// Text
std::cout << "Analysing document..." << std::endl;
document<L>
- doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, language,
+ doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise,
find_line_seps, find_whitespace_seps,
- debug);
+ !language.empty(), language);
// Saving results
+ std::cout << "Saving results..." << std::endl;
scribo::io::xml::save(doc, argv[2], scribo::io::xml::PageExtended);
scribo::io::xml::save(doc, "page.xml", scribo::io::xml::Page);
scribo::io::xml::save(doc, "full.xml", scribo::io::xml::Full);
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc
index 2726ead..42b7d88 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/pbm_text_in_doc.cc
@@ -45,8 +45,6 @@
#include <scribo/debug/usage.hh>
-#include <scribo/make/debug_filename.hh>
-
#include <scribo/preprocessing/crop_without_localization.hh>
#include <scribo/io/text_boxes/save.hh>
@@ -83,13 +81,12 @@ int main(int argc, char* argv[])
"input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <language> <find_lines> <find_whitespaces> <debug_dir>",
args_desc);
- bool debug = false;
-
// Enable debug output.
if (argc == 8 || argc == 12)
{
+ scribo::debug::logger().set_filename_prefix(argv[argc - 1]);
+ scribo::debug::logger().set_level(scribo::debug::All);
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
- debug = true;
}
trace::entering("main");
@@ -116,9 +113,8 @@ int main(int argc, char* argv[])
input = preprocessing::crop_without_localization(input, roi);
crop_shift = point2d(minr, minc);
- if (debug)
- mln::io::pbm::save(input,
- scribo::make::debug_filename("input_cropped.pbm"));
+ scribo::debug::logger().log_image(scribo::debug::Results, input,
+ "input_cropped.pbm");
}
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
@@ -146,14 +142,14 @@ int main(int argc, char* argv[])
<< " ocr language = " << language
<< " | find_lines_seps = " << find_line_seps
<< " | find_whitespace_seps = " << find_whitespace_seps
- << " | debug = " << debug
+ << " | debug = " << scribo::debug::logger().is_enabled()
<< std::endl;
// Run document toolchain.
line_set<L>
lines = scribo::toolchain::text_in_doc(input, denoise,
language, find_line_seps,
- find_whitespace_seps, debug);
+ find_whitespace_seps);
scribo::document<L> doc;
doc.set_filename(argv[1]);
diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc
index d50cc73..177047c 100644
--- a/scribo/src/primitive/extract/separators_nonvisible.cc
+++ b/scribo/src/primitive/extract/separators_nonvisible.cc
@@ -34,6 +34,7 @@ const char *args_desc[][2] =
{
{ "input.pbm", "A binary image." },
{ "output.pbm", "Output image." },
+ { "enable_debug", "0 or 1 (default 0)" },
{0, 0}
};
@@ -43,10 +44,10 @@ int main(int argc, char *argv[])
using namespace mln;
using namespace scribo;
- if (argc != 3)
+ if (argc != 3 && argc != 4)
return scribo::debug::usage(argv,
"Extract non visible separators (whitespaces)",
- "input.pbm output.pbm",
+ "input.pbm output.pbm [enable_debug]",
args_desc);
trace::entering("main");
@@ -54,6 +55,9 @@ int main(int argc, char *argv[])
image2d<bool> input;
io::pbm::load(input, argv[1]);
+ if (argc > 3 && atoi(argv[3]))
+ scribo::debug::logger().set_level(scribo::debug::All);
+
io::pbm::save(primitive::extract::separators_nonvisible(input), argv[2]);
trace::exiting("main");
--
1.5.6.5
1
0
* headers.mk,
* tests/unit_test/unit-tests.mk: Here.
---
milena/ChangeLog | 7 +++++++
milena/headers.mk | 2 ++
milena/tests/unit_test/unit-tests.mk | 30 +++++++++++++++++-------------
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9afea6f..8e3a24d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Regen generated files.
+
+ * headers.mk,
+ * tests/unit_test/unit-tests.mk: Here.
+
+2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/labeling/colorize.hh: Add a missing inline.
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/headers.mk b/milena/headers.mk
index 3d897e3..bb64c9d 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -42,6 +42,7 @@ mln/accu/shape/all.hh \
mln/accu/shape/bbox.hh \
mln/accu/shape/essential.hh \
mln/accu/shape/height.hh \
+mln/accu/shape/site_list.hh \
mln/accu/shape/volume.hh \
mln/accu/site_set/all.hh \
mln/accu/site_set/essential.hh \
@@ -560,6 +561,7 @@ mln/fun/v2v/projection.hh \
mln/fun/v2v/qt_rgb_to_int_u.hh \
mln/fun/v2v/rgb8_to_rgbn.hh \
mln/fun/v2v/rgb_to_int_u.hh \
+mln/fun/v2v/rgb_to_luma.hh \
mln/fun/v2v/saturate.hh \
mln/fun/v2v/wrap.hh \
mln/fun/v2w2v/all.hh \
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index f4cfae7..2a44d75 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -7,7 +7,7 @@ if HAVE_BOOST_TUPLE
check_PROGRAMS += \
mln_accu_tuple
-mln_accu_tuple_CPPFLAGS= ${BOOST_TUPLE_CPPFLAGS} ${AM_CPPFLAGS}
+mln_accu_tuple_CPPFLAGS= ${BOOST_TUPLE_CPPFLAGS} -DHAVE_BOOST_TUPLE ${AM_CPPFLAGS}
mln_accu_tuple_LDFLAGS= ${BOOST_TUPLE_LDFLAGS} ${AM_LDFLAGS}
mln_accu_tuple_SOURCES = mln_accu_tuple.cc
endif HAVE_BOOST_TUPLE
@@ -18,10 +18,10 @@ check_PROGRAMS += \
mln_io_fits_all \
mln_io_fits_load
-mln_io_fits_all_CPPFLAGS= ${CFITSIO_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_fits_all_CPPFLAGS= ${CFITSIO_CPPFLAGS} -DHAVE_CFITSIO ${AM_CPPFLAGS}
mln_io_fits_all_LDFLAGS= ${CFITSIO_LDFLAGS} ${AM_LDFLAGS}
mln_io_fits_all_SOURCES = mln_io_fits_all.cc
-mln_io_fits_load_CPPFLAGS= ${CFITSIO_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_fits_load_CPPFLAGS= ${CFITSIO_CPPFLAGS} -DHAVE_CFITSIO ${AM_CPPFLAGS}
mln_io_fits_load_LDFLAGS= ${CFITSIO_LDFLAGS} ${AM_LDFLAGS}
mln_io_fits_load_SOURCES = mln_io_fits_load.cc
endif HAVE_CFITSIO
@@ -33,13 +33,13 @@ mln_io_dicom_all \
mln_io_dicom_load \
mln_io_dicom_get_header
-mln_io_dicom_all_CPPFLAGS= ${GDCM_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_dicom_all_CPPFLAGS= ${GDCM_CPPFLAGS} -DHAVE_GDCM ${AM_CPPFLAGS}
mln_io_dicom_all_LDFLAGS= ${GDCM_LDFLAGS} ${AM_LDFLAGS}
mln_io_dicom_all_SOURCES = mln_io_dicom_all.cc
-mln_io_dicom_load_CPPFLAGS= ${GDCM_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_dicom_load_CPPFLAGS= ${GDCM_CPPFLAGS} -DHAVE_GDCM ${AM_CPPFLAGS}
mln_io_dicom_load_LDFLAGS= ${GDCM_LDFLAGS} ${AM_LDFLAGS}
mln_io_dicom_load_SOURCES = mln_io_dicom_load.cc
-mln_io_dicom_get_header_CPPFLAGS= ${GDCM_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_dicom_get_header_CPPFLAGS= ${GDCM_CPPFLAGS} -DHAVE_GDCM ${AM_CPPFLAGS}
mln_io_dicom_get_header_LDFLAGS= ${GDCM_LDFLAGS} ${AM_LDFLAGS}
mln_io_dicom_get_header_SOURCES = mln_io_dicom_get_header.cc
endif HAVE_GDCM
@@ -51,13 +51,13 @@ mln_io_magick_all \
mln_io_magick_load \
mln_io_magick_save
-mln_io_magick_all_CPPFLAGS= ${MAGICKXX_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_magick_all_CPPFLAGS= ${MAGICKXX_CPPFLAGS} -DHAVE_MAGICKXX ${AM_CPPFLAGS}
mln_io_magick_all_LDFLAGS= ${MAGICKXX_LDFLAGS} ${AM_LDFLAGS}
mln_io_magick_all_SOURCES = mln_io_magick_all.cc
-mln_io_magick_load_CPPFLAGS= ${MAGICKXX_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_magick_load_CPPFLAGS= ${MAGICKXX_CPPFLAGS} -DHAVE_MAGICKXX ${AM_CPPFLAGS}
mln_io_magick_load_LDFLAGS= ${MAGICKXX_LDFLAGS} ${AM_LDFLAGS}
mln_io_magick_load_SOURCES = mln_io_magick_load.cc
-mln_io_magick_save_CPPFLAGS= ${MAGICKXX_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_magick_save_CPPFLAGS= ${MAGICKXX_CPPFLAGS} -DHAVE_MAGICKXX ${AM_CPPFLAGS}
mln_io_magick_save_LDFLAGS= ${MAGICKXX_LDFLAGS} ${AM_LDFLAGS}
mln_io_magick_save_SOURCES = mln_io_magick_save.cc
endif HAVE_MAGICKXX
@@ -68,10 +68,10 @@ check_PROGRAMS += \
mln_convert_to_qimage \
mln_convert_to_qimage_nocopy
-mln_convert_to_qimage_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS}
+mln_convert_to_qimage_CPPFLAGS= ${QT_CPPFLAGS} -DHAVE_QT ${AM_CPPFLAGS}
mln_convert_to_qimage_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS}
mln_convert_to_qimage_SOURCES = mln_convert_to_qimage.cc
-mln_convert_to_qimage_nocopy_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS}
+mln_convert_to_qimage_nocopy_CPPFLAGS= ${QT_CPPFLAGS} -DHAVE_QT ${AM_CPPFLAGS}
mln_convert_to_qimage_nocopy_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS}
mln_convert_to_qimage_nocopy_SOURCES = mln_convert_to_qimage_nocopy.cc
endif HAVE_QT
@@ -82,10 +82,10 @@ check_PROGRAMS += \
mln_io_tiff_all \
mln_io_tiff_load
-mln_io_tiff_all_CPPFLAGS= ${TIFF_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_tiff_all_CPPFLAGS= ${TIFF_CPPFLAGS} -DHAVE_TIFF ${AM_CPPFLAGS}
mln_io_tiff_all_LDFLAGS= ${TIFF_LDFLAGS} ${AM_LDFLAGS}
mln_io_tiff_all_SOURCES = mln_io_tiff_all.cc
-mln_io_tiff_load_CPPFLAGS= ${TIFF_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_tiff_load_CPPFLAGS= ${TIFF_CPPFLAGS} -DHAVE_TIFF ${AM_CPPFLAGS}
mln_io_tiff_load_LDFLAGS= ${TIFF_LDFLAGS} ${AM_LDFLAGS}
mln_io_tiff_load_SOURCES = mln_io_tiff_load.cc
endif HAVE_TIFF
@@ -135,6 +135,7 @@ mln_accu_shape_all \
mln_accu_shape_bbox \
mln_accu_shape_essential \
mln_accu_shape_height \
+mln_accu_shape_site_list \
mln_accu_shape_volume \
mln_accu_site_set_all \
mln_accu_site_set_essential \
@@ -674,6 +675,7 @@ mln_fun_v2v_rgb8_to_rgbn \
mln_fun_v2v_rgb_to_hsi \
mln_fun_v2v_rgb_to_hsl \
mln_fun_v2v_rgb_to_int_u \
+mln_fun_v2v_rgb_to_luma \
mln_fun_v2v_saturate \
mln_fun_v2v_wrap \
mln_fun_v2w2v_all \
@@ -1459,6 +1461,7 @@ mln_accu_shape_all_SOURCES = mln_accu_shape_all.cc
mln_accu_shape_bbox_SOURCES = mln_accu_shape_bbox.cc
mln_accu_shape_essential_SOURCES = mln_accu_shape_essential.cc
mln_accu_shape_height_SOURCES = mln_accu_shape_height.cc
+mln_accu_shape_site_list_SOURCES = mln_accu_shape_site_list.cc
mln_accu_shape_volume_SOURCES = mln_accu_shape_volume.cc
mln_accu_site_set_all_SOURCES = mln_accu_site_set_all.cc
mln_accu_site_set_essential_SOURCES = mln_accu_site_set_essential.cc
@@ -1998,6 +2001,7 @@ mln_fun_v2v_rgb8_to_rgbn_SOURCES = mln_fun_v2v_rgb8_to_rgbn.cc
mln_fun_v2v_rgb_to_hsi_SOURCES = mln_fun_v2v_rgb_to_hsi.cc
mln_fun_v2v_rgb_to_hsl_SOURCES = mln_fun_v2v_rgb_to_hsl.cc
mln_fun_v2v_rgb_to_int_u_SOURCES = mln_fun_v2v_rgb_to_int_u.cc
+mln_fun_v2v_rgb_to_luma_SOURCES = mln_fun_v2v_rgb_to_luma.cc
mln_fun_v2v_saturate_SOURCES = mln_fun_v2v_saturate.cc
mln_fun_v2v_wrap_SOURCES = mln_fun_v2v_wrap.cc
mln_fun_v2w2v_all_SOURCES = mln_fun_v2w2v_all.cc
--
1.5.6.5
1
0
* headers.mk,
* tests/unit_test/unit-tests.mk: Here.
---
milena/ChangeLog | 7 +++++++
milena/headers.mk | 2 ++
milena/tests/unit_test/unit-tests.mk | 30 +++++++++++++++++-------------
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9afea6f..8e3a24d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Regen generated files.
+
+ * headers.mk,
+ * tests/unit_test/unit-tests.mk: Here.
+
+2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/labeling/colorize.hh: Add a missing inline.
2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/headers.mk b/milena/headers.mk
index 3d897e3..bb64c9d 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -42,6 +42,7 @@ mln/accu/shape/all.hh \
mln/accu/shape/bbox.hh \
mln/accu/shape/essential.hh \
mln/accu/shape/height.hh \
+mln/accu/shape/site_list.hh \
mln/accu/shape/volume.hh \
mln/accu/site_set/all.hh \
mln/accu/site_set/essential.hh \
@@ -560,6 +561,7 @@ mln/fun/v2v/projection.hh \
mln/fun/v2v/qt_rgb_to_int_u.hh \
mln/fun/v2v/rgb8_to_rgbn.hh \
mln/fun/v2v/rgb_to_int_u.hh \
+mln/fun/v2v/rgb_to_luma.hh \
mln/fun/v2v/saturate.hh \
mln/fun/v2v/wrap.hh \
mln/fun/v2w2v/all.hh \
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index f4cfae7..2a44d75 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -7,7 +7,7 @@ if HAVE_BOOST_TUPLE
check_PROGRAMS += \
mln_accu_tuple
-mln_accu_tuple_CPPFLAGS= ${BOOST_TUPLE_CPPFLAGS} ${AM_CPPFLAGS}
+mln_accu_tuple_CPPFLAGS= ${BOOST_TUPLE_CPPFLAGS} -DHAVE_BOOST_TUPLE ${AM_CPPFLAGS}
mln_accu_tuple_LDFLAGS= ${BOOST_TUPLE_LDFLAGS} ${AM_LDFLAGS}
mln_accu_tuple_SOURCES = mln_accu_tuple.cc
endif HAVE_BOOST_TUPLE
@@ -18,10 +18,10 @@ check_PROGRAMS += \
mln_io_fits_all \
mln_io_fits_load
-mln_io_fits_all_CPPFLAGS= ${CFITSIO_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_fits_all_CPPFLAGS= ${CFITSIO_CPPFLAGS} -DHAVE_CFITSIO ${AM_CPPFLAGS}
mln_io_fits_all_LDFLAGS= ${CFITSIO_LDFLAGS} ${AM_LDFLAGS}
mln_io_fits_all_SOURCES = mln_io_fits_all.cc
-mln_io_fits_load_CPPFLAGS= ${CFITSIO_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_fits_load_CPPFLAGS= ${CFITSIO_CPPFLAGS} -DHAVE_CFITSIO ${AM_CPPFLAGS}
mln_io_fits_load_LDFLAGS= ${CFITSIO_LDFLAGS} ${AM_LDFLAGS}
mln_io_fits_load_SOURCES = mln_io_fits_load.cc
endif HAVE_CFITSIO
@@ -33,13 +33,13 @@ mln_io_dicom_all \
mln_io_dicom_load \
mln_io_dicom_get_header
-mln_io_dicom_all_CPPFLAGS= ${GDCM_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_dicom_all_CPPFLAGS= ${GDCM_CPPFLAGS} -DHAVE_GDCM ${AM_CPPFLAGS}
mln_io_dicom_all_LDFLAGS= ${GDCM_LDFLAGS} ${AM_LDFLAGS}
mln_io_dicom_all_SOURCES = mln_io_dicom_all.cc
-mln_io_dicom_load_CPPFLAGS= ${GDCM_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_dicom_load_CPPFLAGS= ${GDCM_CPPFLAGS} -DHAVE_GDCM ${AM_CPPFLAGS}
mln_io_dicom_load_LDFLAGS= ${GDCM_LDFLAGS} ${AM_LDFLAGS}
mln_io_dicom_load_SOURCES = mln_io_dicom_load.cc
-mln_io_dicom_get_header_CPPFLAGS= ${GDCM_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_dicom_get_header_CPPFLAGS= ${GDCM_CPPFLAGS} -DHAVE_GDCM ${AM_CPPFLAGS}
mln_io_dicom_get_header_LDFLAGS= ${GDCM_LDFLAGS} ${AM_LDFLAGS}
mln_io_dicom_get_header_SOURCES = mln_io_dicom_get_header.cc
endif HAVE_GDCM
@@ -51,13 +51,13 @@ mln_io_magick_all \
mln_io_magick_load \
mln_io_magick_save
-mln_io_magick_all_CPPFLAGS= ${MAGICKXX_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_magick_all_CPPFLAGS= ${MAGICKXX_CPPFLAGS} -DHAVE_MAGICKXX ${AM_CPPFLAGS}
mln_io_magick_all_LDFLAGS= ${MAGICKXX_LDFLAGS} ${AM_LDFLAGS}
mln_io_magick_all_SOURCES = mln_io_magick_all.cc
-mln_io_magick_load_CPPFLAGS= ${MAGICKXX_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_magick_load_CPPFLAGS= ${MAGICKXX_CPPFLAGS} -DHAVE_MAGICKXX ${AM_CPPFLAGS}
mln_io_magick_load_LDFLAGS= ${MAGICKXX_LDFLAGS} ${AM_LDFLAGS}
mln_io_magick_load_SOURCES = mln_io_magick_load.cc
-mln_io_magick_save_CPPFLAGS= ${MAGICKXX_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_magick_save_CPPFLAGS= ${MAGICKXX_CPPFLAGS} -DHAVE_MAGICKXX ${AM_CPPFLAGS}
mln_io_magick_save_LDFLAGS= ${MAGICKXX_LDFLAGS} ${AM_LDFLAGS}
mln_io_magick_save_SOURCES = mln_io_magick_save.cc
endif HAVE_MAGICKXX
@@ -68,10 +68,10 @@ check_PROGRAMS += \
mln_convert_to_qimage \
mln_convert_to_qimage_nocopy
-mln_convert_to_qimage_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS}
+mln_convert_to_qimage_CPPFLAGS= ${QT_CPPFLAGS} -DHAVE_QT ${AM_CPPFLAGS}
mln_convert_to_qimage_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS}
mln_convert_to_qimage_SOURCES = mln_convert_to_qimage.cc
-mln_convert_to_qimage_nocopy_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS}
+mln_convert_to_qimage_nocopy_CPPFLAGS= ${QT_CPPFLAGS} -DHAVE_QT ${AM_CPPFLAGS}
mln_convert_to_qimage_nocopy_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS}
mln_convert_to_qimage_nocopy_SOURCES = mln_convert_to_qimage_nocopy.cc
endif HAVE_QT
@@ -82,10 +82,10 @@ check_PROGRAMS += \
mln_io_tiff_all \
mln_io_tiff_load
-mln_io_tiff_all_CPPFLAGS= ${TIFF_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_tiff_all_CPPFLAGS= ${TIFF_CPPFLAGS} -DHAVE_TIFF ${AM_CPPFLAGS}
mln_io_tiff_all_LDFLAGS= ${TIFF_LDFLAGS} ${AM_LDFLAGS}
mln_io_tiff_all_SOURCES = mln_io_tiff_all.cc
-mln_io_tiff_load_CPPFLAGS= ${TIFF_CPPFLAGS} ${AM_CPPFLAGS}
+mln_io_tiff_load_CPPFLAGS= ${TIFF_CPPFLAGS} -DHAVE_TIFF ${AM_CPPFLAGS}
mln_io_tiff_load_LDFLAGS= ${TIFF_LDFLAGS} ${AM_LDFLAGS}
mln_io_tiff_load_SOURCES = mln_io_tiff_load.cc
endif HAVE_TIFF
@@ -135,6 +135,7 @@ mln_accu_shape_all \
mln_accu_shape_bbox \
mln_accu_shape_essential \
mln_accu_shape_height \
+mln_accu_shape_site_list \
mln_accu_shape_volume \
mln_accu_site_set_all \
mln_accu_site_set_essential \
@@ -674,6 +675,7 @@ mln_fun_v2v_rgb8_to_rgbn \
mln_fun_v2v_rgb_to_hsi \
mln_fun_v2v_rgb_to_hsl \
mln_fun_v2v_rgb_to_int_u \
+mln_fun_v2v_rgb_to_luma \
mln_fun_v2v_saturate \
mln_fun_v2v_wrap \
mln_fun_v2w2v_all \
@@ -1459,6 +1461,7 @@ mln_accu_shape_all_SOURCES = mln_accu_shape_all.cc
mln_accu_shape_bbox_SOURCES = mln_accu_shape_bbox.cc
mln_accu_shape_essential_SOURCES = mln_accu_shape_essential.cc
mln_accu_shape_height_SOURCES = mln_accu_shape_height.cc
+mln_accu_shape_site_list_SOURCES = mln_accu_shape_site_list.cc
mln_accu_shape_volume_SOURCES = mln_accu_shape_volume.cc
mln_accu_site_set_all_SOURCES = mln_accu_site_set_all.cc
mln_accu_site_set_essential_SOURCES = mln_accu_site_set_essential.cc
@@ -1998,6 +2001,7 @@ mln_fun_v2v_rgb8_to_rgbn_SOURCES = mln_fun_v2v_rgb8_to_rgbn.cc
mln_fun_v2v_rgb_to_hsi_SOURCES = mln_fun_v2v_rgb_to_hsi.cc
mln_fun_v2v_rgb_to_hsl_SOURCES = mln_fun_v2v_rgb_to_hsl.cc
mln_fun_v2v_rgb_to_int_u_SOURCES = mln_fun_v2v_rgb_to_int_u.cc
+mln_fun_v2v_rgb_to_luma_SOURCES = mln_fun_v2v_rgb_to_luma.cc
mln_fun_v2v_saturate_SOURCES = mln_fun_v2v_saturate.cc
mln_fun_v2v_wrap_SOURCES = mln_fun_v2v_wrap.cc
mln_fun_v2w2v_all_SOURCES = mln_fun_v2w2v_all.cc
--
1.5.6.5
1
0