Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- 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
10 Dec '10
* demo/xml2doc/templates/pdf/line.xsl: Use temporary hack to
improve document rendering.
---
scribo/ChangeLog | 69 +--------------------
scribo/demo/xml2doc/templates/pdf/line.xsl | 89 +++++++++++++++++++++++++--
2 files changed, 85 insertions(+), 73 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 04bf771..7d0a372 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,72 +1,9 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
- Integrate the DIA toolchain in Scribo viewer.
+ Temporary fix PDF rendering.
- * demo/viewer/Makefile.am: Add new files.
-
- * demo/viewer/main.cc: Initialize libMagick++.
-
- * demo/viewer/step_widget.cc,
- * demo/viewer/step_widget.hh: Improve interface.
-
- * demo/viewer/viewer.cc,
- * demo/viewer/viewer.hh,
- * demo/viewer/viewer.hxx: Handle calls to the DIA toolchain.
-
- * demo/viewer/preprocess.cc,
- * demo/viewer/preprocess.hh,
- * demo/viewer/process.cc,
- * demo/viewer/process.hh,
- * demo/viewer/runner.cc,
- * demo/viewer/runner.hh: New.
-
-2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Fix guards and license.
-
- * demo/viewer/README,
- * demo/viewer/browser_widget.cc,
- * demo/viewer/browser_widget.hh,
- * demo/viewer/common.hh,
- * demo/viewer/help_dialog.cc,
- * demo/viewer/help_dialog.hh,
- * demo/viewer/image_region.cc,
- * demo/viewer/image_region.hh,
- * demo/viewer/image_region.hxx,
- * demo/viewer/image_scene.cc,
- * demo/viewer/image_scene.hh,
- * demo/viewer/image_view.cc,
- * demo/viewer/image_view.hh,
- * demo/viewer/image_widget.cc,
- * demo/viewer/image_widget.hh,
- * demo/viewer/key_widget.cc,
- * demo/viewer/key_widget.hh,
- * demo/viewer/main.cc,
- * demo/viewer/xml_widget.cc,
- * demo/viewer/xml_widget.hh: Here.
-
-2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Add configuration widgets in Scribo viewer.
-
- * demo/viewer/config.cc,
- * demo/viewer/config.hh,
- * demo/viewer/defs.hh,
- * demo/viewer/general_options.cc,
- * demo/viewer/general_options.hh,
- * demo/viewer/general_options.ui,
- * demo/viewer/option_widget.cc,
- * demo/viewer/option_widget.hh,
- * demo/viewer/preferences_dialog.cc,
- * demo/viewer/preferences_dialog.hh,
- * demo/viewer/preferences_dialog.ui,
- * demo/viewer/toolchain_options.cc,
- * demo/viewer/toolchain_options.hh,
- * demo/viewer/toolchain_options.ui: New.
-
-2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- * src/scribo-cli.in: Add a call to xml2doc.
+ * demo/xml2doc/templates/pdf/line.xsl: Use temporary hack to
+ improve document rendering.
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/demo/xml2doc/templates/pdf/line.xsl b/scribo/demo/xml2doc/templates/pdf/line.xsl
index b143502..e804d52 100644
--- a/scribo/demo/xml2doc/templates/pdf/line.xsl
+++ b/scribo/demo/xml2doc/templates/pdf/line.xsl
@@ -70,6 +70,15 @@
</xsl:for-each>
</xsl:variable>
+ <xsl:variable name="ymax">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 3">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
<xsl:variable name="x1">
<xsl:for-each select="coords/point">
<xsl:sort select="@x" order="ascending" data-type="number"/>
@@ -78,9 +87,19 @@
</xsl:if>
</xsl:for-each>
</xsl:variable>
+
+ <xsl:variable name="xmax">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 3">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
<!-- END OF lines coordinates -->
- <!-- WTF !?, Necessary to do a lower-case ! -->
+ <!-- WTF !?, Necessary to do a lower-case !
+ FIXME: take a look at text-transform attribute -->
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
@@ -97,7 +116,7 @@
</xsl:variable>
- <fo:block-container position="absolute">
+ <fo:block-container position="absolute" border-width="5mm">
<xsl:attribute name="left">
<xsl:value-of select="$x1" />px
@@ -106,6 +125,18 @@
<xsl:value-of select="$y1" />px
</xsl:attribute>
+ <xsl:attribute name="right">
+ <xsl:value-of select="$xmax" />px
+ </xsl:attribute>
+ <xsl:attribute name="bottom">
+ <xsl:value-of select="$ymax" />px
+ </xsl:attribute>
+
+
+ <xsl:attribute name="width">
+ <xsl:value-of select="$xmax - $x1" />px
+ </xsl:attribute>
+
<xsl:attribute name="color">
<xsl:value-of select="$colour" />
</xsl:attribute>
@@ -113,14 +144,58 @@
<!-- if necessary, put letter-spacing="-Npt" ~ -3 <= N <= -1
in fo:block-->
- <fo:block font-family="Times">
+ <!-- text-align-last="justify" will help justifying and using a
+ uniform font size (it stretchs the text, at least for PDF)
+ but it relies on several lines... We need paragraph
+ information.
+ -->
- <xsl:attribute name="font-size">
- <xsl:value-of select="$a + $d" />px
+ <!-- FIXME: using a table allows to justify a single line of
+ text. This is an UGLY HACK. Font size is also tweaked for
+ now but it should not since we have font information.
+ -->
+ <fo:table table-layout="fixed">
+
+ <xsl:attribute name="width">
+ <xsl:value-of select="$xmax -$x1" />px
</xsl:attribute>
- <xsl:value-of select="@text"/>
- </fo:block>
+ <fo:table-column column-number="1">
+ <xsl:attribute name="column-width">
+ <xsl:value-of select="$xmax -$x1" />px
+ </xsl:attribute>
+ </fo:table-column>
+
+ <fo:table-body start-indent="0pt" text-align="justify" text-align-last="justify">
+
+ <fo:table-row>
+
+ <fo:table-cell>
+
+ <fo:block font-family="Times" wrap-option="no-wrap" white-space-collapse="true" text-align-last="justify" text-align="justify">
+
+ <xsl:attribute name="font-size">
+ <xsl:choose>
+ <xsl:when test="($a + $d) > 50">
+ <xsl:value-of select="0.82 * ($a + $d)" />px
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="0.95 * ($a + $d)" />px
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:value-of select="@text"/>
+ </fo:block>
+
+ </fo:table-cell>
+
+ </fo:table-row>
+
+ </fo:table-body>
+
+ </fo:table>
+
</fo:block-container>
--
1.5.6.5
1
0
last-svn-commit-707-gf9fd47c Integrate the DIA toolchain in Scribo viewer.
by Guillaume Lazzara 10 Dec '10
by Guillaume Lazzara 10 Dec '10
10 Dec '10
* demo/viewer/Makefile.am: Add new files.
* demo/viewer/main.cc: Initialize libMagick++.
* demo/viewer/step_widget.cc,
* demo/viewer/step_widget.hh: Improve interface.
* demo/viewer/viewer.cc,
* demo/viewer/viewer.hh,
* demo/viewer/viewer.hxx: Handle calls to the DIA toolchain.
* demo/viewer/preprocess.cc,
* demo/viewer/preprocess.hh,
* demo/viewer/process.cc,
* demo/viewer/process.hh,
* demo/viewer/runner.cc,
* demo/viewer/runner.hh: New.
---
scribo/ChangeLog | 22 +++
scribo/demo/viewer/Makefile.am | 73 +++++++---
scribo/demo/viewer/main.cc | 2 +
.../viewer/{option_widget.cc => preprocess.cc} | 13 +-
.../{preferences_dialog.hh => preprocess.hh} | 38 ++---
.../demo/viewer/{option_widget.cc => process.cc} | 22 ++-
.../{xml2doc/image_crop.hh => viewer/process.hh} | 48 +++----
scribo/demo/viewer/runner.cc | 150 ++++++++++++++++++
scribo/demo/viewer/runner.hh | 61 ++++++++
scribo/demo/viewer/step_widget.cc | 108 ++++++++------
scribo/demo/viewer/step_widget.hh | 19 +--
scribo/demo/viewer/viewer.cc | 160 +++++++++++++++----
scribo/demo/viewer/viewer.hh | 34 +++--
scribo/demo/viewer/viewer.hxx | 4 -
14 files changed, 565 insertions(+), 189 deletions(-)
copy scribo/demo/viewer/{option_widget.cc => preprocess.cc} (78%)
copy scribo/demo/viewer/{preferences_dialog.hh => preprocess.hh} (53%)
copy scribo/demo/viewer/{option_widget.cc => process.cc} (66%)
copy scribo/demo/{xml2doc/image_crop.hh => viewer/process.hh} (50%)
create mode 100644 scribo/demo/viewer/runner.cc
create mode 100644 scribo/demo/viewer/runner.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index f12eb4f..04bf771 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,27 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Integrate the DIA toolchain in Scribo viewer.
+
+ * demo/viewer/Makefile.am: Add new files.
+
+ * demo/viewer/main.cc: Initialize libMagick++.
+
+ * demo/viewer/step_widget.cc,
+ * demo/viewer/step_widget.hh: Improve interface.
+
+ * demo/viewer/viewer.cc,
+ * demo/viewer/viewer.hh,
+ * demo/viewer/viewer.hxx: Handle calls to the DIA toolchain.
+
+ * demo/viewer/preprocess.cc,
+ * demo/viewer/preprocess.hh,
+ * demo/viewer/process.cc,
+ * demo/viewer/process.hh,
+ * demo/viewer/runner.cc,
+ * demo/viewer/runner.hh: New.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix guards and license.
* demo/viewer/README,
diff --git a/scribo/demo/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am
index 851bf30..2e0afec 100644
--- a/scribo/demo/viewer/Makefile.am
+++ b/scribo/demo/viewer/Makefile.am
@@ -1,16 +1,19 @@
-##
-## Document layout viewer.
-##
-## Copyright (C) 2009 Florent D'Halluin.
-##
-## This program 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; either version 2
-## of the License, or (at your option) any later version.
-##
-## The complete GNU General Public Licence Notice can be found as the
-## `COPYING' file in the root directory.
-##
+# Copyright (C) 2009, 2010 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/>.
include $(top_srcdir)/build-aux/autotroll.mk
@@ -27,11 +30,26 @@ scribo_viewer_SOURCES = $(BUILT_SOURCES) \
image_view.cc \
image_region.cc \
help_dialog.cc \
- step_widget.cc
+ step_widget.cc \
+ toolchain_options.cc \
+ runner.cc \
+ preprocess.cc \
+ process.cc \
+ general_options.cc \
+ preferences_dialog.cc \
+ option_widget.cc \
+ config.cc
-scribo_viewer_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir)
+scribo_viewer_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir) \
+ -I$(top_srcdir)/milena \
+ -I$(top_srcdir)/scribo \
+ $(MAGICKXX_CPPFLAGS) \
+ $(TESSERACT_CPPFLAGS) \
+ -DNDEBUG -DMLN_WO_GLOBAL_VARS
scribo_viewer_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) -O3
-scribo_viewer_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS)
+scribo_viewer_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ $(TESSERACT_LDFLAGS)
scribo_viewer_LDADD = $(QT_LIBS) $(LDADD)
BUILT_SOURCES = viewer.moc.cc \
@@ -43,7 +61,16 @@ BUILT_SOURCES = viewer.moc.cc \
image_view.moc.cc \
image_region.moc.cc \
help_dialog.moc.cc \
- step_widget.moc.cc
+ step_widget.moc.cc \
+ toolchain_options.moc.cc \
+ toolchain_options.ui.h \
+ runner.moc.cc \
+ preprocess.moc.cc \
+ process.moc.cc \
+ preferences_dialog.moc.cc \
+ preferences_dialog.ui.h \
+ general_options.moc.cc \
+ general_options.ui.h
noinst_HEADERS = viewer.hh \
@@ -58,6 +85,16 @@ noinst_HEADERS = viewer.hh \
image_region.hxx \
common.hh \
help_dialog.hh \
- step_widget.hh
+ step_widget.hh \
+ toolchain_options.hh \
+ runner.hh \
+ preprocess.hh \
+ process.hh \
+ general_options.hh \
+ preferences_dialog.hh \
+ option_widget.hh \
+ config.hh
EXTRA_DIST = README
+
+CLEANFILES = $(BUILT_SOURCES)
\ No newline at end of file
diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc
index 76d4494..6d1cb18 100644
--- a/scribo/demo/viewer/main.cc
+++ b/scribo/demo/viewer/main.cc
@@ -35,6 +35,8 @@ int main(int argc, char** argv)
return 0;
}
+ Magick::InitializeMagick(*argv);
+
Viewer* viewer = Viewer::Instance(argc, argv);
if (!viewer)
diff --git a/scribo/demo/viewer/option_widget.cc b/scribo/demo/viewer/preprocess.cc
similarity index 78%
copy from scribo/demo/viewer/option_widget.cc
copy to scribo/demo/viewer/preprocess.cc
index 4557749..fd9a48b 100644
--- a/scribo/demo/viewer/option_widget.cc
+++ b/scribo/demo/viewer/preprocess.cc
@@ -14,17 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-# include "option_widget.hh"
+#include "preprocess.hh"
-OptionWidget::OptionWidget(QWidget * parent)
- : QWidget(parent)
+void preprocess::on_progress()
{
+ emit progress();
}
-void OptionWidget::save_config()
-{
-}
-void OptionWidget::load_config()
+void preprocess::on_new_progress_label(const char *label)
{
+ QString lbl(label);
+ emit new_progress_label(label);
}
diff --git a/scribo/demo/viewer/preferences_dialog.hh b/scribo/demo/viewer/preprocess.hh
similarity index 53%
copy from scribo/demo/viewer/preferences_dialog.hh
copy to scribo/demo/viewer/preprocess.hh
index 0368bbe..4562cfb 100644
--- a/scribo/demo/viewer/preferences_dialog.hh
+++ b/scribo/demo/viewer/preprocess.hh
@@ -14,32 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#ifndef SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
-# define SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
+#ifndef SCRIBO_DEMO_VIEWER_PREPROCESS_HH
+# define SCRIBO_DEMO_VIEWER_PREPROCESS_HH
-# include <QtGui>
-# include <preferences_dialog.ui.h>
+# include <QtCore/QObject>
+# include <mln/core/image/image2d.hh>
+# include <mln/value/rgb8.hh>
+# include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-class preferences_dialog : public QDialog, private Ui::PreferencesDialog
+using namespace scribo::toolchain::internal;
+
+struct preprocess
+ : public QObject,
+ public text_in_doc_preprocess_functor<mln::image2d<mln::value::rgb8> >
{
Q_OBJECT;
-public:
- preferences_dialog(QWidget *parent = 0);
- ~preferences_dialog();
-
-private slots:
- void on_optionList_currentRowChanged(int row);
- virtual void accept();
- virtual void reject();
-
-private: // Methods
- void load_option_list();
- void select_option_widget(int row);
-
-private: // Attributes
- QVector<QWidget *> widgets_;
+ virtual void on_progress();
+ virtual void on_new_progress_label(const char *label);
+signals:
+ void new_progress_label(const QString& label);
+ void progress();
};
-#endif // ! SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
+#endif // ! SCRIBO_DEMO_VIEWER_PREPROCESS_HH
diff --git a/scribo/demo/viewer/option_widget.cc b/scribo/demo/viewer/process.cc
similarity index 66%
copy from scribo/demo/viewer/option_widget.cc
copy to scribo/demo/viewer/process.cc
index 4557749..8fa5b9f 100644
--- a/scribo/demo/viewer/option_widget.cc
+++ b/scribo/demo/viewer/process.cc
@@ -14,17 +14,29 @@
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-# include "option_widget.hh"
+#include "process.hh"
-OptionWidget::OptionWidget(QWidget * parent)
- : QWidget(parent)
+process::process(const char *doc_filename)
+ : super_t(doc_filename)
{
+
+}
+
+void process::on_progress()
+{
+ emit progress();
}
-void OptionWidget::save_config()
+
+void process::on_new_progress_label(const char *label)
{
+ QString lbl(label);
+ emit new_progress_label(label);
}
-void OptionWidget::load_config()
+
+void process::on_xml_saved()
{
+ QString filename(output_file.c_str());
+ emit xml_saved(filename);
}
diff --git a/scribo/demo/xml2doc/image_crop.hh b/scribo/demo/viewer/process.hh
similarity index 50%
copy from scribo/demo/xml2doc/image_crop.hh
copy to scribo/demo/viewer/process.hh
index 2856c35..09ace43 100644
--- a/scribo/demo/xml2doc/image_crop.hh
+++ b/scribo/demo/viewer/process.hh
@@ -14,41 +14,33 @@
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#ifndef SCRIBO_DEMO_XML2DOC_IMAGE_CROP_HH
-# define SCRIBO_DEMO_XML2DOC_IMAGE_CROP_HH
+#ifndef SCRIBO_DEMO_VIEWER_PROCESS_HH
+# define SCRIBO_DEMO_VIEWER_PROCESS_HH
-# include <QDomDocument>
-# include <QtCore>
-
-# include <mln/value/rgb8.hh>
+# include <QtCore/QObject>
# include <mln/core/image/image2d.hh>
+# include <scribo/toolchain/internal/content_in_doc_functor.hh>
+using namespace scribo::toolchain::internal;
-class DomModel;
-
-class ImageCrop : public QObject
+struct process
+ : public QObject,
+ public content_in_doc_functor<mln::image2d<bool> >
{
- Q_OBJECT
- public:
-
- ImageCrop(const QString&, const QString&, const QString&);
- ~ImageCrop();
-
- void save_image(const QString&);
- bool crop_regions(bool temp = false);
+ Q_OBJECT;
+ typedef content_in_doc_functor<mln::image2d<bool> > super_t;
- QString img_to_base64();
- bool img_from_base64(const QString&, const QString&);
- void to_base64(const QString&, bool);
+public:
+ process(const char *doc_filename);
- void from_base64();
+ virtual void on_progress();
+ virtual void on_new_progress_label(const char *label);
+ virtual void on_xml_saved();
-private:
- QString xml_;
- QString image_;
- QString output_dir_;
- QMap<QString, QString> region_map_;
- mln::image2d<mln::value::rgb8> ima_;
+signals:
+ void new_progress_label(const QString& label);
+ void progress();
+ void xml_saved(const QString& filename);
};
-#endif // ! SCRIBO_DEMO_XML2DOC_IMAGE_CROP_HH
+#endif // ! SCRIBO_DEMO_VIEWER_PROCESS_HH
diff --git a/scribo/demo/viewer/runner.cc b/scribo/demo/viewer/runner.cc
new file mode 100644
index 0000000..1d0f4bb
--- /dev/null
+++ b/scribo/demo/viewer/runner.cc
@@ -0,0 +1,150 @@
+// Copyright (C) 2010 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/>.
+
+#include "runner.hh"
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/io/magick/load.hh>
+
+#include "process.hh"
+#include "preprocess.hh"
+#include "config.hh"
+#include "defs.hh"
+
+
+using namespace mln;
+using namespace scribo::toolchain::internal;
+
+runner::runner(QObject *parent)
+ : QThread(parent)
+{
+ moveToThread(this);
+}
+
+
+void runner::start(const QString& filename)
+{
+ filename_ = filename;
+
+ QThread::start();
+}
+
+
+void runner::run()
+{
+ QThread::setTerminationEnabled();
+
+ image2d<value::rgb8> ima;
+ io::magick::load(ima, filename_.toUtf8().constData());
+
+ image2d<bool> bin_ima = preprocess(ima);
+ process(ima, bin_ima);
+
+ emit finished();
+ qDebug() << "Done.";
+}
+
+
+image2d<bool>
+runner::preprocess(const image2d<value::rgb8>& ima)
+{
+ emit new_step("Preprocessing");
+
+ ::preprocess f;
+
+ // Load config.
+ config * const conf = config::get_instance();
+
+ connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
+ connect(&f, SIGNAL(new_progress_label(const QString&)),
+ this, SIGNAL(new_progress_label(const QString&)));
+
+ f.enable_subsample = conf->preprocessing_subsample();
+ f.enable_fg_extraction = conf->preprocessing_remove_bg();
+ f.enable_deskew = conf->preprocessing_deskew();
+ f.enable_denoising = conf->preprocessing_remove_noise();
+
+ f.binarization_algo = static_cast<Binarization_Algo>(conf->preprocessing_bin_algo());
+
+ emit new_progress_max_value(f.nsteps());
+
+ // Perform preprocessing.
+ f(ima);
+
+ qDebug() << "Preprocess Done.";
+ return f.output;
+}
+
+
+void runner::process(const image2d<value::rgb8>& original_ima,
+ const image2d<bool>& processed_ima)
+{
+ emit new_step("Page segmentation");
+
+ ::process f(filename_.toUtf8().constData());
+
+ connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
+ connect(&f, SIGNAL(new_progress_label(const QString&)),
+ this, SIGNAL(new_progress_label(const QString&)));
+ connect(&f, SIGNAL(xml_saved(const QString&)),
+ this, SIGNAL(xml_saved(const QString&)));
+
+ // Load config.
+ config * const conf = config::get_instance();
+
+ defs::FindSeparators
+ find_seps = static_cast<defs::FindSeparators>(conf->segmentation_find_seps());
+ f.enable_line_seps = (find_seps == defs::Lines
+ || find_seps == defs::LinesAndWhitespaces);
+ f.enable_whitespace_seps = (find_seps == defs::Whitespaces
+ || find_seps == defs::LinesAndWhitespaces);
+
+ f.allow_xml_extensions = true;
+
+
+ f.save_doc_as_xml = true;
+ QFileInfo file(filename_);
+ QString output_dir = QDir::tempPath();
+ if (conf->general_save_xml_enabled())
+ {
+ if (conf->general_save_xml_same_dir())
+ output_dir = file.absolutePath();
+ else if (conf->general_save_xml_custom_dir())
+ output_dir = conf->general_save_xml_custom_dir_path();
+ else
+ qDebug() << "runner::progress - Invalid xml saving option!";
+
+ QDir dir(output_dir);
+ if (!dir.exists() && !dir.mkpath(output_dir))
+ output_dir = QDir::tempPath();
+ }
+ f.output_file = (output_dir + "/" + file.baseName() + "_gui.xml").toUtf8().constData();
+ qDebug() << "Saving to " << f.output_file.c_str();
+
+ emit new_progress_max_value(f.nsteps());
+
+ // Perform text detection.
+ f(original_ima, processed_ima);
+
+ qDebug() << "Process Done.";
+}
+
+
+void runner::stop()
+{
+ terminate();
+}
diff --git a/scribo/demo/viewer/runner.hh b/scribo/demo/viewer/runner.hh
new file mode 100644
index 0000000..ed243ea
--- /dev/null
+++ b/scribo/demo/viewer/runner.hh
@@ -0,0 +1,61 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_RUNNER_HH
+# define SCRIBO_DEMO_VIEWER_RUNNER_HH
+
+# include <QtGui>
+
+# include <mln/core/image/image2d.hh>
+# include <mln/value/rgb8.hh>
+
+using namespace mln;
+
+class runner : public QThread
+{
+ Q_OBJECT;
+
+public:
+ runner(QObject *parent = 0);
+
+ void start(const QString& filename);
+
+public slots:
+ void stop();
+
+signals:
+ void new_step(const QString& step_name);
+ void new_progress_max_value(int i);
+ void new_progress_label(const QString& msg);
+ void xml_saved(const QString& filename);
+ void progress();
+ void finished();
+
+private: // members
+ image2d<bool> preprocess(const image2d<value::rgb8>& ima);
+ void process(const image2d<value::rgb8>& original_ima,
+ const image2d<bool>& processed_ima);
+ virtual void run();
+
+ template <typename V>
+ unsigned find_best_scale(const mln::image2d<V>& ima);
+
+private: // attributes
+ QString filename_;
+};
+
+
+#endif // ! SCRIBO_DEMO_VIEWER_RUNNER_HH
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
index 010b270..342b654 100644
--- a/scribo/demo/viewer/step_widget.cc
+++ b/scribo/demo/viewer/step_widget.cc
@@ -13,17 +13,9 @@
//
// 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.
# include "step_widget.hh"
+# include "config.hh"
StepWidget::StepWidget()
: view_(new QListWidget()),
@@ -48,26 +40,31 @@ StepWidget::StepWidget()
this, SLOT(activate(QListWidgetItem*)));
}
+StepWidget::~StepWidget()
+{
+}
+
+
void StepWidget::activate(QListWidgetItem* item)
{
QString key, value;
StepQMap::iterator iter = map_.find(item->text());
- view_->setCurrentItem(item);
if (iter != map_.end())
- {
- step_ = item->text();
- key = iter.key();
- value = iter.value();
-
- emit load_xml(value);
- }
+ {
+ view_->setCurrentItem(item);
+ step_ = item->text();
+ key = iter.key();
+ value = iter.value();
+
+ emit load_xml(value);
+ }
else
qDebug() << "Step not found!";
-
}
+
void StepWidget::fill_steps(QString file, bool step, bool container)
{
view_->clear();
@@ -85,38 +82,31 @@ void StepWidget::fill_steps(QString file, bool step, bool container)
// image is loaded once
emit load_image(file, false);
- int cut = file.lastIndexOf(QChar('/'));
- QString path = file.left(cut+1);
- QString filename = file.mid(cut+1);
- cut = filename.lastIndexOf(QChar('.'));
+ QFileInfo f(file);
+ file_with_no_ext_ = f.baseName();
+
+ QStringList dirlist;
+ dirlist << f.absolutePath() << QDir::tempPath();
- QString file_with_no_ext = filename.left(cut);
- // view_->addItem(file_with_no_ext);
+ // Set directories to look at according to settings.
+ config * const conf = config::get_instance();
+ if (conf->general_save_xml_custom_dir())
+ dirlist << conf->general_save_xml_custom_dir_path();
- QDir dir(path);
+ foreach(QString path, dirlist)
+ {
+ QDir dir(path);
- if (dir.isReadable())
+ if (dir.isReadable())
{
QStringList filter;
filter << "*.xml";
- QStringList xml_list = dir.entryList(filter);
+ QFileInfoList xml_list = dir.entryInfoList(filter);
for (int i = 0; i < xml_list.size(); ++i)
- {
- if (xml_list.at(i).startsWith(file_with_no_ext))
- {
- cut = xml_list.at(i).lastIndexOf(QChar('.'));
- QString key = xml_list.at(i).left(cut);
- key.replace(file_with_no_ext + QString("_"), QString(""));
- key.replace(QRegExp("^step([0-9])"), "Step \\1");
- key.replace(QRegExp("^Step ([0-9])_"), "Step \\1 : ");
- key.replace("_", " ");
- QString value = path;
- map_.insertMulti(key, value.append(xml_list.at(i)));
- view_->addItem(key);
- }
- }
+ insert_new_entry(xml_list.at(i));
}
+ }
if ( (step && step_ != QString::Null()))
{
@@ -130,15 +120,43 @@ void StepWidget::fill_steps(QString file, bool step, bool container)
}
}
-void StepWidget::add_element(const QString& element)
+
+QListWidgetItem* StepWidget::insert_new_entry(const QFileInfo& file)
{
- view_->addItem(element);
+ QListWidgetItem *item = 0;
+
+ if (file.fileName().startsWith(file_with_no_ext_))
+ {
+ QString key = file.baseName();
+ key.replace(file_with_no_ext_ + QString("_"), QString(""));
+ key.replace(QRegExp("^step([0-9])"), "Step \\1");
+ key.replace(QRegExp("^Step ([0-9])_"), "Step \\1 : ");
+ key.replace("_", " ");
+
+ bool exists = (map_.find(key) != map_.end());
+
+ map_.insertMulti(key, file.absoluteFilePath());
+
+ if (!exists)
+ {
+ item = new QListWidgetItem(key);
+ view_->addItem(item);
+ }
+ else
+ item = view_->findItems(key, Qt::MatchCaseSensitive).at(0);
+ }
+
+ return item;
}
-StepWidget::~StepWidget()
+
+QListWidgetItem* StepWidget::add_element(const QString& element)
{
-}
+ QListWidgetItem *item = new QListWidgetItem(element);
+ view_->addItem(item);
+ return item;
+}
diff --git a/scribo/demo/viewer/step_widget.hh b/scribo/demo/viewer/step_widget.hh
index c5d77df..b323167 100644
--- a/scribo/demo/viewer/step_widget.hh
+++ b/scribo/demo/viewer/step_widget.hh
@@ -13,19 +13,10 @@
//
// 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 STEP_WIDGET_HH_
-# define STEP_WIDGET_HH_
+#ifndef SCRIBO_DEMO_VIEWER_STEP_WIDGET_HH_
+# define SCRIBO_DEMO_VIEWER_STEP_WIDGET_HH_
# include <QtGui>
@@ -39,7 +30,7 @@ class StepWidget
public:
StepWidget();
~StepWidget();
- void add_element(const QString& element);
+ QListWidgetItem* add_element(const QString& element);
signals:
void load_image(QString, bool);
@@ -50,11 +41,13 @@ signals:
public slots:
void fill_steps(QString file, bool step = false, bool container = false);
void activate(QListWidgetItem* item);
+ QListWidgetItem* insert_new_entry(const QFileInfo& file);
private:
QListWidget* view_;
StepQMap map_;
QString step_;
+ QString file_with_no_ext_;
};
-#endif /* !STEP_WIDGET_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_STEP_WIDGET_HH_
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 41434ba..dd0fbe4 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -13,15 +13,10 @@
//
// 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.
+
+
+#include <iostream>
+#include <limits.h>
#include "viewer.hh"
#include "key_widget.hh"
@@ -32,7 +27,9 @@
#include "image_scene.hh"
#include "image_region.hh"
#include "help_dialog.hh"
-#include <limits.h>
+#include "preferences_dialog.hh"
+#include "runner.hh"
+#include "config.hh"
#include "common.hh"
@@ -49,7 +46,8 @@ Viewer::Viewer(int &argc, char** argv)
xml_file_(QString::Null()),
base64_(false),
text_(true),
- use_image_(true)
+ use_image_(true),
+ pdialog_(win_)
{
// Key map
@@ -81,30 +79,53 @@ Viewer::Viewer(int &argc, char** argv)
region_ids_["chart_region"] = region::Chart;
region_ids_["maths_region"] = region::Maths;
- // Layout
win_->resize(1152, 864);
win_->statusBar();
QMenu* file_menu = win_->menuBar()->addMenu(tr("File"));
QMenu* option_menu = win_->menuBar()->addMenu(tr("Options"));
+ QMenu* view_menu = win_->menuBar()->addMenu(tr("View"));
QMenu* help_menu = win_->menuBar()->addMenu(tr("Help"));
+
+ // File menu
+
+ QAction *doc_seg_action = create_action("Segment document", file_menu,
+ "Segment document", "Ctrl+S");
+ connect(doc_seg_action, SIGNAL(triggered()),
+ this, SLOT(run_process()));
+ file_menu->addAction(doc_seg_action);
+
+ file_menu->addSeparator();
+
QAction* quit_action = create_action("Quit", file_menu,
"Exit the program.", "Ctrl+q");
connect(quit_action, SIGNAL(triggered()),
app_, SLOT(quit()));
file_menu->addAction(quit_action);
- outline_action_ = create_action("Draw outline", option_menu,
+ // Option menu
+
+ QAction* preferences_action_ = create_action("Preferences", option_menu,
+ "Preferences", "Ctrl+Alt+P");
+ preferences_action_->setCheckable(false);
+ connect(preferences_action_, SIGNAL(triggered(bool)),
+ this, SLOT(on_preferences()));
+ option_menu->addAction(preferences_action_);
+
+
+ // View menu
+
+ outline_action_ = create_action("Draw outline", view_menu,
"Draw region outlines.", "Ctrl+o");
outline_action_->setCheckable(true);
outline_action_->setChecked(true);
connect(outline_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setOutline(bool)));
- option_menu->addAction(outline_action_);
+ view_menu->addAction(outline_action_);
- precise_action_ = create_action("Precise outline", option_menu,
+ precise_action_ = create_action("Precise outline", view_menu,
"1px outline relative to the image "
"(1px relative to the view if off).",
"Ctrl+p");
@@ -112,27 +133,27 @@ Viewer::Viewer(int &argc, char** argv)
precise_action_->setChecked(false);
connect(precise_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setPrecise(bool)));
- option_menu->addAction(precise_action_);
+ view_menu->addAction(precise_action_);
- fill_action_ = create_action("Fill regions", option_menu,
+ fill_action_ = create_action("Fill regions", view_menu,
"Color the inside of regions.", "Ctrl+f");
fill_action_->setCheckable(true);
fill_action_->setChecked(true);
connect(fill_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setFill(bool)));
- option_menu->addAction(fill_action_);
+ view_menu->addAction(fill_action_);
- QAction* cache_action = create_action("Disable cache", option_menu,
+ QAction* cache_action = create_action("Disable cache", view_menu,
"Disable the image cache (useful for"
" large images).", "Ctrl+c");
cache_action->setCheckable(true);
cache_action->setChecked(false);
connect(cache_action, SIGNAL(toggled(bool)),
this, SLOT(useCache(bool)));
- option_menu->addAction(cache_action);
+ view_menu->addAction(cache_action);
- QAction* extended_action = create_action("Extended mode", option_menu,
+ QAction* extended_action = create_action("Extended mode", view_menu,
"If enabled, some features "
"not supported by ICDAR"
" are added such as text regions"
@@ -141,28 +162,28 @@ Viewer::Viewer(int &argc, char** argv)
extended_action->setChecked(false);
connect(extended_action, SIGNAL(toggled(bool)),
this, SLOT(useExtended(bool)));
- option_menu->addAction(extended_action);
+ view_menu->addAction(extended_action);
- QAction* show_image_action = create_action("Show pictures", option_menu,
+ QAction* show_image_action = create_action("Show pictures", view_menu,
"Display pictures on the scene or not",
"Ctrl+i");
show_image_action->setCheckable(true);
show_image_action->setChecked(true);
connect(show_image_action, SIGNAL(toggled(bool)),
this, SLOT(useImage(bool)));
- option_menu->addAction(show_image_action);
+ view_menu->addAction(show_image_action);
- QAction* show_text_action = create_action("Show text", option_menu,
+ QAction* show_text_action = create_action("Show text", view_menu,
"Show detected text inside boxes.",
"Ctrl+t");
show_text_action->setCheckable(true);
show_text_action->setChecked(true);
connect(show_text_action, SIGNAL(toggled(bool)),
this, SLOT(useText(bool)));
- option_menu->addAction(show_text_action);
+ view_menu->addAction(show_text_action);
key_wgt_ = new KeyWidget(key_map_);
- QAction *show_region_action = create_action("Show regions", option_menu,
+ QAction *show_region_action = create_action("Show regions", view_menu,
"Display regions that are present in"
" the XML file.",
"Ctrl+r");
@@ -170,7 +191,9 @@ Viewer::Viewer(int &argc, char** argv)
show_region_action->setChecked(true);
connect(show_region_action, SIGNAL(toggled(bool)),
key_wgt_, SLOT(setAll(bool)));
- option_menu->addAction(show_region_action);
+ view_menu->addAction(show_region_action);
+
+ // Help menu
QAction* about_action = create_action("About", help_menu,
"About this program",
@@ -179,11 +202,13 @@ Viewer::Viewer(int &argc, char** argv)
this, SLOT(help()));
help_menu->addAction(about_action);
+ // Layout
+
QSplitter* h_splitter = new QSplitter();
QSplitter* v_splitter = new QSplitter(Qt::Vertical);
QSplitter* v_splitter2 = new QSplitter(Qt::Vertical);
- StepWidget* step_widget = new StepWidget();
+ step_widget_ = new StepWidget();
XmlWidget* xml_wgt = new XmlWidget();
BrowserWidget* browser_wgt =
new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
@@ -191,7 +216,7 @@ Viewer::Viewer(int &argc, char** argv)
scene_->setBackgroundBrush(scene_->palette().window());
- v_splitter->addWidget(step_widget);
+ v_splitter->addWidget(step_widget_);
v_splitter->addWidget(key_wgt_);
v_splitter->addWidget(browser_wgt);
@@ -216,13 +241,13 @@ Viewer::Viewer(int &argc, char** argv)
h_splitter->setSizes(h_sizes);
connect(browser_wgt, SIGNAL(activated(QString, bool, bool)),
- step_widget, SLOT(fill_steps(QString, bool, bool)));
+ step_widget_, SLOT(fill_steps(QString, bool, bool)));
- connect(step_widget, SIGNAL(change_base(bool)),
+ connect(step_widget_, SIGNAL(change_base(bool)),
this, SLOT(change_base(bool)));
- connect(step_widget, SIGNAL(load_image(QString, bool)),
+ connect(step_widget_, SIGNAL(load_image(QString, bool)),
this, SLOT(load(QString, bool)));
- connect(step_widget, SIGNAL(load_xml(QString)),
+ connect(step_widget_, SIGNAL(load_xml(QString)),
this, SLOT(load_xml(QString)));
connect(this, SIGNAL(mode_changed(bool)),
@@ -242,9 +267,34 @@ Viewer::Viewer(int &argc, char** argv)
connect(image_wgt, SIGNAL(scaleUpdated(qreal)),
this, SLOT(maybeChangeCacheMode(qreal)));
+
+
+ // Progress dialog and process runner.
+ pdialog_.setModal(true);
+ pdialog_.setAutoClose(false);
+ pdialog_.setCancelButton(0);
+ connect(&runner_, SIGNAL(finished()), &pdialog_, SLOT(close()));
+
+ connect(&runner_, SIGNAL(new_step(const QString&)),
+ &pdialog_, SLOT(setWindowTitle(const QString&)));
+ connect(&runner_, SIGNAL(new_progress_max_value(int)),
+ &pdialog_, SLOT(setMaximum(int)));
+ connect(&runner_, SIGNAL(new_progress_label(const QString&)),
+ &pdialog_, SLOT(setLabelText(const QString&)));
+ connect(&runner_, SIGNAL(progress()),
+ this, SLOT(run_progress()));
+ connect(&runner_, SIGNAL(xml_saved(const QString&)),
+ this, SLOT(on_xml_saved(const QString&)));
}
+Viewer::~Viewer()
+{
+ // Remove temporary xml files.
+ foreach(QString file, tmp_files_to_remove_)
+ QFile::remove(file);
+}
+
void
Viewer::add_text(QDomNode line, QDomNode region)
{
@@ -518,6 +568,8 @@ Viewer::load(QString filename, bool b)
else
image_ = new QGraphicsPixmapItem(QPixmap(filename));
+ current_image_ = filename;
+
image_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
image_->setZValue(0);
if (use_image_)
@@ -687,3 +739,43 @@ QAction
return (action);
}
+
+void
+Viewer::on_preferences()
+{
+ preferences_dialog *win = new preferences_dialog(win_);
+ win->show();
+}
+
+
+void
+Viewer::run_process()
+{
+ if (!current_image_.isEmpty())
+ {
+ pdialog_.setValue(0);
+ pdialog_.setLabelText("");
+ pdialog_.show();
+ runner_.start(current_image_);
+ }
+}
+
+
+void
+Viewer::run_progress()
+{
+ pdialog_.setValue(pdialog_.value() + 1);
+}
+
+
+void
+Viewer::on_xml_saved(const QString& filename)
+{
+ config * const conf = config::get_instance();
+
+ if (!conf->general_save_xml_enabled())
+ tmp_files_to_remove_.insert(filename);
+
+ QListWidgetItem *item = step_widget_->insert_new_entry(filename);
+ step_widget_->activate(item);
+}
diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh
index 30e01bb..93fc840 100644
--- a/scribo/demo/viewer/viewer.hh
+++ b/scribo/demo/viewer/viewer.hh
@@ -13,27 +13,20 @@
//
// 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 VIEWER_HH_
-# define VIEWER_HH_
+
+#ifndef SCRIBO_DEMO_VIEWER_VIEWER_HH
+# define SCRIBO_DEMO_VIEWER_VIEWER_HH
# include <QtGui>
-# include "common.hh"
# include <QDomNode>
+# include "common.hh"
+# include "runner.hh"
class ImageScene;
class DomModel;
class KeyWidget;
class ImageRegion;
+class StepWidget;
class Viewer
: public QObject
@@ -60,6 +53,12 @@ public slots:
void useImage(bool b);
void change_base(bool b);
+private slots:
+ void on_preferences();
+ void run_process();
+ void run_progress();
+ void on_xml_saved(const QString& filename);
+
signals:
void updated();
void key_updated(int key, bool checked);
@@ -81,6 +80,7 @@ private:
QApplication* app_;
QMainWindow* win_;
+ StepWidget* step_widget_;
QGraphicsPixmapItem* image_;
@@ -105,8 +105,14 @@ private:
bool use_image_;
QVector<QGraphicsTextItem *> text_vector_;
QVector<QGraphicsPixmapItem*> image_vector_;
+ QString current_image_;
+
+ QProgressDialog pdialog_;
+ runner runner_;
+
+ QSet<QString> tmp_files_to_remove_;
};
#include "viewer.hxx"
-#endif /* !VIEWER_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_VIEWER_HH
diff --git a/scribo/demo/viewer/viewer.hxx b/scribo/demo/viewer/viewer.hxx
index b72eaff..cba59f3 100644
--- a/scribo/demo/viewer/viewer.hxx
+++ b/scribo/demo/viewer/viewer.hxx
@@ -35,8 +35,4 @@ inline Viewer* Viewer::Instance(int &argc, char** argv)
return &viewer;
}
-inline Viewer::~Viewer()
-{
-}
-
#endif /* !VIEWER_HXX_ */
--
1.5.6.5
1
0
* demo/viewer/README,
* demo/viewer/browser_widget.cc,
* demo/viewer/browser_widget.hh,
* demo/viewer/common.hh,
* demo/viewer/help_dialog.cc,
* demo/viewer/help_dialog.hh,
* demo/viewer/image_region.cc,
* demo/viewer/image_region.hh,
* demo/viewer/image_region.hxx,
* demo/viewer/image_scene.cc,
* demo/viewer/image_scene.hh,
* demo/viewer/image_view.cc,
* demo/viewer/image_view.hh,
* demo/viewer/image_widget.cc,
* demo/viewer/image_widget.hh,
* demo/viewer/key_widget.cc,
* demo/viewer/key_widget.hh,
* demo/viewer/main.cc,
* demo/viewer/xml_widget.cc,
* demo/viewer/xml_widget.hh: Here.
---
scribo/ChangeLog | 25 +++++++++++++++++++++++++
scribo/demo/viewer/README | 9 ---------
scribo/demo/viewer/browser_widget.cc | 9 ---------
scribo/demo/viewer/browser_widget.hh | 17 ++++-------------
scribo/demo/viewer/common.hh | 17 ++++-------------
scribo/demo/viewer/help_dialog.cc | 9 ---------
scribo/demo/viewer/help_dialog.hh | 15 +++------------
scribo/demo/viewer/image_region.cc | 9 ---------
scribo/demo/viewer/image_region.hh | 15 +++------------
scribo/demo/viewer/image_region.hxx | 34 +++++++++++++++++++++++-----------
scribo/demo/viewer/image_scene.cc | 10 +---------
scribo/demo/viewer/image_scene.hh | 18 ++++--------------
scribo/demo/viewer/image_view.cc | 9 ---------
scribo/demo/viewer/image_view.hh | 17 ++++-------------
scribo/demo/viewer/image_widget.cc | 9 ---------
scribo/demo/viewer/image_widget.hh | 17 ++++-------------
scribo/demo/viewer/key_widget.cc | 9 ---------
scribo/demo/viewer/key_widget.hh | 15 +++------------
scribo/demo/viewer/main.cc | 14 +++++---------
scribo/demo/viewer/xml_widget.cc | 9 ---------
scribo/demo/viewer/xml_widget.hh | 17 ++++-------------
21 files changed, 87 insertions(+), 216 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 7829717..f12eb4f 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,30 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix guards and license.
+
+ * demo/viewer/README,
+ * demo/viewer/browser_widget.cc,
+ * demo/viewer/browser_widget.hh,
+ * demo/viewer/common.hh,
+ * demo/viewer/help_dialog.cc,
+ * demo/viewer/help_dialog.hh,
+ * demo/viewer/image_region.cc,
+ * demo/viewer/image_region.hh,
+ * demo/viewer/image_region.hxx,
+ * demo/viewer/image_scene.cc,
+ * demo/viewer/image_scene.hh,
+ * demo/viewer/image_view.cc,
+ * demo/viewer/image_view.hh,
+ * demo/viewer/image_widget.cc,
+ * demo/viewer/image_widget.hh,
+ * demo/viewer/key_widget.cc,
+ * demo/viewer/key_widget.hh,
+ * demo/viewer/main.cc,
+ * demo/viewer/xml_widget.cc,
+ * demo/viewer/xml_widget.hh: Here.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add configuration widgets in Scribo viewer.
* demo/viewer/config.cc,
diff --git a/scribo/demo/viewer/README b/scribo/demo/viewer/README
index fa37cd6..31c66aa 100644
--- a/scribo/demo/viewer/README
+++ b/scribo/demo/viewer/README
@@ -14,15 +14,6 @@ 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.
-
__________________________________________________________________
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
index 7e01789..5a67d1e 100644
--- a/scribo/demo/viewer/browser_widget.cc
+++ b/scribo/demo/viewer/browser_widget.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "browser_widget.hh"
diff --git a/scribo/demo/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
index 964dc47..bbed1ac 100644
--- a/scribo/demo/viewer/browser_widget.hh
+++ b/scribo/demo/viewer/browser_widget.hh
@@ -13,18 +13,9 @@
//
// 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 BROWSER_WIDGET_HH_
-# define BROWSER_WIDGET_HH_
+
+#ifndef SCRIBO_DEMO_VIEWER_BROWSER_WIDGET_HH
+# define SCRIBO_DEMO_VIEWER_BROWSER_WIDGET_HH
# include <QtGui>
@@ -54,4 +45,4 @@ private:
bool first_time_;
};
-#endif /* !BROWSER_WIDGET_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_BROWSER_WIDGET_HH
diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh
index 4dee676..7f67f82 100644
--- a/scribo/demo/viewer/common.hh
+++ b/scribo/demo/viewer/common.hh
@@ -13,18 +13,9 @@
//
// 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 COMMON_HH_
-# define COMMON_HH_
+#ifndef SCRIBO_DEMO_VIEWER_COMMON_HH
+# define SCRIBO_DEMO_VIEWER_COMMON_HH
namespace region
{
@@ -35,7 +26,7 @@ namespace region
Text = 0,
Paragraph,
Line,
- Image,
+ Image,
Noise,
Separator,
Table,
@@ -46,4 +37,4 @@ namespace region
};
}
-#endif /* !COMMON_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_COMMON_HH
diff --git a/scribo/demo/viewer/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc
index 836413a..1f4a775 100644
--- a/scribo/demo/viewer/help_dialog.cc
+++ b/scribo/demo/viewer/help_dialog.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "help_dialog.hh"
diff --git a/scribo/demo/viewer/help_dialog.hh b/scribo/demo/viewer/help_dialog.hh
index 2b4adcf..41be95d 100644
--- a/scribo/demo/viewer/help_dialog.hh
+++ b/scribo/demo/viewer/help_dialog.hh
@@ -13,18 +13,9 @@
//
// 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 HELP_DIALOG_HH_
-# define HELP_DIALOG_HH_
+#ifndef SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH
+# define SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH
# include <QtGui>
@@ -40,4 +31,4 @@ public slots:
void done();
};
-#endif /* !HELP_DIALOG_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH
diff --git a/scribo/demo/viewer/image_region.cc b/scribo/demo/viewer/image_region.cc
index 037ed56..19ca872 100644
--- a/scribo/demo/viewer/image_region.cc
+++ b/scribo/demo/viewer/image_region.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "image_region.hh"
diff --git a/scribo/demo/viewer/image_region.hh b/scribo/demo/viewer/image_region.hh
index a492b44..41141f7 100644
--- a/scribo/demo/viewer/image_region.hh
+++ b/scribo/demo/viewer/image_region.hh
@@ -13,18 +13,9 @@
//
// 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 IMAGE_REGION_HH_
-# define IMAGE_REGION_HH_
+#ifndef SCRIBO_DEMO_VIEWER_IMAGE_REGION_HH
+# define SCRIBO_DEMO_VIEWER_IMAGE_REGION_HH
# include <QtGui>
# include "common.hh"
@@ -85,4 +76,4 @@ private:
#include "image_region.hxx"
-#endif /* !IMAGE_REGION_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_REGION_HH
diff --git a/scribo/demo/viewer/image_region.hxx b/scribo/demo/viewer/image_region.hxx
index 0d23426..5ddd7de 100644
--- a/scribo/demo/viewer/image_region.hxx
+++ b/scribo/demo/viewer/image_region.hxx
@@ -1,19 +1,31 @@
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
-// Document layout viewer.
+// This file is part of Olena.
//
-// Copyright (C) 2009 Florent D'Halluin.
+// 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.
//
-// This program 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; either version 2
-// of the License, or (at your option) any later version.
+// 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.
//
-// The complete GNU General Public Licence Notice can be found as the
-// `COPYING' file in the root directory.
+// 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 IMAGE_REGION_HXX_
-# define IMAGE_REGION_HXX_
+#ifndef IMAGE_REGION_HXX_
+# define IMAGE_REGION_HXX_
# include "image_region.hh"
@@ -91,4 +103,4 @@ ImageRegion::shape() const
return shape_;
}
-#endif /* !IMAGE_REGION_HXX_ */
+#endif /* !IMAGE_REGION_HXX_ */
diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc
index 850647f..2c56113 100644
--- a/scribo/demo/viewer/image_scene.cc
+++ b/scribo/demo/viewer/image_scene.cc
@@ -13,15 +13,7 @@
//
// 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.
+
#include "image_scene.hh"
#include "image_region.hh"
diff --git a/scribo/demo/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh
index 4c417b0..136f1a2 100644
--- a/scribo/demo/viewer/image_scene.hh
+++ b/scribo/demo/viewer/image_scene.hh
@@ -1,4 +1,3 @@
-
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -14,18 +13,9 @@
//
// 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 IMAGE_SCENE_HH_
-# define IMAGE_SCENE_HH_
+
+#ifndef SCRIBO_DEMO_VIEWER_IMAGE_SCENE_HH
+# define SCRIBO_DEMO_VIEWER_IMAGE_SCENE_HH
# include <QtGui>
@@ -52,4 +42,4 @@ private:
QVector<ImageRegion*> region_vector_;
};
-#endif /* !IMAGE_SCENE_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_SCENE_HH
diff --git a/scribo/demo/viewer/image_view.cc b/scribo/demo/viewer/image_view.cc
index 05a85e8..bb34eb7 100644
--- a/scribo/demo/viewer/image_view.cc
+++ b/scribo/demo/viewer/image_view.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "image_view.hh"
diff --git a/scribo/demo/viewer/image_view.hh b/scribo/demo/viewer/image_view.hh
index ab48a36..622999b 100644
--- a/scribo/demo/viewer/image_view.hh
+++ b/scribo/demo/viewer/image_view.hh
@@ -13,18 +13,9 @@
//
// 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 IMAGE_VIEW_HH_
-# define IMAGE_VIEW_HH_
+
+#ifndef SCRIBO_DEMO_VIEWER_IMAGE_VIEW_HH
+# define SCRIBO_DEMO_VIEWER_IMAGE_VIEW_HH
# include <QtGui>
@@ -48,4 +39,4 @@ signals:
void scaleUpdated(qreal scale);
};
-#endif /* !IMAGE_VIEW_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_VIEW_HH
diff --git a/scribo/demo/viewer/image_widget.cc b/scribo/demo/viewer/image_widget.cc
index 3e3f241..e9e5e79 100644
--- a/scribo/demo/viewer/image_widget.cc
+++ b/scribo/demo/viewer/image_widget.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "image_widget.hh"
#include "image_view.hh"
diff --git a/scribo/demo/viewer/image_widget.hh b/scribo/demo/viewer/image_widget.hh
index a3f51e4..826b873 100644
--- a/scribo/demo/viewer/image_widget.hh
+++ b/scribo/demo/viewer/image_widget.hh
@@ -13,18 +13,9 @@
//
// 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 IMAGE_WIDGET_HH_
-# define IMAGE_WIDGET_HH_
+
+#ifndef SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH
+# define SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH
# include <QtGui>
@@ -49,4 +40,4 @@ private:
ImageView* view_;
};
-#endif /* !IMAGE_WIDGET_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index f567992..47cfbcf 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "key_widget.hh"
#include "common.hh"
diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh
index d261ec6..fd0b514 100644
--- a/scribo/demo/viewer/key_widget.hh
+++ b/scribo/demo/viewer/key_widget.hh
@@ -13,18 +13,9 @@
//
// 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 KEY_WIDGET_HH_
-# define KEY_WIDGET_HH_
+#ifndef SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH
+# define SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH
# include <QtGui>
# include "common.hh"
@@ -61,4 +52,4 @@ private:
QTreeWidgetItem* regions_;
};
-#endif /* !KEY_WIDGET_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH
diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc
index b55ad84..76d4494 100644
--- a/scribo/demo/viewer/main.cc
+++ b/scribo/demo/viewer/main.cc
@@ -13,20 +13,16 @@
//
// 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.
#include <QtGui>
#include <iostream>
+#undef MLN_WO_GLOBAL_VARS
#include "viewer.hh"
+#include <mln/labeling/colorize.hh>
+#include <mln/math/pi.hh>
+#include <mln/io/magick/load.hh>
+#include <scribo/make/debug_filename.hh>
int main(int argc, char** argv)
{
diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
index 2d10bd7..df68960 100644
--- a/scribo/demo/viewer/xml_widget.cc
+++ b/scribo/demo/viewer/xml_widget.cc
@@ -13,15 +13,6 @@
//
// 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.
#include "xml_widget.hh"
diff --git a/scribo/demo/viewer/xml_widget.hh b/scribo/demo/viewer/xml_widget.hh
index b80835b..b7cd868 100644
--- a/scribo/demo/viewer/xml_widget.hh
+++ b/scribo/demo/viewer/xml_widget.hh
@@ -13,18 +13,9 @@
//
// 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 XML_WIDGET_HH_
-# define XML_WIDGET_HH_
+
+#ifndef SCRIBO_DEMO_VIEWER_XML_WIDGET_HH
+# define SCRIBO_DEMO_VIEWER_XML_WIDGET_HH
# include <QtGui>
# include <QDomNode>
@@ -54,4 +45,4 @@ private:
QMap<QTreeWidgetItem*, QDomNode> node_map_;
};
-#endif /* !XML_WIDGET_HH_ */
+#endif // ! SCRIBO_DEMO_VIEWER_XML_WIDGET_HH
--
1.5.6.5
1
0
last-svn-commit-705-g9dcc9c1 Add configuration widgets in Scribo viewer.
by Guillaume Lazzara 10 Dec '10
by Guillaume Lazzara 10 Dec '10
10 Dec '10
* demo/viewer/config.cc,
* demo/viewer/config.hh,
* demo/viewer/defs.hh,
* demo/viewer/general_options.cc,
* demo/viewer/general_options.hh,
* demo/viewer/general_options.ui,
* demo/viewer/option_widget.cc,
* demo/viewer/option_widget.hh,
* demo/viewer/preferences_dialog.cc,
* demo/viewer/preferences_dialog.hh,
* demo/viewer/preferences_dialog.ui,
* demo/viewer/toolchain_options.cc,
* demo/viewer/toolchain_options.hh,
* demo/viewer/toolchain_options.ui: New.
---
scribo/ChangeLog | 19 ++++
scribo/demo/viewer/config.cc | 156 ++++++++++++++++++++++++++++++
scribo/demo/viewer/config.hh | 69 +++++++++++++
scribo/demo/viewer/defs.hh | 31 ++++++
scribo/demo/viewer/general_options.cc | 60 ++++++++++++
scribo/demo/viewer/general_options.hh | 40 ++++++++
scribo/demo/viewer/general_options.ui | 100 +++++++++++++++++++
scribo/demo/viewer/option_widget.cc | 30 ++++++
scribo/demo/viewer/option_widget.hh | 30 ++++++
scribo/demo/viewer/preferences_dialog.cc | 113 +++++++++++++++++++++
scribo/demo/viewer/preferences_dialog.hh | 45 +++++++++
scribo/demo/viewer/preferences_dialog.ui | 121 +++++++++++++++++++++++
scribo/demo/viewer/toolchain_options.cc | 75 ++++++++++++++
scribo/demo/viewer/toolchain_options.hh | 37 +++++++
scribo/demo/viewer/toolchain_options.ui | 121 +++++++++++++++++++++++
15 files changed, 1047 insertions(+), 0 deletions(-)
create mode 100644 scribo/demo/viewer/config.cc
create mode 100644 scribo/demo/viewer/config.hh
create mode 100644 scribo/demo/viewer/defs.hh
create mode 100644 scribo/demo/viewer/general_options.cc
create mode 100644 scribo/demo/viewer/general_options.hh
create mode 100644 scribo/demo/viewer/general_options.ui
create mode 100644 scribo/demo/viewer/option_widget.cc
create mode 100644 scribo/demo/viewer/option_widget.hh
create mode 100644 scribo/demo/viewer/preferences_dialog.cc
create mode 100644 scribo/demo/viewer/preferences_dialog.hh
create mode 100644 scribo/demo/viewer/preferences_dialog.ui
create mode 100644 scribo/demo/viewer/toolchain_options.cc
create mode 100644 scribo/demo/viewer/toolchain_options.hh
create mode 100644 scribo/demo/viewer/toolchain_options.ui
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index e730400..7829717 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,24 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add configuration widgets in Scribo viewer.
+
+ * demo/viewer/config.cc,
+ * demo/viewer/config.hh,
+ * demo/viewer/defs.hh,
+ * demo/viewer/general_options.cc,
+ * demo/viewer/general_options.hh,
+ * demo/viewer/general_options.ui,
+ * demo/viewer/option_widget.cc,
+ * demo/viewer/option_widget.hh,
+ * demo/viewer/preferences_dialog.cc,
+ * demo/viewer/preferences_dialog.hh,
+ * demo/viewer/preferences_dialog.ui,
+ * demo/viewer/toolchain_options.cc,
+ * demo/viewer/toolchain_options.hh,
+ * demo/viewer/toolchain_options.ui: New.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* src/scribo-cli.in: Add a call to xml2doc.
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/demo/viewer/config.cc b/scribo/demo/viewer/config.cc
new file mode 100644
index 0000000..bf12e95
--- /dev/null
+++ b/scribo/demo/viewer/config.cc
@@ -0,0 +1,156 @@
+// Copyright (C) 2010 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/>.
+
+#include <QDir>
+
+#include "config.hh"
+#include "defs.hh"
+
+// Defines enum of binarization algorithms
+# include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
+
+
+config::config()
+ : QSettings("Olena-Scribo", "viewer")
+{
+
+}
+
+config* config::get_instance()
+{
+ static config * conf = new config();
+ return conf;
+}
+
+
+// Preprocessing
+
+bool config::preprocessing_subsample()
+{
+ return value("preprocessing/subsample", false).toBool();
+}
+
+void config::set_preprocessing_subsample(bool b)
+{
+ setValue("preprocessing/subsample", b);
+}
+
+
+bool config::preprocessing_remove_bg()
+{
+ return value("preprocessing/remove_bg", false).toBool();
+}
+
+void config::set_preprocessing_remove_bg(bool b)
+{
+ setValue("preprocessing/remove_bg", b);
+}
+
+
+bool config::preprocessing_deskew()
+{
+ return value("preprocessing/deskew", false).toBool();
+}
+
+void config::set_preprocessing_deskew(bool b)
+{
+ setValue("preprocessing/deskew", b);
+}
+
+
+bool config::preprocessing_remove_noise()
+{
+ return value("preprocessing/remove_noise", true).toBool();
+}
+
+void config::set_preprocessing_remove_noise(bool b)
+{
+ setValue("preprocessing/remove_noise", b);
+}
+
+
+int config::preprocessing_bin_algo()
+{
+ return value("preprocessing/bin_algo",
+ scribo::toolchain::internal::SauvolaMs).toInt();
+}
+
+void config::set_preprocessing_bin_algo(int algo)
+{
+ setValue("preprocessing/bin_algo", algo);
+}
+
+
+
+// Segmentation
+
+int config::segmentation_find_seps()
+{
+ return value("segmentation/find_seps", defs::LinesAndWhitespaces).toInt();
+}
+
+void config::set_segmentation_find_seps(int seps)
+{
+ setValue("segmentation/find_seps", seps);
+}
+
+
+
+// General options
+
+bool config::general_save_xml_enabled()
+{
+ return value("general/save_xml/enabled", true).toBool();
+}
+
+void config::set_general_save_xml_enabled(bool b)
+{
+ setValue("general/save_xml/enabled", b);
+}
+
+
+bool config::general_save_xml_same_dir()
+{
+ return value("general/save_xml/same_dir", true).toBool();
+}
+
+void config::set_general_save_xml_same_dir(bool b)
+{
+ setValue("general/save_xml/same_dir", b);
+}
+
+
+bool config::general_save_xml_custom_dir()
+{
+ return value("general/save_xml/custom_dir", false).toBool();
+}
+
+void config::set_general_save_xml_custom_dir(bool b)
+{
+ setValue("general/save_xml/custom_dir", b);
+}
+
+
+QString config::general_save_xml_custom_dir_path()
+{
+ return value("general/save_xml/custom_dir_path", QDir::tempPath()).toString();
+}
+
+void config::set_general_save_xml_custom_dir_path(const QString& path)
+{
+ setValue("general/save_xml/custom_dir_path", path);
+}
+
diff --git a/scribo/demo/viewer/config.hh b/scribo/demo/viewer/config.hh
new file mode 100644
index 0000000..07d193c
--- /dev/null
+++ b/scribo/demo/viewer/config.hh
@@ -0,0 +1,69 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_CONFIG_HH
+# define SCRIBO_DEMO_VIEWER_CONFIG_HH
+
+# include <QSettings>
+
+class config : public QSettings
+{
+public:
+
+ config();
+
+ static config* get_instance();
+
+ // Preprocessing
+ bool preprocessing_subsample();
+ void set_preprocessing_subsample(bool b);
+
+ bool preprocessing_remove_bg();
+ void set_preprocessing_remove_bg(bool b);
+
+ bool preprocessing_deskew();
+ void set_preprocessing_deskew(bool b);
+
+ bool preprocessing_remove_noise();
+ void set_preprocessing_remove_noise(bool b);
+
+ int preprocessing_bin_algo();
+ void set_preprocessing_bin_algo(int algo);
+
+
+ // Segmentation
+ int segmentation_find_seps();
+ void set_segmentation_find_seps(int seps);
+
+
+ // General options
+ bool general_save_xml_enabled();
+ void set_general_save_xml_enabled(bool b);
+
+ bool general_save_xml_same_dir();
+ void set_general_save_xml_same_dir(bool b);
+
+ bool general_save_xml_custom_dir();
+ void set_general_save_xml_custom_dir(bool b);
+
+ QString general_save_xml_custom_dir_path();
+ void set_general_save_xml_custom_dir_path(const QString& path);
+
+
+};
+
+
+#endif // ! SCRIBO_DEMO_VIEWER_CONFIG_HH
diff --git a/scribo/demo/viewer/defs.hh b/scribo/demo/viewer/defs.hh
new file mode 100644
index 0000000..ada4441
--- /dev/null
+++ b/scribo/demo/viewer/defs.hh
@@ -0,0 +1,31 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_DEFS_HH
+# define SCRIBO_DEMO_VIEWER_DEFS_HH
+
+namespace defs
+{
+ enum FindSeparators
+ {
+ Lines,
+ Whitespaces,
+ LinesAndWhitespaces
+ };
+
+} // end of namespace defs
+
+#endif // ! SCRIBO_DEMO_VIEWER_DEFS_HH
diff --git a/scribo/demo/viewer/general_options.cc b/scribo/demo/viewer/general_options.cc
new file mode 100644
index 0000000..50201ff
--- /dev/null
+++ b/scribo/demo/viewer/general_options.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2010 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/>.
+
+#include "general_options.hh"
+#include "config.hh"
+
+
+general_options::general_options(QWidget *parent)
+ : OptionWidget(parent)
+{
+ setupUi(this);
+
+ load_config();
+}
+
+general_options::~general_options()
+{
+}
+
+
+void general_options::load_config()
+{
+ config * const conf = config::get_instance();
+
+ saveXml->setChecked(conf->general_save_xml_enabled());
+ sameDir->setChecked(conf->general_save_xml_same_dir());
+ customDir->setChecked(conf->general_save_xml_custom_dir());
+ customDirValue->setText(conf->general_save_xml_custom_dir_path());
+}
+
+
+void general_options::save_config()
+{
+ config * const conf = config::get_instance();
+
+ conf->set_general_save_xml_enabled(saveXml->isChecked());
+ conf->set_general_save_xml_same_dir(sameDir->isChecked());
+ conf->set_general_save_xml_custom_dir(customDir->isChecked());
+ conf->set_general_save_xml_custom_dir_path(customDirValue->text());
+}
+
+void general_options::on_customDirBrowseBtn_clicked()
+{
+ QString dir = QFileDialog::getExistingDirectory(0, "Choose a directory");
+ if (!dir.isEmpty())
+ customDirValue->setText(dir);
+}
diff --git a/scribo/demo/viewer/general_options.hh b/scribo/demo/viewer/general_options.hh
new file mode 100644
index 0000000..e2fcaae
--- /dev/null
+++ b/scribo/demo/viewer/general_options.hh
@@ -0,0 +1,40 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_GENERAL_OPTIONS_HH
+# define SCRIBO_DEMO_VIEWER_GENERAL_OPTIONS_HH
+
+# include <QtGui>
+# include <general_options.ui.h>
+# include "option_widget.hh"
+
+class general_options : public OptionWidget, private Ui::GeneralOptions
+{
+ Q_OBJECT;
+
+public:
+ general_options(QWidget *parent = 0);
+ ~general_options();
+
+ virtual void load_config();
+ virtual void save_config();
+
+private slots:
+ void on_customDirBrowseBtn_clicked();
+
+};
+
+#endif // ! SCRIBO_DEMO_VIEWER_GENERAL_OPTIONS_HH
diff --git a/scribo/demo/viewer/general_options.ui b/scribo/demo/viewer/general_options.ui
new file mode 100644
index 0000000..5839c27
--- /dev/null
+++ b/scribo/demo/viewer/general_options.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>GeneralOptions</class>
+ <widget class="QWidget" name="GeneralOptions">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="saveXml">
+ <property name="title">
+ <string>Save segmentation results</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QRadioButton" name="sameDir">
+ <property name="text">
+ <string>In the same directory as the input image</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="customDir">
+ <property name="text">
+ <string>In the following directory</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Maximum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="customDirValue"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="customDirBrowseBtn">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/scribo/demo/viewer/option_widget.cc b/scribo/demo/viewer/option_widget.cc
new file mode 100644
index 0000000..4557749
--- /dev/null
+++ b/scribo/demo/viewer/option_widget.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2010 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/>.
+
+# include "option_widget.hh"
+
+OptionWidget::OptionWidget(QWidget * parent)
+ : QWidget(parent)
+{
+}
+
+void OptionWidget::save_config()
+{
+}
+
+void OptionWidget::load_config()
+{
+}
diff --git a/scribo/demo/viewer/option_widget.hh b/scribo/demo/viewer/option_widget.hh
new file mode 100644
index 0000000..6b24e90
--- /dev/null
+++ b/scribo/demo/viewer/option_widget.hh
@@ -0,0 +1,30 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_OPTION_WIDGET_HH
+# define SCRIBO_DEMO_VIEWER_OPTION_WIDGET_HH
+
+#include <QWidget>
+
+struct OptionWidget : public QWidget
+{
+ OptionWidget(QWidget * parent);
+
+ virtual void load_config();
+ virtual void save_config();
+};
+
+#endif // ! SCRIBO_DEMO_VIEWER_OPTION_WIDGET_HH
diff --git a/scribo/demo/viewer/preferences_dialog.cc b/scribo/demo/viewer/preferences_dialog.cc
new file mode 100644
index 0000000..dfd6061
--- /dev/null
+++ b/scribo/demo/viewer/preferences_dialog.cc
@@ -0,0 +1,113 @@
+// Copyright (C) 2010 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/>.
+
+#include "preferences_dialog.hh"
+#include "toolchain_options.hh"
+#include "general_options.hh"
+
+
+
+preferences_dialog::preferences_dialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+
+ // We may want to remove this useless object in the ui file.
+ delete widget;
+
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ load_option_list();
+ optionList->setCurrentRow(0);
+}
+
+preferences_dialog::~preferences_dialog()
+{
+}
+
+
+void preferences_dialog::load_option_list()
+{
+ static const char *options[] = { "General", "Toolchain", 0 };
+
+ int i;
+ for (i = 0; options[i]; ++i)
+ optionList->insertItem(i, options[i]);
+
+ widgets_.fill(0, i);
+}
+
+void preferences_dialog::on_optionList_currentRowChanged(int row)
+{
+ select_option_widget(row);
+}
+
+
+void preferences_dialog::select_option_widget(int row)
+{
+ if (row >= widgets_.size())
+ {
+ qDebug() << "select_option_widget - Hu? Something wrong... Invalid row";
+ return;
+ }
+
+ if (!widgets_[row])
+ {
+ switch (row)
+ {
+ case 0:
+ widgets_[0] = new general_options(this);
+ break;
+
+ case 1:
+ widgets_[1] = new toolchain_options(this);
+ break;
+
+ default:
+ qDebug() << "select_option_widget - Hu? Something wrong...";
+ }
+ }
+
+ if (horizontalLayout_2->count() == 2)
+ {
+ QWidget *current_widget = horizontalLayout_2->itemAt(1)->widget();
+ horizontalLayout_2->removeWidget(current_widget);
+ current_widget->hide();
+ }
+
+ horizontalLayout_2->insertWidget(1, widgets_[row]);
+ widgets_[row]->show();
+}
+
+
+void preferences_dialog::accept()
+{
+ for (int i = 0; i < widgets_.size(); ++i)
+ if (widgets_[i])
+ {
+ static_cast<OptionWidget *>(widgets_[i])->save_config();
+ delete widgets_[i];
+ }
+ QDialog::accept();
+}
+
+
+void preferences_dialog::reject()
+{
+ for (int i = 0; i < widgets_.size(); ++i)
+ delete widgets_[i];
+ QDialog::reject();
+}
diff --git a/scribo/demo/viewer/preferences_dialog.hh b/scribo/demo/viewer/preferences_dialog.hh
new file mode 100644
index 0000000..0368bbe
--- /dev/null
+++ b/scribo/demo/viewer/preferences_dialog.hh
@@ -0,0 +1,45 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
+# define SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
+
+# include <QtGui>
+# include <preferences_dialog.ui.h>
+
+class preferences_dialog : public QDialog, private Ui::PreferencesDialog
+{
+ Q_OBJECT;
+
+public:
+ preferences_dialog(QWidget *parent = 0);
+ ~preferences_dialog();
+
+private slots:
+ void on_optionList_currentRowChanged(int row);
+ virtual void accept();
+ virtual void reject();
+
+private: // Methods
+ void load_option_list();
+ void select_option_widget(int row);
+
+private: // Attributes
+ QVector<QWidget *> widgets_;
+
+};
+
+#endif // ! SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
diff --git a/scribo/demo/viewer/preferences_dialog.ui b/scribo/demo/viewer/preferences_dialog.ui
new file mode 100644
index 0000000..1d40563
--- /dev/null
+++ b/scribo/demo/viewer/preferences_dialog.ui
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesDialog</class>
+ <widget class="QDialog" name="PreferencesDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>668</width>
+ <height>418</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Preferences</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Preferences</span></p></body></html></string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QListWidget" name="optionList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="widget" native="true"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>PreferencesDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>PreferencesDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/scribo/demo/viewer/toolchain_options.cc b/scribo/demo/viewer/toolchain_options.cc
new file mode 100644
index 0000000..6024ff3
--- /dev/null
+++ b/scribo/demo/viewer/toolchain_options.cc
@@ -0,0 +1,75 @@
+// Copyright (C) 2010 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/>.
+
+#include "defs.hh"
+#include "toolchain_options.hh"
+#include "config.hh"
+
+// Defines enum of binarization algorithms
+# include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
+
+using namespace scribo::toolchain::internal;
+
+toolchain_options::toolchain_options(QWidget *parent)
+ : OptionWidget(parent)
+{
+ setupUi(this);
+
+ bin_algoCbox->insertItem(Convert, "Violent convert");
+ bin_algoCbox->insertItem(Sauvola, "Local threshold");
+ bin_algoCbox->insertItem(SauvolaMs,
+ "Local threshold multiscale");
+
+ find_sepsCbox->insertItem(defs::Lines, "Lines");
+ find_sepsCbox->insertItem(defs::Whitespaces, "Whitespaces");
+ find_sepsCbox->insertItem(defs::LinesAndWhitespaces, "Lines and whitespaces");
+
+ load_config();
+}
+
+toolchain_options::~toolchain_options()
+{
+}
+
+
+void toolchain_options::load_config()
+{
+ config * const conf = config::get_instance();
+
+ // Preprocessing
+ subsampleCb->setChecked(conf->preprocessing_subsample());
+ remove_bgCb->setChecked(conf->preprocessing_remove_bg());
+ deskewCb->setChecked(conf->preprocessing_deskew());
+ remove_noiseCb->setChecked(conf->preprocessing_remove_noise());
+ bin_algoCbox->setCurrentIndex(conf->preprocessing_bin_algo());
+
+ // Page segmentation
+ find_sepsCbox->setCurrentIndex(conf->segmentation_find_seps());
+}
+
+
+void toolchain_options::save_config()
+{
+ config * const conf = config::get_instance();
+
+ conf->set_preprocessing_subsample(subsampleCb->isChecked());
+ conf->set_preprocessing_remove_bg(remove_bgCb->isChecked());
+ conf->set_preprocessing_deskew(deskewCb->isChecked());
+ conf->set_preprocessing_remove_noise(remove_noiseCb->isChecked());
+ conf->set_preprocessing_bin_algo(bin_algoCbox->currentIndex());
+
+ conf->set_segmentation_find_seps(find_sepsCbox->currentIndex());
+}
diff --git a/scribo/demo/viewer/toolchain_options.hh b/scribo/demo/viewer/toolchain_options.hh
new file mode 100644
index 0000000..afad3e7
--- /dev/null
+++ b/scribo/demo/viewer/toolchain_options.hh
@@ -0,0 +1,37 @@
+// Copyright (C) 2010 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/>.
+
+#ifndef SCRIBO_DEMO_VIEWER_TOOLCHAIN_OPTIONS_HH
+# define SCRIBO_DEMO_VIEWER_TOOLCHAIN_OPTIONS_HH
+
+# include <QtGui>
+# include <toolchain_options.ui.h>
+# include "option_widget.hh"
+
+class toolchain_options : public OptionWidget, private Ui::ToolchainOptions
+{
+ Q_OBJECT;
+
+public:
+ toolchain_options(QWidget *parent = 0);
+ ~toolchain_options();
+
+ void load_config();
+ void save_config();
+
+};
+
+#endif // ! SCRIBO_DEMO_VIEWER_TOOLCHAIN_OPTIONS_HH
diff --git a/scribo/demo/viewer/toolchain_options.ui b/scribo/demo/viewer/toolchain_options.ui
new file mode 100644
index 0000000..748696d
--- /dev/null
+++ b/scribo/demo/viewer/toolchain_options.ui
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ToolchainOptions</class>
+ <widget class="QWidget" name="ToolchainOptions">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>492</width>
+ <height>264</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Configure toolchain</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Preprocessing</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="subsampleCb">
+ <property name="text">
+ <string>Run on subsampled image</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="remove_bgCb">
+ <property name="text">
+ <string>Remove background (slow)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="deskewCb">
+ <property name="text">
+ <string>Deskew</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="remove_noiseCb">
+ <property name="text">
+ <string>Remove noise</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Binarization method:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="bin_algoCbox"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Page segmentation</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Find separators</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="find_sepsCbox"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--
1.5.6.5
1
0
last-svn-commit-704-g50bccc1 src/scribo-cli.in: Add a call to xml2doc.
by Guillaume Lazzara 10 Dec '10
by Guillaume Lazzara 10 Dec '10
10 Dec '10
---
scribo/ChangeLog | 4 ++++
scribo/src/scribo-cli.in | 13 +++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index eeaeac1..e730400 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * src/scribo-cli.in: Add a call to xml2doc.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Small fixes.
* scribo/text/recognition.hh: Add comments.
diff --git a/scribo/src/scribo-cli.in b/scribo/src/scribo-cli.in
index e271810..96fcdf2 100755
--- a/scribo/src/scribo-cli.in
+++ b/scribo/src/scribo-cli.in
@@ -55,6 +55,15 @@ List of available COMMAND argument:
pic-ocr Localize and try to recognize text.
+
+ Tools
+ -----
+
+
+ * xml2doc Convert the XML results of document toolchains
+ into user documents (HTML, PDF...).
+
+
Algorithms
----------
@@ -100,6 +109,10 @@ run_cmd()
$bdir/text_recognition_in_picture $@
;;
+ xml2doc)
+ $bdir/scribo-xml2doc $@
+ ;;
+
*)
cmd_bin=`echo $cmd | sed -e 's/-/_/g'`
if test -f $bdir/$cmd_bin; then
--
1.5.6.5
1
0
* scribo/text/recognition.hh: Add comments.
* src/debug/show_links_single_right.cc: Fix an invalid
incrementation.
* src/Makefile.am: Add Magickxx flags for pbm_text_in_doc.
* src/binarization/sauvola_ms.cc,
* src/text_in_doc_preprocess.cc,
* src/text_in_picture_neg.cc,
* src/text_recognition_in_picture.cc: Initialize LibMagick++.
---
scribo/ChangeLog | 16 ++++++++++++++++
scribo/scribo/text/recognition.hh | 9 +++++++--
scribo/src/Makefile.am | 7 ++++---
scribo/src/binarization/sauvola_ms.cc | 2 ++
scribo/src/debug/show_links_single_right.cc | 4 ++--
scribo/src/text_in_doc_preprocess.cc | 2 ++
scribo/src/text_in_picture_neg.cc | 2 ++
scribo/src/text_recognition_in_picture.cc | 2 ++
8 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 941fc35..eeaeac1 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,21 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Small fixes.
+
+ * scribo/text/recognition.hh: Add comments.
+
+ * src/debug/show_links_single_right.cc: Fix an invalid
+ incrementation.
+
+ * src/Makefile.am: Add Magickxx flags for pbm_text_in_doc.
+
+ * src/binarization/sauvola_ms.cc,
+ * src/text_in_doc_preprocess.cc,
+ * src/text_in_picture_neg.cc,
+ * src/text_recognition_in_picture.cc: Initialize LibMagick++.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new options to command lines tools.
* scribo/src/content_in_doc.cc,
diff --git a/scribo/scribo/text/recognition.hh b/scribo/scribo/text/recognition.hh
index ab5e3e2..8b243bd 100644
--- a/scribo/scribo/text/recognition.hh
+++ b/scribo/scribo/text/recognition.hh
@@ -148,6 +148,7 @@ namespace scribo
const component_set<L>& comp_set = lines.components();
const L& lbl = comp_set.labeled_image();
+ // Extract each character components to create the line image.
const mln::util::array<component_id_t>& comps = lines(i).components();
for_all_elements(e, lines(i).components())
{
@@ -157,12 +158,16 @@ namespace scribo
}
/// Improve text quality.
-
- /// text_ima_cleaned domain may be larger than text_ima's.
text::clean_inplace(lines(i), text_ima);
// Make sure characters are isolated from the borders.
// Help Tesseract.
+ //
+ // FIXME: can be improved! We need a morpher for a constant
+ // extension set to false (avoid data::fill), a morpher for
+ // translating the domain to (0,0) (avoid the creation of a
+ // new image), change the default border::thickness to 0 and a
+ // morpher to enlarge the domain to a part of the extension.
mln_domain(I) lbox = text_ima.domain();
lbox.enlarge(lines(i).char_space() + 2);
I line_image(lbox, 0); // Make sure there is no border!
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index 2c318a1..d6275fd 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -35,6 +35,8 @@ SUBDIRS = \
utilexec_PROGRAMS =
+if HAVE_MAGICKXX
+
if HAVE_TESSERACT
utilexec_PROGRAMS += pbm_text_in_doc
@@ -42,17 +44,16 @@ if HAVE_TESSERACT
pbm_text_in_doc_CPPFLAGS = $(AM_CPPFLAGS) \
$(TESSERACT_CPPFLAGS) \
$(TIFF_CPPFLAGS) \
+ $(MAGICKXX_CPPFLAGS) \
-I$(top_builddir)
pbm_text_in_doc_LDFLAGS = $(AM_LDFLAGS) \
$(TESSERACT_LDFLAGS) \
$(TIFF_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
-lpthread
endif HAVE_TESSERACT
-
-if HAVE_MAGICKXX
-
utilexec_PROGRAMS += text_in_doc_preprocess
text_in_doc_preprocess_SOURCES = text_in_doc_preprocess.cc
text_in_doc_preprocess_CPPFLAGS = $(AM_CPPFLAGS) \
diff --git a/scribo/src/binarization/sauvola_ms.cc b/scribo/src/binarization/sauvola_ms.cc
index 7c3bcf0..0b001f2 100644
--- a/scribo/src/binarization/sauvola_ms.cc
+++ b/scribo/src/binarization/sauvola_ms.cc
@@ -82,6 +82,8 @@ int main(int argc, char *argv[])
"input.* output.pbm <w> <s> <k>",
args_desc);
+ Magick::InitializeMagick(*argv);
+
trace::entering("main");
// Window size
diff --git a/scribo/src/debug/show_links_single_right.cc b/scribo/src/debug/show_links_single_right.cc
index 632d082..2392e62 100644
--- a/scribo/src/debug/show_links_single_right.cc
+++ b/scribo/src/debug/show_links_single_right.cc
@@ -98,7 +98,7 @@ namespace scribo
else
{
P tmp = p;
- ++tmp.col();
+ --tmp.col();
mln::draw::line(output_, start_point, tmp, literal::red);
}
@@ -109,7 +109,7 @@ namespace scribo
void compute_next_site_(P& p)
{
- --p.col();
+ ++p.col();
}
diff --git a/scribo/src/text_in_doc_preprocess.cc b/scribo/src/text_in_doc_preprocess.cc
index b731272..8dd918c 100644
--- a/scribo/src/text_in_doc_preprocess.cc
+++ b/scribo/src/text_in_doc_preprocess.cc
@@ -60,6 +60,8 @@ int main(int argc, char* argv[])
"input.* output.pbm <enable fg/bg> <lambda>",
args_desc);
+ Magick::InitializeMagick(*argv);
+
image2d<value::rgb8> input_rgb;
io::magick::load(input_rgb, argv[1]);
diff --git a/scribo/src/text_in_picture_neg.cc b/scribo/src/text_in_picture_neg.cc
index 7d6694a..c1a4317 100644
--- a/scribo/src/text_in_picture_neg.cc
+++ b/scribo/src/text_in_picture_neg.cc
@@ -142,6 +142,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]);
diff --git a/scribo/src/text_recognition_in_picture.cc b/scribo/src/text_recognition_in_picture.cc
index b94ed0b..a5f93a7 100644
--- a/scribo/src/text_recognition_in_picture.cc
+++ b/scribo/src/text_recognition_in_picture.cc
@@ -223,6 +223,8 @@ int main(int argc, char* argv[])
trace::entering("main");
+ Magick::InitializeMagick(*argv);
+
image2d<value::rgb8> input_rgb;
mln::io::magick::load(input_rgb, argv[1]);
--
1.5.6.5
1
0
last-svn-commit-702-gcb3d4f6 Add new options to command lines tools.
by Guillaume Lazzara 10 Dec '10
by Guillaume Lazzara 10 Dec '10
10 Dec '10
* scribo/src/content_in_doc.cc,
* scribo/src/pbm_text_in_doc.cc: Here.
---
scribo/ChangeLog | 7 ++++++
scribo/src/content_in_doc.cc | 49 ++++++++++++++++++++++++++++++++++------
scribo/src/pbm_text_in_doc.cc | 24 ++++++++++++++++---
3 files changed, 68 insertions(+), 12 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 5042dc0..941fc35 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new options to command lines tools.
+
+ * scribo/src/content_in_doc.cc,
+ * scribo/src/pbm_text_in_doc.cc: Here.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Rewrite toolchains as functors.
* scribo/toolchain/internal/content_in_doc_functor.hh,
diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc
index 6613e22..2c31d90 100644
--- a/scribo/src/content_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -72,6 +72,9 @@ const char *args_desc[][2] =
{ "pmin_col", "Col index of the top left corner of the Region of interest." },
{ "pmax_row", "Row index of the bottom right corner of the Region of interest." },
{ "pmax_col", "Col index of the bottom right corner of the Region of interest." },
+ { "find_lines", "Find vertical lines. (Default 1)" },
+ { "find_whitespaces", "Find whitespaces separators. (Default 1)" },
+ { "K", "Sauvola's binarization threshold parameter. (Default: 0.34)" },
{ "debug_dir", "Output directory for debug image" },
{0, 0}
};
@@ -83,16 +86,16 @@ int main(int argc, char* argv[])
using namespace scribo;
using namespace mln;
- if (argc != 3 && argc != 4 && argc != 5 && argc != 8 && argc != 9)
+ if (argc < 3 || (argc > 8 && argc != 12))
return scribo::debug::usage(argv,
"Find text lines and elements in a document",
- "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <debug_dir>",
+ "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <find_lines> <find_whitespaces> <K> <debug_dir>",
args_desc);
bool debug = false;
// Enable debug output.
- if (argc == 5 || argc == 9)
+ if (argc == 8 || argc == 12)
{
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
debug = true;
@@ -104,15 +107,28 @@ int main(int argc, char* argv[])
typedef image2d<scribo::def::lbl_type> L;
scribo::document<L> doc(argv[1]);
+ doc.open();
// Preprocess document
- image2d<bool>
- input = toolchain::text_in_doc_preprocess(doc.image(), false);
-
+ image2d<bool> input;
+ {
+ double K = 0.34;
+ if (argc == 7 || argc == 8 || argc == 11)
+ {
+ if (argc == 7)
+ K = atof(argv[6]);
+ else
+ K = atof(argv[argc - 2]);
+ std::cout << "Using K = " << K << std::endl;
+ }
+
+ image2d<bool> tmp_fg;
+ input = toolchain::text_in_doc_preprocess(doc.image(), false, K);
+ }
// Optional Cropping
point2d crop_shift = literal::origin;
- if (argc >= 8)
+ if (argc >= 12)
{
mln::def::coord
minr = atoi(argv[4]),
@@ -120,6 +136,9 @@ int main(int argc, char* argv[])
maxr = atoi(argv[6]),
maxc = atoi(argv[7]);
+ std::cout << "> Image cropped from (" << minr << "," << minc << ")"
+ << " to (" << maxr << "," << maxc << ")" << std::endl;
+
box2d roi = mln::make::box2d(minr, minc, maxr, maxc);
input = preprocessing::crop_without_localization(input, roi);
crop_shift = point2d(minr, minc);
@@ -131,13 +150,27 @@ int main(int argc, char* argv[])
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
+ bool find_line_seps = true;
+ if (argc >= 5 && argc < 12)
+ find_line_seps = (atoi(argv[4]) != 0);
+
+ bool find_whitespace_seps = true;
+ if (argc >= 6 && argc < 12)
+ find_line_seps = (atoi(argv[5]) != 0);
+
+ std::cout << "Running with the following options :"
+ << "find_lines_seps = " << find_line_seps
+ << " | find_whitespace_seps = " << find_whitespace_seps
+ << " | debug = " << debug
+ << std::endl;
// Run document toolchain.
// Text
std::cout << "Extracting text" << std::endl;
line_set<L>
- lines = scribo::toolchain::text_in_doc(input, denoise, debug);
+ lines = scribo::toolchain::text_in_doc(input, denoise, find_line_seps,
+ find_whitespace_seps, debug);
doc.set_text(lines);
// Elements
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc
index 96cb92b..2240f42 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/pbm_text_in_doc.cc
@@ -65,6 +65,8 @@ for the background." },
{ "pmin_col", "Col index of the top left corner of the Region of interest." },
{ "pmax_row", "Row index of the bottom right corner of the Region of interest." },
{ "pmax_col", "Col index of the bottom right corner of the Region of interest." },
+ { "find_lines", "Find vertical lines. (Default 1)" },
+ { "find_whitespaces", "Find whitespaces separators. (Default 1)" },
{ "debug_dir", "Output directory for debug image" },
{0, 0}
};
@@ -78,13 +80,13 @@ int main(int argc, char* argv[])
if (argc != 3 && argc != 4 && argc != 5 && argc != 8 && argc != 9)
return scribo::debug::usage(argv,
"Find text lines using left/right validation and display x-height in a binarized article.",
- "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <debug_dir>",
+ "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <find_lines> <find_whitespaces> <debug_dir>",
args_desc);
bool debug = false;
// Enable debug output.
- if (argc == 5 || argc == 9)
+ if (argc == 7 || argc == 11)
{
scribo::make::internal::debug_filename_prefix = argv[argc - 1];
debug = true;
@@ -99,7 +101,7 @@ int main(int argc, char* argv[])
// Optional Cropping
point2d crop_shift = literal::origin;
- if (argc >= 8)
+ if (argc >= 11)
{
mln::def::coord
minr = atoi(argv[4]),
@@ -118,10 +120,24 @@ int main(int argc, char* argv[])
bool denoise = (argc > 3 && atoi(argv[3]) != 0);
+ bool find_line_seps = true;
+ if (argc >= 4 && argc < 11)
+ find_line_seps = (atoi(argv[3]) != 0);
+
+ bool find_whitespace_seps = true;
+ if (argc >= 5 && argc < 11)
+ find_line_seps = (atoi(argv[4]) != 0);
+
+ std::cout << "Running with the following options :"
+ << "find_lines_seps = " << find_line_seps
+ << " | find_whitespace_seps = " << find_whitespace_seps
+ << " | debug = " << debug
+ << std::endl;
// Run document toolchain.
line_set<L>
- lines = scribo::toolchain::text_in_doc(input, denoise, debug);
+ lines = scribo::toolchain::text_in_doc(input, denoise, find_line_seps,
+ find_whitespace_seps, debug);
scribo::document<L> doc;
doc.set_filename(argv[1]);
--
1.5.6.5
1
0
10 Dec '10
* scribo/toolchain/internal/content_in_doc_functor.hh,
* scribo/toolchain/internal/text_in_doc_functor.hh,
* scribo/toolchain/internal/text_in_doc_preprocess_functor.hh,
* scribo/toolchain/internal/toolchain_functor.hh: New.
* scribo/toolchain/text_in_doc.hh,
* scribo/toolchain/text_in_doc_preprocess.hh: Make use of the
functors.
---
scribo/ChangeLog | 13 +
.../toolchain/internal/content_in_doc_functor.hh | 415 ++++++++++++++++++++
.../toolchain/internal/text_in_doc_functor.hh | 401 +++++++++++++++++++
.../internal/text_in_doc_preprocess_functor.hh | 304 ++++++++++++++
.../internal/toolchain_functor.hh} | 74 ++--
scribo/scribo/toolchain/text_in_doc.hh | 251 +-----------
scribo/scribo/toolchain/text_in_doc_preprocess.hh | 64 ++--
7 files changed, 1225 insertions(+), 297 deletions(-)
create mode 100644 scribo/scribo/toolchain/internal/content_in_doc_functor.hh
create mode 100644 scribo/scribo/toolchain/internal/text_in_doc_functor.hh
create mode 100644 scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh
copy scribo/scribo/{primitive/link/internal/dmax_default.hh => toolchain/internal/toolchain_functor.hh} (59%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 8a7132a..5042dc0 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,18 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Rewrite toolchains as functors.
+
+ * scribo/toolchain/internal/content_in_doc_functor.hh,
+ * scribo/toolchain/internal/text_in_doc_functor.hh,
+ * scribo/toolchain/internal/text_in_doc_preprocess_functor.hh,
+ * scribo/toolchain/internal/toolchain_functor.hh: New.
+
+ * scribo/toolchain/text_in_doc.hh,
+ * scribo/toolchain/text_in_doc_preprocess.hh: Make use of the
+ functors.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/core/document.hh: Add new methods.
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
new file mode 100644
index 0000000..5459487
--- /dev/null
+++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh
@@ -0,0 +1,415 @@
+// Copyright (C) 2010 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_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_PREPROCESS_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/primitive/extract/elements.hh>
+# include <scribo/primitive/extract/components.hh>
+# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/separators_nonvisible.hh>
+
+# include <scribo/primitive/remove/separators.hh>
+
+# include <scribo/filter/object_links_bbox_h_ratio.hh>
+# include <scribo/filter/objects_small.hh>
+
+# include <scribo/primitive/group/from_single_link.hh>
+
+# include <scribo/primitive/link/merge_double_link.hh>
+# include <scribo/primitive/link/internal/dmax_width_and_height.hh>
+# include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
+# include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
+
+# include <scribo/preprocessing/denoise_fg.hh>
+
+# include <scribo/text/recognition.hh>
+# include <scribo/text/merging.hh>
+
+# include <scribo/make/debug_filename.hh>
+
+# include <scribo/debug/save_bboxes_image.hh>
+# include <scribo/debug/save_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>
+
+# include <scribo/toolchain/internal/toolchain_functor.hh>
+
+# include <scribo/io/xml/save.hh>
+
+
+namespace scribo
+{
+
+ namespace toolchain
+ {
+
+ namespace internal
+ {
+
+
+ template <typename I>
+ struct content_in_doc_functor
+ : public Toolchain_Functor
+ {
+ typedef value::label<30> V;
+ typedef mln_ch_value(I,V) L;
+
+ content_in_doc_functor(const char *doc_filename);
+
+ virtual int nsteps() const;
+
+ virtual void on_xml_saved();
+
+ //===============
+ // Core function
+ //===============
+
+ template <typename J>
+ scribo::document<L> operator()(const Image<J>& original_image,
+ const Image<I>& processed_image);
+
+
+ //=========
+ // Options
+ //=========
+ bool enable_denoising;
+ bool enable_line_seps;
+ bool enable_whitespace_seps;
+ bool enable_debug;
+ bool save_doc_as_xml;
+ bool allow_xml_extensions;
+
+ //============
+ // Parameters
+ //============
+
+ std::string ocr_language;
+ std::string output_file;
+
+ //=========
+ // Results
+ //=========
+ document<L> doc;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ content_in_doc_functor<I>::content_in_doc_functor(const char *doc_filename)
+ : enable_denoising(true),
+ enable_line_seps(true),
+ enable_whitespace_seps(true),
+ enable_debug(false),
+ save_doc_as_xml(false),
+ allow_xml_extensions(true),
+ ocr_language("eng"),
+ output_file("/tmp/foo.xml"),
+ doc(doc_filename)
+ {
+ }
+
+
+ //===============
+ // Core function
+ //===============
+
+ template <typename I>
+ template <typename J>
+ scribo::document<typename content_in_doc_functor<I>::L>
+ content_in_doc_functor<I>::operator()(const Image<J>& original_image,
+ const Image<I>& processed_image)
+ {
+ mln_precondition(exact(original_image).is_valid());
+ mln_precondition(exact(processed_image).is_valid());
+
+ doc.set_image(exact(original_image));
+
+ // Remove separators
+ mln_ch_value(I,bool) separators, input_cleaned;
+ if (enable_line_seps)
+ {
+ on_new_progress_label("Find vertical separators...");
+
+ // Vertical separators
+ separators = primitive::extract::vertical_separators(processed_image, 81);
+
+ on_progress();
+
+ on_new_progress_label("Remove separators...");
+
+ input_cleaned = primitive::remove::separators(processed_image, separators);
+
+ on_progress();
+ }
+
+ mln_ch_value(I,bool) whitespaces;
+ if (enable_whitespace_seps)
+ {
+ // Whitespace separators
+ on_new_progress_label("Find whitespace separators...");
+
+ whitespaces = primitive::extract::separators_nonvisible(processed_image);
+
+ on_progress();
+ }
+
+ if (enable_debug)
+ {
+ if (enable_whitespace_seps)
+ mln::io::pbm::save(whitespaces,
+ scribo::make::debug_filename("whitespaces.pbm"));
+
+ if (enable_line_seps)
+ {
+ mln::io::pbm::save(separators,
+ scribo::make::debug_filename("vseparators.pbm"));
+
+ mln::io::pbm::save(input_cleaned,
+ scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ }
+ }
+
+ // Denoise
+ if (enable_denoising)
+ {
+ on_new_progress_label("Denoise...");
+
+ input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
+
+ if (enable_debug)
+ mln::io::pbm::save(input_cleaned,
+ scribo::make::debug_filename("denoised.pbm"));
+
+ on_progress();
+ }
+
+ /// Finding components.
+ on_new_progress_label("Finding components...");
+
+ V ncomponents;
+ component_set<L>
+ components = scribo::primitive::extract::components(input_cleaned, c8(),
+ ncomponents);
+
+ on_progress();
+
+ /// Set separator components.
+ if (enable_line_seps)
+ components.add_separators(separators);
+ if (enable_whitespace_seps)
+ components.add_separators(whitespaces);
+
+ if (enable_debug)
+ mln::io::pbm::save(components.separators(),
+ scribo::make::debug_filename("all_separators.pbm"));
+
+
+ on_new_progress_label("Filtering components");
+
+ components = scribo::filter::components_small(components, 3);
+
+ on_progress();
+
+
+ /// Linking potential objects
+ 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);
+
+ if (enable_debug)
+ {
+ 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"));
+ }
+
+
+ // Validating left and right links.
+ object_links<L>
+ merged_links = primitive::link::merge_double_link(left_link,
+ right_link);
+
+ on_progress();
+
+
+ on_new_progress_label("Filtering objects");
+
+ // Remove links if bboxes have too different sizes.
+ object_links<L> hratio_filtered_links
+ = filter::object_links_bbox_h_ratio(merged_links, 2.5f);
+
+
+ if (enable_debug)
+ {
+ 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"));
+ }
+
+ on_progress();
+
+
+ on_new_progress_label("Rebuilding lines");
+
+ object_groups<L>
+ groups = primitive::group::from_single_link(hratio_filtered_links);
+
+
+
+ // Construct a line set.
+ line_set<L>
+ lines = scribo::make::line_set(groups);
+
+
+ //===== DEBUG =====
+
+ if (enable_debug)
+ {
+
+ // Bboxes image.
+ scribo::debug::save_bboxes_image(processed_image, lines,
+ scribo::make::debug_filename("step1_bboxes.ppm"));
+
+ // Bboxes enlarged
+ mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines),
+ scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+
+ // 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"));
+
+
+ // 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"));
+
+ }
+ //===== END OF DEBUG =====
+
+
+
+ lines = scribo::text::merging(lines);
+
+
+ if (enable_debug)
+ {
+
+ // 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"));
+
+ // 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"));
+
+ // Bboxes image.
+ scribo::debug::save_bboxes_image(processed_image, lines,
+ scribo::make::debug_filename("step2_bboxes.ppm"));
+
+
+ }
+
+ on_progress();
+
+ on_new_progress_label("Recognizing text");
+
+ scribo::text::recognition(lines, ocr_language.c_str());
+ doc.set_text(lines);
+
+ on_progress();
+
+ // Extract other Elements
+ on_new_progress_label("Extracting Elements");
+ component_set<L>
+ elements = scribo::primitive::extract::elements(doc, original_image);
+ doc.set_elements(elements);
+
+ on_progress();
+
+ // Saving results
+ if (save_doc_as_xml)
+ {
+ on_new_progress_label("Saving results");
+
+ scribo::io::xml::save(doc, output_file, allow_xml_extensions);
+ on_xml_saved();
+
+ on_progress();
+ }
+
+ return doc;
+ }
+
+
+
+ template<typename I>
+ int
+ content_in_doc_functor<I>::nsteps() const
+ {
+ return 7 + enable_denoising + enable_line_seps
+ + enable_whitespace_seps + save_doc_as_xml;
+ }
+
+
+ template<typename I>
+ void
+ content_in_doc_functor<I>::on_xml_saved()
+ {
+ // Nothing
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::toolchain::internal
+
+ } // end of namespace scribo::toolchain
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH
diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
new file mode 100644
index 0000000..701f1e6
--- /dev/null
+++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh
@@ -0,0 +1,401 @@
+// Copyright (C) 2010 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_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_PREPROCESS_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>
+# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/separators_nonvisible.hh>
+
+# include <scribo/primitive/remove/separators.hh>
+
+# include <scribo/filter/object_links_bbox_h_ratio.hh>
+# include <scribo/filter/objects_small.hh>
+
+# include <scribo/primitive/group/from_single_link.hh>
+
+# include <scribo/primitive/link/merge_double_link.hh>
+# include <scribo/primitive/link/internal/dmax_width_and_height.hh>
+# include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
+# include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
+
+# include <scribo/preprocessing/denoise_fg.hh>
+
+# include <scribo/text/recognition.hh>
+# include <scribo/text/merging.hh>
+
+# include <scribo/make/debug_filename.hh>
+
+# include <scribo/debug/save_bboxes_image.hh>
+# include <scribo/debug/save_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>
+
+# include <scribo/toolchain/internal/toolchain_functor.hh>
+
+
+namespace scribo
+{
+
+ namespace toolchain
+ {
+
+ namespace internal
+ {
+
+
+ template <typename I>
+ struct text_in_doc_functor
+ : public Toolchain_Functor
+ {
+ typedef value::label<30> V;
+ typedef mln_ch_value(I,V) L;
+
+ text_in_doc_functor();
+
+ virtual int nsteps() const;
+
+ //===============
+ // Core function
+ //===============
+
+ line_set<L> operator()(const Image<I>& input_);
+
+
+ //=========
+ // Options
+ //=========
+ bool enable_denoising;
+ bool enable_line_seps;
+ bool enable_whitespace_seps;
+ bool enable_debug;
+
+ //============
+ // Parameters
+ //============
+
+ std::string ocr_language;
+
+
+ // Results
+ line_set<L> output;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ text_in_doc_functor<I>::text_in_doc_functor()
+ : enable_denoising(true),
+ enable_line_seps(true),
+ enable_whitespace_seps(true),
+ enable_debug(false),
+ ocr_language("eng")
+ {
+ }
+
+
+ //===============
+ // Core function
+ //===============
+
+ template <typename I>
+ line_set<typename text_in_doc_functor<I>::L>
+ text_in_doc_functor<I>::operator()(const Image<I>& input)
+ {
+ // Remove separators
+ mln_ch_value(I,bool) separators, input_cleaned;
+ if (enable_line_seps)
+ {
+ on_new_progress_label("Find vertical separators...");
+
+ // Vertical separators
+ separators = primitive::extract::vertical_separators(input, 81);
+
+ on_progress();
+
+ on_new_progress_label("Remove separators...");
+
+ input_cleaned = primitive::remove::separators(input, separators);
+
+ on_progress();
+ }
+
+ mln_ch_value(I,bool) whitespaces;
+ if (enable_whitespace_seps)
+ {
+ // Whitespace separators
+ on_new_progress_label("Find whitespace separators...");
+
+ whitespaces = primitive::extract::separators_nonvisible(input);
+
+ on_progress();
+ }
+
+ if (enable_debug)
+ {
+ if (enable_whitespace_seps)
+ mln::io::pbm::save(whitespaces,
+ scribo::make::debug_filename("whitespaces.pbm"));
+
+ if (enable_line_seps)
+ {
+ mln::io::pbm::save(separators,
+ scribo::make::debug_filename("vseparators.pbm"));
+
+ mln::io::pbm::save(input_cleaned,
+ scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ }
+ }
+
+ // Denoise
+ if (enable_denoising)
+ {
+ on_new_progress_label("Denoise...");
+
+ input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
+
+ if (enable_debug)
+ mln::io::pbm::save(input_cleaned,
+ scribo::make::debug_filename("denoised.pbm"));
+
+ on_progress();
+ }
+
+ /// Finding components.
+ on_new_progress_label("Finding components...");
+
+ V ncomponents;
+ component_set<L>
+ components = scribo::primitive::extract::components(input_cleaned, c8(),
+ ncomponents);
+
+ on_progress();
+
+ /// Set separator components.
+ if (enable_line_seps)
+ components.add_separators(separators);
+ if (enable_whitespace_seps)
+ components.add_separators(whitespaces);
+
+ if (enable_debug)
+ mln::io::pbm::save(components.separators(),
+ scribo::make::debug_filename("all_separators.pbm"));
+
+
+ on_new_progress_label("Filtering components");
+
+ components = scribo::filter::components_small(components, 3);
+
+ on_progress();
+
+
+ /// Linking potential objects
+ 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);
+
+ if (enable_debug)
+ {
+ 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"));
+ }
+
+
+ // Validating left and right links.
+ object_links<L>
+ merged_links = primitive::link::merge_double_link(left_link,
+ right_link);
+
+ on_progress();
+
+
+ on_new_progress_label("Filtering objects");
+
+ // Remove links if bboxes have too different sizes.
+ object_links<L> hratio_filtered_links
+ = filter::object_links_bbox_h_ratio(merged_links, 2.5f);
+
+
+ if (enable_debug)
+ {
+ 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"));
+ }
+
+ on_progress();
+
+
+ on_new_progress_label("Rebuilding lines");
+
+ object_groups<L>
+ groups = primitive::group::from_single_link(hratio_filtered_links);
+
+
+
+ // Construct a line set.
+ line_set<L>
+ lines = scribo::make::line_set(groups);
+
+
+ //===== DEBUG =====
+
+ if (enable_debug)
+ {
+
+ // Bboxes image.
+ scribo::debug::save_bboxes_image(input, lines,
+ scribo::make::debug_filename("step1_bboxes.ppm"));
+
+ // Bboxes enlarged
+ mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines),
+ scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
+
+ // 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"));
+
+
+ // 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"));
+
+ }
+ //===== END OF DEBUG =====
+
+
+
+ lines = scribo::text::merging(lines);
+
+
+
+ //===== DEBUG =====
+
+ if (enable_debug)
+ {
+
+ // 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"));
+
+ // 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"));
+
+ // Bboxes image.
+ scribo::debug::save_bboxes_image(input, lines,
+ scribo::make::debug_filename("step2_bboxes.ppm"));
+
+
+ }
+
+
+
+ if (enable_debug)
+ {
+ std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str());
+
+ for_all_lines(l, lines)
+ if (lines(l).tag() != line::Merged
+ && lines(l).tag() != line::Ignored
+ && lines(l).tag() != line::Pathological)
+ {
+ file << lines(l).bbox().pmin().row() << " "
+ << lines(l).bbox().pmin().col() << " "
+ << lines(l).bbox().pmax().row() << " "
+ << lines(l).bbox().pmax().col() << " "
+ << lines(l).card() << " "
+ << lines(l).baseline() << " "
+ << lines(l).x_height() << " "
+ << lines(l).meanline() << " "
+ << lines(l).d_height() << " "
+ << lines(l).a_height() << " "
+ << lines(l).char_space() << " "
+ << lines(l).char_width() << std::endl;
+
+ }
+
+ file.close();
+ }
+
+
+ //===== END OF DEBUG =====
+
+ on_progress();
+
+ on_new_progress_label("Recognizing text");
+
+ scribo::text::recognition(lines, ocr_language.c_str());
+
+ on_progress();
+
+ output = lines;
+ return output;
+ }
+
+
+
+ template<typename I>
+ int
+ text_in_doc_functor<I>::nsteps() const
+ {
+ return 6 + enable_denoising + enable_line_seps
+ + enable_whitespace_seps;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::toolchain::internal
+
+ } // end of namespace scribo::toolchain
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH
diff --git a/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh
new file mode 100644
index 0000000..6a9506b
--- /dev/null
+++ b/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh
@@ -0,0 +1,304 @@
+// Copyright (C) 2010 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_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_PREPROCESS_FUNCTOR_HH
+# define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_PREPROCESS_FUNCTOR_HH
+
+#include <mln/core/concept/image.hh>
+#include <mln/data/transform.hh>
+#include <mln/data/convert.hh>
+#include <mln/fun/v2v/rgb_to_int_u.hh>
+
+#include <mln/subsampling/antialiased.hh>
+#include <scribo/binarization/sauvola.hh>
+#include <scribo/binarization/sauvola_ms.hh>
+
+#include <scribo/preprocessing/split_bg_fg.hh>
+#include <scribo/preprocessing/deskew.hh>
+#include <scribo/preprocessing/denoise.hh>
+
+#include <scribo/toolchain/internal/toolchain_functor.hh>
+
+namespace scribo
+{
+
+ namespace toolchain
+ {
+
+ namespace internal
+ {
+
+ /*! \brief Enum of the binarization algorithms available.
+
+ Convert: Violently convert from color to binary.
+ Sauvola: Local threshold binarization algoritm.
+ SauvolaMs: Multi-scale local threshold binarization algoritm.
+ */
+ enum Binarization_Algo
+ {
+ Convert,
+ Sauvola,
+ SauvolaMs
+ };
+
+
+ /*! \brief Functor performing custom preprocessing algorithms on
+ * documents.
+
+ Whatever the options selected, this functor converts an input
+ image into a graylevel image and try to binarize the latter.
+
+ Optional algorithms can be performed too:
+ - Subsampling (enable_subsample), disabled by default.
+ - Extract Background/Foreground (enable_fg_extraction), split
+ background and foreground objects, disabled by default.
+ - Deskew (enable_deskew), disabled by default.
+ - Denoise (enable_denoise), enabled by default.
+
+ The binarization algorithm can be chosen through
+ binarization_algo option. It can be one of the algorithms
+ detailed in enum Binarization_Algo.
+
+ Few parameters can be set for algorithms:
+
+ - Sauvola:
+ * sauvola_win, the window size used in Sauvola based
+ algorithms (default 101).
+ * sauvola_K, a user parameter for Sauvola's threshold formula
+ (default 0.34).
+
+ - Extract background/foreground
+ * lambda, the maximum area of the possible foreground objects
+ (default 0, auto).
+
+ */
+ template <typename I>
+ struct text_in_doc_preprocess_functor
+ : public Toolchain_Functor
+ {
+
+ text_in_doc_preprocess_functor();
+
+ virtual int nsteps() const;
+
+ //===============
+ // Core function
+ //===============
+
+ mln_ch_value(I,bool) operator()(const Image<I>& input_);
+
+
+ //=========
+ // Options
+ //=========
+
+ // Settings
+ bool enable_subsample;
+ bool enable_fg_extraction;
+ bool enable_deskew;
+ bool enable_denoising;
+
+ Binarization_Algo binarization_algo;
+
+ unsigned sauvola_win;
+ double sauvola_K;
+ unsigned lambda;
+
+ // Results
+ mln_concrete(I) fg;
+ mln_concrete(I) bg;
+ image2d<bool> output;
+
+ private: // Methods
+ unsigned find_best_scale(const Image<I>& ima_);
+
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ text_in_doc_preprocess_functor<I>::text_in_doc_preprocess_functor()
+ : enable_subsample(false),
+ enable_fg_extraction(false),
+ enable_deskew(false),
+ enable_denoising(false),
+ binarization_algo(SauvolaMs),
+ sauvola_win(101),
+ sauvola_K(0.34),
+ lambda(0)
+ {
+ }
+
+
+ //===============
+ // Core function
+ //===============
+
+ template <typename I>
+ mln_ch_value(I,bool)
+ text_in_doc_preprocess_functor<I>::operator()(const Image<I>& input_)
+ {
+ trace::entering("scribo::toolchain::text_in_doc_preprocess");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ mln_concrete(I) input_rgb = input;
+
+ // Subsample
+ //----------
+ if (enable_subsample)
+ {
+ on_new_progress_label("Subsample");
+
+ input_rgb = mln::subsampling::antialiased(input_rgb,
+ find_best_scale(input_rgb));
+
+ on_progress();
+ }
+
+
+ // Remove background
+ //------------------
+ if (enable_fg_extraction)
+ {
+ on_new_progress_label("Foreground Extraction");
+
+ typedef mln::util::couple<mln_concrete(I), mln_concrete(I)> res_t;
+
+ unsigned rlambda = lambda;
+ if (!lambda)
+ rlambda = 1.2 * (input.nrows() + input.ncols());
+
+ res_t res = scribo::preprocessing::split_bg_fg(input_rgb, rlambda, 32);
+
+ bg = res.first();
+ fg = res.second();
+ input_rgb = res.second();
+
+ on_progress();
+ }
+
+
+ // Convert to grayscale image (always happens).
+ //---------------------------------------------
+ on_new_progress_label("Convert to gray-scale image");
+ image2d<value::int_u8>
+ intensity_ima = mln::data::transform(input_rgb,
+ mln::fun::v2v::rgb_to_int_u<8>());
+ on_progress();
+
+
+ // Deskew
+ //-------
+ if (enable_deskew)
+ {
+ on_new_progress_label("Deskew");
+
+ intensity_ima = scribo::preprocessing::deskew(intensity_ima);
+
+ on_progress();
+ }
+
+
+ // Binarization (always happens)
+ //------------------------------
+ on_new_progress_label("Binarization");
+
+ if (binarization_algo == Sauvola)
+ {
+ on_new_progress_label("Binarization (Sauvola)");
+ output = scribo::binarization::sauvola(intensity_ima);
+ }
+ else if (binarization_algo == SauvolaMs)
+ {
+ on_new_progress_label("Binarization (Sauvola Multi-scale)");
+ output = scribo::binarization::sauvola_ms(intensity_ima,
+ sauvola_win, 3, sauvola_K);
+ }
+ else // binarization_algo == Convert
+ {
+ on_new_progress_label("Binary conversion");
+ output = mln::data::convert(bool(), intensity_ima);
+ }
+
+ on_progress();
+
+
+ // Denoise
+ //--------
+ if (enable_denoising)
+ {
+ on_new_progress_label("Remove noise");
+
+ output = scribo::preprocessing::denoise(output, c8(), 2, 2);
+
+ on_progress();
+ }
+
+ return output;
+ }
+
+
+
+ template<typename I>
+ int
+ text_in_doc_preprocess_functor<I>::nsteps() const
+ {
+ return 2 + enable_denoising + enable_deskew
+ + enable_fg_extraction + enable_subsample;
+ }
+
+
+ template <typename I>
+ unsigned
+ text_in_doc_preprocess_functor<I>::find_best_scale(const Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ if (ima.nrows() > 2500
+ && ima.nrows() < 5000
+ && ima.ncols() > 2500
+ && ima.ncols() < 5000)
+ return 2;
+
+ if (ima.nrows() > 5000
+ && ima.ncols() > 5000)
+ return 3;
+
+ return 1;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::toolchain::internal
+
+ } // end of namespace scribo::toolchain
+
+} // end of namespace scribo
+
+#endif // ! SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_PREPROCESS_FUNCTOR_HH
diff --git a/scribo/scribo/primitive/link/internal/dmax_default.hh b/scribo/scribo/toolchain/internal/toolchain_functor.hh
similarity index 59%
copy from scribo/scribo/primitive/link/internal/dmax_default.hh
copy to scribo/scribo/toolchain/internal/toolchain_functor.hh
index b4106a9..d10ea28 100644
--- a/scribo/scribo/primitive/link/internal/dmax_default.hh
+++ b/scribo/scribo/toolchain/internal/toolchain_functor.hh
@@ -23,62 +23,72 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_DMAX_DEFAULT_HH
-# define SCRIBO_PRIMITIVE_LINK_INTERNAL_DMAX_DEFAULT_HH
-
-/// \file
-///
-/// Default class for dmax functors.
-
-# include <scribo/primitive/link/internal/dmax_functor_base.hh>
-
+#ifndef SCRIBO_TOOLCHAIN_INTERNAL_TOOLCHAIN_FUNCTOR_HH
+# define SCRIBO_TOOLCHAIN_INTERNAL_TOOLCHAIN_FUNCTOR_HH
namespace scribo
{
- namespace primitive
+ namespace toolchain
{
- namespace link
+ namespace internal
{
- namespace internal
+ class Toolchain_Functor
{
+ public:
+ Toolchain_Functor();
- /// \brief Base class for dmax functors.
- class dmax_default : public dmax_functor_base<dmax_default>
- {
- typedef dmax_functor_base<dmax_default> super_;
+ virtual int nsteps() const = 0;
- public:
- dmax_default(const float& dmax_factor);
- protected:
- using super_::dmax_factor_;
- };
+ //==========
+ // Triggers
+ //==========
+
+ virtual void on_progress();
+ virtual void on_new_progress_label(const char *label);
+
+ // Attributes
+ bool verbose;
+ };
# ifndef MLN_INCLUDE_ONLY
+ inline
+ Toolchain_Functor::Toolchain_Functor()
+ : verbose(true)
+ {
+ }
+
- inline
- dmax_default::dmax_default(const float& dmax_factor)
- : super_(dmax_factor)
- {
- }
+ //==========
+ // Triggers
+ //==========
+ inline
+ void Toolchain_Functor::on_progress()
+ {
+ // Nothing
+ }
-# endif // ! MLN_INCLUDE_ONLY
+ inline
+ void Toolchain_Functor::on_new_progress_label(const char *label)
+ {
+ if (verbose)
+ std::cout << label << std::endl;
+ }
+# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::primitive::link::internal
- } // end of namespace scribo::primitive::link
+ } // end of namespace scribo::toolchain::internal
- } // end of namespace scribo::primitive
+ } // end of namespace scribo::toolchain
} // end of namespace scribo
-
-#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_DMAX_DEFAULT_HH
+#endif // ! SCRIBO_TOOLCHAIN_INTERNAL_TOOLCHAIN_FUNCTOR_HH
diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh
index 82094d4..0ad6cf3 100644
--- a/scribo/scribo/toolchain/text_in_doc.hh
+++ b/scribo/scribo/toolchain/text_in_doc.hh
@@ -31,38 +31,7 @@
///
/// Extract text from a document.
-# include <mln/io/ppm/save.hh>
-
-# include <scribo/core/def/lbl_type.hh>
-
-# include <scribo/primitive/extract/components.hh>
-# include <scribo/primitive/extract/vertical_separators.hh>
-# include <scribo/primitive/extract/separators_nonvisible.hh>
-
-# include <scribo/primitive/remove/separators.hh>
-
-# include <scribo/filter/object_links_bbox_h_ratio.hh>
-# include <scribo/filter/objects_small.hh>
-
-# include <scribo/primitive/group/from_single_link.hh>
-
-# include <scribo/primitive/link/merge_double_link.hh>
-# include <scribo/primitive/link/internal/dmax_width_and_height.hh>
-# include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
-# include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
-
-# include <scribo/preprocessing/denoise_fg.hh>
-
-# include <scribo/text/recognition.hh>
-# include <scribo/text/merging.hh>
-
-# include <scribo/make/debug_filename.hh>
-
-# include <scribo/debug/save_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>
-
+# include <scribo/toolchain/internal/text_in_doc_functor.hh>
namespace scribo
{
@@ -75,7 +44,10 @@ namespace scribo
template <typename I>
line_set<mln_ch_value(I, def::lbl_type)>
- text_in_doc(const Image<I>& input, bool denoise, bool debug = false);
+ text_in_doc(const Image<I>& input, bool denoise,
+ bool find_line_seps = true,
+ bool find_whitespace_seps = true,
+ bool debug = false);
# ifndef MLN_INCLUDE_ONLY
@@ -83,211 +55,18 @@ namespace scribo
template <typename I>
line_set<mln_ch_value(I, def::lbl_type)>
- text_in_doc(const Image<I>& input, bool denoise, bool debug = false)
+ text_in_doc(const Image<I>& input, bool denoise,
+ bool find_line_seps = true,
+ bool find_whitespace_seps = true,
+ bool debug = false)
{
- typedef value::label<30> V;
- typedef image2d<V> L;
-
- // Remove separators
- if (debug)
- std::cout << "Find vertical separators..." << std::endl;
-
- // Vertical separators
- image2d<bool>
- separators = primitive::extract::vertical_separators(input, 81);
-
- if (debug)
- std::cout << "Remove separators..." << std::endl;
-
- image2d<bool> input_cleaned = primitive::remove::separators(input,
- separators);
-
- // Whitespace separators
- if (debug)
- std::cout << "Find whitespace separators..." << std::endl;
-
- image2d<bool>
- whitespaces = primitive::extract::separators_nonvisible(input);
-
- if (debug)
- {
- mln::io::pbm::save(whitespaces,
- scribo::make::debug_filename("whitespaces.pbm"));
-
- mln::io::pbm::save(separators,
- scribo::make::debug_filename("vseparators.pbm"));
-
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("input_wo_vseparators.pbm"));
- }
-
- // Denoise
- if (denoise)
- {
- if (debug)
- std::cout << "Denoise..." << std::endl;
-
- input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
-
- if (debug)
- mln::io::pbm::save(input_cleaned,
- scribo::make::debug_filename("denoised.pbm"));
- }
-
- /// Finding components.
- if (debug)
- std::cout << "Finding components..." << std::endl;
-
- V ncomponents;
- component_set<L>
- components = scribo::primitive::extract::components(input_cleaned, c8(),
- ncomponents);
-
- /// Set separator components.
- components.add_separators(separators);
- components.add_separators(whitespaces);
-
- components = scribo::filter::components_small(components, 3);
-
- if (debug)
- mln::io::pbm::save(components.separators(),
- scribo::make::debug_filename("all_separators.pbm"));
-
- /// Linking potential objects
- if (debug)
- std::cout << "Linking objects..." << std::endl;
-
- 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);
-
- // Validating left and right links.
- object_links<L>
- merged_links = primitive::link::merge_double_link(left_link,
- right_link);
-
-
- // Remove links if bboxes have too different sizes.
- object_links<L> hratio_filtered_links
- = filter::object_links_bbox_h_ratio(merged_links, 2.5f);
-
-
-// #ifndef NOUT
-// if (argc == 4)
-// {
-// image2d<value::rgb8>
-// hratio_decision_image = scribo::debug::decision_image(input,
-// merged_links,
-// hratio_filtered_links);
-// io::ppm::save(hratio_decision_image,
-// scribo::make::debug_filename("hratio_links_decision_image.ppm"));
-// }
-// #endif
-
-
- object_groups<L>
- groups = primitive::group::from_single_link(hratio_filtered_links);
-
-
- // Construct a line set.
- line_set<L>
- lines = scribo::make::line_set(groups);
-
-
-
- //===== DEBUG =====
-
- if (debug)
- {
-
- // Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step1_bboxes.ppm"));
-
- // Bboxes enlarged
- mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines),
- scribo::make::debug_filename("step1_bboxes_enlarged.ppm"));
-
- // 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"));
-
-
- // 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"));
-
- }
- //===== END OF DEBUG =====
-
-
-
- if (debug)
- std::cout << "Merging lines..." << std::endl;
- lines = scribo::text::merging(lines);
-
-
-
- //===== DEBUG =====
-
- if (debug)
- {
-
- // 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"));
-
- // 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"));
-
- // Bboxes image.
- scribo::debug::save_bboxes_image(input, lines,
- scribo::make::debug_filename("step2_bboxes.ppm"));
-
-
- }
-
-
-
- if (debug)
- {
- std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str());
-
- for_all_lines(l, lines)
- if (lines(l).tag() != line::Merged
- && lines(l).tag() != line::Ignored
- && lines(l).tag() != line::Pathological)
- {
- file << lines(l).bbox().pmin().row() << " "
- << lines(l).bbox().pmin().col() << " "
- << lines(l).bbox().pmax().row() << " "
- << lines(l).bbox().pmax().col() << " "
- << lines(l).card() << " "
- << lines(l).baseline() << " "
- << lines(l).x_height() << " "
- << lines(l).meanline() << " "
- << lines(l).d_height() << " "
- << lines(l).a_height() << " "
- << lines(l).char_space() << " "
- << lines(l).char_width() << std::endl;
-
- }
-
- file.close();
- }
-
-
- //===== END OF DEBUG =====
-
-
+ 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;
- scribo::text::recognition(lines, "eng");
+ line_set<mln_ch_value(I, def::lbl_type)> lines = f(input);
return lines;
}
diff --git a/scribo/scribo/toolchain/text_in_doc_preprocess.hh b/scribo/scribo/toolchain/text_in_doc_preprocess.hh
index 00a626e..20fea02 100644
--- a/scribo/scribo/toolchain/text_in_doc_preprocess.hh
+++ b/scribo/scribo/toolchain/text_in_doc_preprocess.hh
@@ -40,6 +40,7 @@
#include <scribo/preprocessing/split_bg_fg.hh>
#include <scribo/preprocessing/deskew.hh>
+#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
namespace scribo
{
@@ -53,6 +54,7 @@ namespace scribo
\param[in] input An image.
\param[in] enable_fg_bg Enable/Disable background removal.
+ \param[in] K Binarization threshold parameter. (Default 0.34)
If \p enable_fg_bg is set to 'True' then a background removal is
performed. Its parameter lambda is automatically set according
@@ -61,8 +63,16 @@ namespace scribo
*/
template <typename I>
mln_ch_value(I,bool)
+ text_in_doc_preprocess(const Image<I>& input, bool enable_fg_bg, double K);
+
+ /*! \overload
+ K is set to 0.34.
+ */
+ template <typename I>
+ mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input, bool enable_fg_bg);
+
/*! \brief Preprocess a document before looking for its content.
\param[in] input An image.
@@ -81,6 +91,7 @@ namespace scribo
\param[in] input An image.
\param[in] lambda Parameter to the background removal.
+ \param[in] K Binarization threshold parameter. (Default 0.34)
\param[in,out] fg The foreground layer of \p input.
If lambda is set to '0' no background removal is
@@ -91,7 +102,7 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input, unsigned lambda,
- Image<I>& fg);
+ double K, bool enable_fg_bg, Image<I>& fg);
# ifndef MLN_INCLUDE_ONLY
@@ -99,7 +110,15 @@ namespace scribo
template <typename I>
mln_ch_value(I,bool)
- text_in_doc_preprocess(const Image<I>& input_, bool enable_fg_bg)
+ text_in_doc_preprocess(const Image<I>& input, bool enable_fg_bg)
+ {
+ return text_in_doc_preprocess(input, enable_fg_bg, 0.34);
+ }
+
+
+ template <typename I>
+ mln_ch_value(I,bool)
+ text_in_doc_preprocess(const Image<I>& input_, bool enable_fg_bg, double K)
{
const I& input = exact(input_);
mln_precondition(input.is_valid());
@@ -108,7 +127,9 @@ namespace scribo
if (enable_fg_bg)
lambda = 1.2 * (input.nrows() + input.ncols());
- mln_ch_value(I,bool) output = text_in_doc_preprocess(input, lambda);
+ mln_concrete(I) tmp_fg;
+ mln_ch_value(I,bool)
+ output = text_in_doc_preprocess(input, lambda, K, enable_fg_bg, tmp_fg);
return output;
}
@@ -118,48 +139,33 @@ namespace scribo
text_in_doc_preprocess(const Image<I>& input, unsigned lambda)
{
I tmp;
- return text_in_doc_preprocess(input, lambda, tmp);
+ return text_in_doc_preprocess(input, lambda, 0.34, true, tmp);
}
template <typename I>
mln_ch_value(I,bool)
text_in_doc_preprocess(const Image<I>& input_, unsigned lambda,
- Image<I>& fg_)
+ double K, bool enable_fg_bg, Image<I>& fg)
{
trace::entering("scribo::toolchain::text_in_doc_preprocess");
const I& input = exact(input_);
- I& fg = exact(fg_);
mln_precondition(input.is_valid());
- mln_concrete(I) input_rgb = input;
-
- // Extract foreground
- if (lambda != 0)
- {
- std::cout << "Extracting foreground..." << std::endl;
- input_rgb = preprocessing::split_bg_fg(input, lambda, 32).second();
- fg = input_rgb;
- }
+ internal::text_in_doc_preprocess_functor<I> f;
- // Convert to Gray level image.
- mln_ch_value(I,value::int_u8)
- input_gl = data::transform(input_rgb,
- mln::fun::v2v::rgb_to_int_u<8>());
+ // Setup functor.
+ f.sauvola_K = K;
+ f.enable_fg_extraction = enable_fg_bg;
+ f.lambda = lambda;
-
- // Deskewing
- std::cout << "Deskew if needed..." << std::endl;
- input_gl = preprocessing::deskew(input_gl);
-
- // Binarize foreground to use it in the processing chain.
- std::cout << "Binarizing foreground..." << std::endl;
- mln_ch_value(I,bool)
- input_bin = scribo::binarization::sauvola_ms(input_gl, 101, 3);
+ // Get results.
+ mln_ch_value(I,bool) output = f(input);
+ exact(fg) = f.fg;
trace::exiting("scribo::toolchain::text_in_doc_preprocess");
- return input_bin;
+ return output;
}
--
1.5.6.5
1
0
last-svn-commit-700-g0a5f6a5 scribo/core/document.hh: Add new methods.
by Guillaume Lazzara 10 Dec '10
by Guillaume Lazzara 10 Dec '10
10 Dec '10
---
scribo/ChangeLog | 4 ++++
scribo/scribo/core/document.hh | 30 +++++++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a1025f2..8a7132a 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/core/document.hh: Add new methods.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix missing inlines and MLN_WO_GLOBALS_VARS guards in Scribo.
* scribo/binarization/internal/first_pass_functor.hh,
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index daa0d7b..b6b79df 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -47,8 +47,11 @@ namespace scribo
document();
document(const char *filename);
+ document(const char *filename,
+ const mln::image2d<mln::value::rgb8>& input);
void open();
+ bool is_open() const;
const char * filename() const;
void set_filename(const char*name);
@@ -64,6 +67,7 @@ namespace scribo
void set_elements(const component_set<L>& elements);
const mln::image2d<value::rgb8>& image() const;
+ void set_image(const mln::image2d<value::rgb8>& image);
private:
const char *filename_;
@@ -88,7 +92,15 @@ namespace scribo
document<L>::document(const char *filename)
: filename_(filename)
{
- open();
+ }
+
+
+ template <typename L>
+ document<L>::document(const char *filename,
+ const mln::image2d<mln::value::rgb8>& input)
+ : filename_(filename),
+ image_(input)
+ {
}
@@ -118,6 +130,14 @@ namespace scribo
template <typename L>
bool
+ document<L>::is_open() const
+ {
+ return image_.is_valid();
+ }
+
+
+ template <typename L>
+ bool
document<L>::is_valid() const
{
return image_.is_valid();
@@ -180,6 +200,14 @@ namespace scribo
}
+ template <typename L>
+ void
+ document<L>::set_image(const mln::image2d<value::rgb8>& image)
+ {
+ image_ = image;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
last-svn-commit-699-g3cc1d66 Fix missing inlines and MLN_WO_GLOBALS_VARS guards in Scribo.
by Guillaume Lazzara 10 Dec '10
by Guillaume Lazzara 10 Dec '10
10 Dec '10
* scribo/binarization/internal/first_pass_functor.hh,
* scribo/binarization/sauvola_ms.hh,
* scribo/core/component_info.hh,
* scribo/core/init_integral_image.hh,
* scribo/core/tag/component.hh,
* scribo/core/tag/line.hh,
* scribo/io/xml/save.hh,
* scribo/make/debug_filename.hh,
* scribo/preprocessing/deskew.hh,
* scribo/preprocessing/split_bg_fg.hh,
* scribo/primitive/extract/separators_nonvisible.hh,
* scribo/primitive/link/internal/dmax_default.hh,
* scribo/primitive/link/internal/dmax_width_and_height.hh,
* scribo/primitive/link/internal/dmax_width_only.hh,
* scribo/text/merging.hh,
* scribo/text/recognition.hh: Here.
---
scribo/ChangeLog | 21 +++
.../binarization/internal/first_pass_functor.hh | 142 +++++++++++---------
scribo/scribo/binarization/sauvola_ms.hh | 2 +
scribo/scribo/core/component_info.hh | 17 +++-
scribo/scribo/core/init_integral_image.hh | 16 ++-
scribo/scribo/core/tag/component.hh | 2 +
scribo/scribo/core/tag/line.hh | 3 +
scribo/scribo/io/xml/save.hh | 3 +
scribo/scribo/make/debug_filename.hh | 3 +
scribo/scribo/preprocessing/deskew.hh | 5 +
scribo/scribo/preprocessing/split_bg_fg.hh | 6 +-
.../primitive/extract/separators_nonvisible.hh | 65 +++++-----
.../scribo/primitive/link/internal/dmax_default.hh | 1 +
.../link/internal/dmax_width_and_height.hh | 2 +
.../primitive/link/internal/dmax_width_only.hh | 2 +
scribo/scribo/text/merging.hh | 3 +
scribo/scribo/text/recognition.hh | 2 -
17 files changed, 196 insertions(+), 99 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 579f31e..a1025f2 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,26 @@
2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix missing inlines and MLN_WO_GLOBALS_VARS guards in Scribo.
+
+ * scribo/binarization/internal/first_pass_functor.hh,
+ * scribo/binarization/sauvola_ms.hh,
+ * scribo/core/component_info.hh,
+ * scribo/core/init_integral_image.hh,
+ * scribo/core/tag/component.hh,
+ * scribo/core/tag/line.hh,
+ * scribo/io/xml/save.hh,
+ * scribo/make/debug_filename.hh,
+ * scribo/preprocessing/deskew.hh,
+ * scribo/preprocessing/split_bg_fg.hh,
+ * scribo/primitive/extract/separators_nonvisible.hh,
+ * scribo/primitive/link/internal/dmax_default.hh,
+ * scribo/primitive/link/internal/dmax_width_and_height.hh,
+ * scribo/primitive/link/internal/dmax_width_only.hh,
+ * scribo/text/merging.hh,
+ * scribo/text/recognition.hh: Here.
+
+2010-12-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix guards and license in xml2doc.
* demo/xml2doc/image_crop.cc,
diff --git a/scribo/scribo/binarization/internal/first_pass_functor.hh b/scribo/scribo/binarization/internal/first_pass_functor.hh
index 637ff39..fb52be5 100644
--- a/scribo/scribo/binarization/internal/first_pass_functor.hh
+++ b/scribo/scribo/binarization/internal/first_pass_functor.hh
@@ -27,6 +27,10 @@
#ifndef SCRIBO_BINARIZATION_INTERNAL_FIRST_PASS_FUNCTOR_HH
# define SCRIBO_BINARIZATION_INTERNAL_FIRST_PASS_FUNCTOR_HH
+/// \file
+///
+///
+
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/extension/fill.hh>
@@ -48,15 +52,6 @@ namespace scribo
using namespace mln;
- unsigned my_find_root(image2d<unsigned>& parent, unsigned x)
- {
- if (parent.element(x) == x)
- return x;
- return parent.element(x) = my_find_root(parent,
- parent.element(x));
- }
-
-
template <typename I>
struct first_pass_functor
{
@@ -73,74 +68,99 @@ namespace scribo
double K_;
- first_pass_functor(const I& input, double K)
- : input(input),
- pxl(input),
- K_(K)
- {
- res = 0;
- pxl.start();
+ first_pass_functor(const I& input, double K);
+
+ void exec(double mean, double stddev);
+ void finalize();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ unsigned my_find_root(image2d<unsigned>& parent, unsigned x)
+ {
+ if (parent.element(x) == x)
+ return x;
+ return parent.element(x) = my_find_root(parent,
+ parent.element(x));
+ }
+
- initialize(t_sub, input);
- initialize(parent, input);
- initialize(msk, input);
+ template <typename I>
+ first_pass_functor<I>::first_pass_functor(const I& input, double K)
+ : input(input),
+ pxl(input),
+ K_(K)
+ {
+ res = 0;
+ pxl.start();
+
+ initialize(t_sub, input);
+ initialize(parent, input);
+ initialize(msk, input);
# ifdef SCRIBO_SAUVOLA_DEBUG
- initialize(debug_mean, input);
- initialize(debug_stddev, input);
+ initialize(debug_mean, input);
+ initialize(debug_stddev, input);
# endif // ! SCRIBO_SAUVOLA_DEBUG
- mln::extension::fill(msk, false);
+ mln::extension::fill(msk, false);
- initialize(card, input);
- data::fill(card, 1);
+ initialize(card, input);
+ data::fill(card, 1);
- dp = negative_offsets_wrt(input, c4());
- n_nbhs = dp.nelements();
- }
+ dp = negative_offsets_wrt(input, c4());
+ n_nbhs = dp.nelements();
+ }
- void exec(double mean, double stddev)
- {
- mln_precondition(pxl.is_valid());
- unsigned p = pxl.offset();
+ template <typename I>
+ void
+ first_pass_functor<I>::exec(double mean, double stddev)
+ {
+ mln_precondition(pxl.is_valid());
- value::int_u8 t_p;
- mln::convert::from_to(sauvola_threshold_formula(mean, stddev,
- K_,
- SCRIBO_DEFAULT_SAUVOLA_R),
- t_p);
+ unsigned p = pxl.offset();
- msk.element(p) = input.element(p) < t_p;
- t_sub.element(p) = t_p;
- if (! msk.element(p))
- {
- pxl.next();
- return;
- }
- parent.element(p) = p;
- for (unsigned i = 0; i < n_nbhs; ++i)
- {
- unsigned n = p + dp[i];
- if (! msk.element(n))
- continue;
- unsigned r = my_find_root(parent, n);
- if (r != p)
- {
- parent.element(r) = p;
- card.element(p) += card.element(r);
- }
- }
+ value::int_u8 t_p;
+ mln::convert::from_to(sauvola_threshold_formula(mean, stddev,
+ K_,
+ SCRIBO_DEFAULT_SAUVOLA_R),
+ t_p);
- pxl.next(); // next pixel
+ msk.element(p) = input.element(p) < t_p;
+ t_sub.element(p) = t_p;
+ if (! msk.element(p))
+ {
+ pxl.next();
+ return;
}
-
- void finalize()
+ parent.element(p) = p;
+ for (unsigned i = 0; i < n_nbhs; ++i)
{
- mln_assertion(! pxl.is_valid());
+ unsigned n = p + dp[i];
+ if (! msk.element(n))
+ continue;
+ unsigned r = my_find_root(parent, n);
+ if (r != p)
+ {
+ parent.element(r) = p;
+ card.element(p) += card.element(r);
+ }
}
- };
+ pxl.next(); // next pixel
+ }
+
+
+ template <typename I>
+ void first_pass_functor<I>::finalize()
+ {
+ mln_assertion(! pxl.is_valid());
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::binarization::internal
diff --git a/scribo/scribo/binarization/sauvola_ms.hh b/scribo/scribo/binarization/sauvola_ms.hh
index a6b3aba..1233d1c 100644
--- a/scribo/scribo/binarization/sauvola_ms.hh
+++ b/scribo/scribo/binarization/sauvola_ms.hh
@@ -132,6 +132,7 @@ namespace scribo
}
+ inline
image2d<int_u8>
compute_t_n_and_e_2(const image2d<int_u8>& sub, image2d<int_u8>& e_2,
unsigned lambda_min, unsigned lambda_max,
@@ -746,6 +747,7 @@ namespace scribo
+ inline
unsigned sub(unsigned nbr, unsigned down_scaling)
{
return (nbr + down_scaling - 1) / down_scaling;
diff --git a/scribo/scribo/core/component_info.hh b/scribo/scribo/core/component_info.hh
index 56f7799..8345266 100644
--- a/scribo/scribo/core/component_info.hh
+++ b/scribo/scribo/core/component_info.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -94,6 +95,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ inline
component_info::component_info()
: id_(0), tag_(component::Ignored)
{
@@ -101,6 +103,7 @@ namespace scribo
}
+ inline
component_info::component_info(const component_id_t& id,
const mln::box2d& bbox,
const mln::point2d& mass_center,
@@ -112,6 +115,7 @@ namespace scribo
}
+ inline
component_info::component_id_t
component_info::id() const
{
@@ -119,6 +123,7 @@ namespace scribo
}
+ inline
const mln::box2d&
component_info::bbox() const
{
@@ -126,12 +131,14 @@ namespace scribo
}
+ inline
const mln::point2d&
component_info::mass_center() const
{
return mass_center_;
}
+ inline
unsigned
component_info::card() const
{
@@ -139,6 +146,7 @@ namespace scribo
}
+ inline
component::Tag
component_info::tag() const
{
@@ -146,6 +154,7 @@ namespace scribo
}
+ inline
void
component_info::update_tag(component::Tag tag)
{
@@ -153,6 +162,7 @@ namespace scribo
}
+ inline
component::Type
component_info::type() const
{
@@ -160,6 +170,7 @@ namespace scribo
}
+ inline
void
component_info::update_type(component::Type type)
{
@@ -167,12 +178,15 @@ namespace scribo
}
+ inline
component_info::line_id_t
component_info::line_id() const
{
return line_id_;
}
+
+ inline
bool
component_info::is_valid() const
{
@@ -180,6 +194,7 @@ namespace scribo
}
+ inline
std::ostream&
operator<<(std::ostream& ostr, const component_info& info)
{
diff --git a/scribo/scribo/core/init_integral_image.hh b/scribo/scribo/core/init_integral_image.hh
index ec19070..5bd88dc 100644
--- a/scribo/scribo/core/init_integral_image.hh
+++ b/scribo/scribo/core/init_integral_image.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -37,15 +38,24 @@ namespace scribo
using namespace mln;
+ template <typename I, typename F>
+ mln_ch_value(I,double)
+ init_integral_image(const Image<I>& input_, F& func);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace internal
{
+ inline
double square_(const double& val)
{
double v = static_cast<double>(val);
return v * v;
}
+ inline
double identity_(const double& val)
{
return static_cast<double>(val);
@@ -54,6 +64,8 @@ namespace scribo
} // end of namespace scribo::internal
+ // Facade
+
template <typename I, typename F>
mln_ch_value(I,double)
init_integral_image(const Image<I>& input_, F& func)
@@ -91,6 +103,8 @@ namespace scribo
return output;
}
+#endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace scribo
#endif // ! SCRIBO_CORE_INIT_INTEGRAL_IMAGE_HH
diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh
index 5ed51fa..f2fb059 100644
--- a/scribo/scribo/core/tag/component.hh
+++ b/scribo/scribo/core/tag/component.hh
@@ -63,6 +63,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ inline
std::ostream&
operator<<(std::ostream& ostr, const Tag& tag)
{
@@ -82,6 +83,7 @@ namespace scribo
}
+ inline
std::ostream&
operator<<(std::ostream& ostr, const Type& type)
{
diff --git a/scribo/scribo/core/tag/line.hh b/scribo/scribo/core/tag/line.hh
index ccb8cd1..0444a11 100644
--- a/scribo/scribo/core/tag/line.hh
+++ b/scribo/scribo/core/tag/line.hh
@@ -101,6 +101,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ inline
std::ostream&
operator<<(std::ostream& ostr, const Tag& tag)
{
@@ -130,6 +131,7 @@ namespace scribo
+ inline
std::ostream&
operator<<(std::ostream& ostr, const ReadingDirection& direction)
{
@@ -155,6 +157,7 @@ namespace scribo
}
+ inline
std::ostream&
operator<<(std::ostream& ostr, const Type& type)
{
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index 3c182e7..d0c72e9 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -70,6 +70,8 @@ namespace scribo
namespace internal
{
+
+ inline
std::string&
html_markups_replace(std::string& input,
std::map<char, std::string>& map)
@@ -87,6 +89,7 @@ namespace scribo
}
+ inline
void print_box_coords(std::ofstream& ostr, const box2d& b,
const char *space)
{
diff --git a/scribo/scribo/make/debug_filename.hh b/scribo/scribo/make/debug_filename.hh
index 0aadbfe..f3b4962 100644
--- a/scribo/scribo/make/debug_filename.hh
+++ b/scribo/scribo/make/debug_filename.hh
@@ -59,6 +59,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_WO_GLOBAL_VARS
namespace internal
{
@@ -67,6 +68,8 @@ namespace scribo
} // end of namespace scribo::make::internal
+# endif // ! MLN_WO_GLOBAL_VARS
+
inline
std::string
diff --git a/scribo/scribo/preprocessing/deskew.hh b/scribo/scribo/preprocessing/deskew.hh
index 80ea351..12fd104 100644
--- a/scribo/scribo/preprocessing/deskew.hh
+++ b/scribo/scribo/preprocessing/deskew.hh
@@ -115,6 +115,7 @@ namespace scribo
namespace internal
{
+ inline
bool
QCompare::operator()(const s_angle& s1, const s_angle& s2)
{
@@ -122,6 +123,7 @@ namespace scribo
}
+ inline
Hough::Hough(int width, int height)
: width_(width / 2),
height_(height / 2),
@@ -135,12 +137,14 @@ namespace scribo
}
+ inline
Hough::~Hough()
{
delete[] this->cos_;
delete[] this->sin_;
}
+
inline
void Hough::look_up_table()
{
@@ -336,6 +340,7 @@ namespace scribo
}
+ inline
double
perform_deskew(const image2d<value::int_u8>& gray)
{
diff --git a/scribo/scribo/preprocessing/split_bg_fg.hh b/scribo/scribo/preprocessing/split_bg_fg.hh
index 5094f32..e1fae7d 100644
--- a/scribo/scribo/preprocessing/split_bg_fg.hh
+++ b/scribo/scribo/preprocessing/split_bg_fg.hh
@@ -189,7 +189,7 @@ namespace scribo
}
-
+ inline
image2d< value::rgb8 >
diff_abs(const image2d< value::rgb8 >& input1,
const image2d< value::rgb8 >& input2)
@@ -207,6 +207,7 @@ namespace scribo
}
+ inline
image2d< value::rgb8 >
inverted_diff_abs(const image2d< value::rgb8 >& input1,
const image2d< value::rgb8 >& input2)
@@ -228,7 +229,7 @@ namespace scribo
}
-
+ inline
unsigned dist(const rgb8& c1, const rgb8& c2)
{
unsigned d = 0;
@@ -239,6 +240,7 @@ namespace scribo
}
+ inline
image2d<rgb8>
background_analyze(const image2d<rgb8>& input,
unsigned lambda, unsigned delta)
diff --git a/scribo/scribo/primitive/extract/separators_nonvisible.hh b/scribo/scribo/primitive/extract/separators_nonvisible.hh
index 8aaeeec..81ebd64 100644
--- a/scribo/scribo/primitive/extract/separators_nonvisible.hh
+++ b/scribo/scribo/primitive/extract/separators_nonvisible.hh
@@ -128,10 +128,6 @@ namespace scribo
namespace internal
{
- // Enable debug.
- bool _debug_;
-
-
template <typename L>
void filter_bad_groups(object_groups<L>& top_groups,
object_groups<L>& bot_groups)
@@ -223,13 +219,15 @@ namespace scribo
unsigned dmax,
float min_angle,
float max_angle,
- anchor::Type anchor_)
+ anchor::Type anchor_,
+ bool debug)
: super_(components,
anchor::Horizontal,
dmax_default(dmax)),
anchor(anchor_),
debug_(data::convert(value::rgb8(), input)),
- debug_angle_(data::convert(value::rgb8(), input))
+ debug_angle_(data::convert(value::rgb8(), input)),
+ _debug_(debug)
{
min_alpha_rad = (min_angle / 180.0f) * math::pi;
max_alpha_rad = (max_angle / 180.0f) * math::pi;
@@ -372,6 +370,7 @@ namespace scribo
mln_ch_value(L, value::rgb8) debug_;
mln_ch_value(L, value::rgb8) debug_angle_;
+ bool _debug_;
};
@@ -391,8 +390,9 @@ namespace scribo
unsigned dmax,
float min_angle,
float max_angle,
- anchor::Type anchor)
- : super_(input, components, dmax, min_angle, max_angle, anchor)
+ anchor::Type anchor,
+ bool debug)
+ : super_(input, components, dmax, min_angle, max_angle, anchor, debug)
{
}
@@ -425,8 +425,9 @@ namespace scribo
unsigned dmax,
float min_angle,
float max_angle,
- anchor::Type anchor)
- : super_(input, components, dmax, min_angle, max_angle, anchor)
+ anchor::Type anchor,
+ bool debug)
+ : super_(input, components, dmax, min_angle, max_angle, anchor, debug)
{
}
@@ -459,7 +460,7 @@ namespace scribo
typedef mln_value(I) Vi;
mlc_is(Vi,bool)::check();
- internal::_debug_ = false;
+ bool _debug_ = false;
unsigned
min_angle = 3,
max_angle = 5,
@@ -497,7 +498,7 @@ namespace scribo
t_ = t;
std::cout << "closing_structural - " << t_ << std::endl;
- if (internal::_debug_)
+ if (_debug_)
{
// Restore input orientation.
input = scribo::preprocessing::rotate_90(input, false);
@@ -525,7 +526,7 @@ namespace scribo
t_ = t;
std::cout << "extract::components - " << t_ << std::endl;
- if (internal::_debug_)
+ if (_debug_)
io::pgm::save(data::convert(value::int_u8(), components.labeled_image()),
"lbl.pgm");
@@ -542,14 +543,14 @@ namespace scribo
{
// Right
internal::single_right_dmax_ratio_aligned_functor<L>
- functor(input_clo, components, dmax, min_angle, max_angle, anchor::Top);
+ functor(input_clo, components, dmax, min_angle, max_angle, anchor::Top, _debug_);
// top_right = primitive::link::impl::compute_fastest(functor, anchor::Top);
top_right = primitive::link::compute(functor, anchor::Top);
t.stop();
- if (internal::_debug_)
+ if (_debug_)
{
io::ppm::save(functor.debug_, "right_top.ppm");
io::ppm::save(functor.debug_angle_, "right_top_angle.ppm");
@@ -559,13 +560,13 @@ namespace scribo
// Left
internal::single_left_dmax_ratio_aligned_functor<L>
- lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Top);
+ lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Top, _debug_);
top_left = primitive::link::compute(lfunctor, anchor::Top);
t.stop();
- if (internal::_debug_)
+ if (_debug_)
{
io::ppm::save(lfunctor.debug_, "left_top.ppm");
io::ppm::save(lfunctor.debug_angle_, "left_top_angle.ppm");
@@ -584,11 +585,11 @@ namespace scribo
{
// Right
internal::single_right_dmax_ratio_aligned_functor<L>
- functor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom);
+ functor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom, _debug_);
bot_right = primitive::link::compute(functor, anchor::Bottom);
t.stop();
- if (internal::_debug_)
+ if (_debug_)
{
io::ppm::save(functor.debug_, "right_bot.ppm");
io::ppm::save(functor.debug_angle_, "right_bot_angle.ppm");
@@ -598,17 +599,17 @@ namespace scribo
// Left
internal::single_left_dmax_ratio_aligned_functor<L>
- lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom);
+ lfunctor(input_clo, components, dmax, min_angle, max_angle, anchor::Bottom, _debug_);
bot_left = primitive::link::compute(lfunctor, anchor::Bottom);
t.stop();
- if (internal::_debug_)
+ if (_debug_)
{
io::ppm::save(lfunctor.debug_, "left_bot.ppm");
io::ppm::save(lfunctor.debug_angle_, "left_bot_angle.ppm");
}
- if (internal::_debug_)
+ if (_debug_)
{
mln_ch_value(I, value::rgb8) output = duplicate(functor.debug_);
data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output);
@@ -648,7 +649,7 @@ namespace scribo
- if (internal::_debug_)
+ if (_debug_)
{
mln_ch_value(I, value::rgb8)
@@ -721,7 +722,7 @@ namespace scribo
mln_ch_value(I, value::rgb8) both;
- if (internal::_debug_)
+ if (_debug_)
both = data::convert(value::rgb8(), input);
@@ -733,7 +734,7 @@ namespace scribo
{
if (top_accu(d).is_valid())
{
- if (internal::_debug_)
+ if (_debug_)
mln::draw::line(both,
top_accu(d).to_result().pmin(),
point2d(top_accu(d).to_result().pmin().row(),
@@ -747,7 +748,7 @@ namespace scribo
true);
}
else
- if (internal::_debug_ && btop_accu(d).is_valid())
+ if (_debug_ && btop_accu(d).is_valid())
mln::draw::line(both,
btop_accu(d).to_result().pmin(),
point2d(btop_accu(d).to_result().pmin().row(),
@@ -759,7 +760,7 @@ namespace scribo
{
if (bot_accu(d).is_valid())
{
- if (internal::_debug_)
+ if (_debug_)
mln::draw::line(both,
point2d(bot_accu(d).to_result().pmax().row(),
bot_accu(d).to_result().pmin().col()),
@@ -773,7 +774,7 @@ namespace scribo
true);
}
else
- if (internal::_debug_ && bbot_accu(d).is_valid())
+ if (_debug_ && bbot_accu(d).is_valid())
mln::draw::line(both,
point2d(bbot_accu(d).to_result().pmax().row(),
bbot_accu(d).to_result().pmin().col()),
@@ -786,7 +787,7 @@ namespace scribo
std::cout << "Drawing output image - " << t_ << std::endl;
- if (internal::_debug_)
+ if (_debug_)
{
io::ppm::save(both, "both.ppm");
io::pbm::save(separators, "separators.pbm");
@@ -795,7 +796,7 @@ namespace scribo
// Hit or miss
{
- if (internal::_debug_)
+ if (_debug_)
{
mln_concrete(I) input_with_seps = duplicate(input_clo);
data::paste(separators | pw::value(separators), input_with_seps);
@@ -821,7 +822,7 @@ namespace scribo
t_ = t;
std::cout << "* accu::transform_line - " << t_ << std::endl;
- if (internal::_debug_)
+ if (_debug_)
io::pgm::save(data::convert(value::int_u8(), tmp), "tmp.pgm");
@@ -869,7 +870,7 @@ namespace scribo
mln_concrete(I) output = data::convert(bool(), sep_lbl);
- if (internal::_debug_)
+ if (_debug_)
{
io::pbm::save(output, "separators_hom.pbm");
io::pbm::save(separators, "separators_filtered.pbm");
diff --git a/scribo/scribo/primitive/link/internal/dmax_default.hh b/scribo/scribo/primitive/link/internal/dmax_default.hh
index 1444dfe..b4106a9 100644
--- a/scribo/scribo/primitive/link/internal/dmax_default.hh
+++ b/scribo/scribo/primitive/link/internal/dmax_default.hh
@@ -62,6 +62,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ inline
dmax_default::dmax_default(const float& dmax_factor)
: super_(dmax_factor)
{
diff --git a/scribo/scribo/primitive/link/internal/dmax_width_and_height.hh b/scribo/scribo/primitive/link/internal/dmax_width_and_height.hh
index 3f19f1f..4c1d561 100644
--- a/scribo/scribo/primitive/link/internal/dmax_width_and_height.hh
+++ b/scribo/scribo/primitive/link/internal/dmax_width_and_height.hh
@@ -66,12 +66,14 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ inline
dmax_width_and_height::dmax_width_and_height(const float& dmax_factor)
: super_(dmax_factor)
{
}
+ inline
float
dmax_width_and_height::operator()(const box2d& b) const
{
diff --git a/scribo/scribo/primitive/link/internal/dmax_width_only.hh b/scribo/scribo/primitive/link/internal/dmax_width_only.hh
index 034d40b..1d882ba 100644
--- a/scribo/scribo/primitive/link/internal/dmax_width_only.hh
+++ b/scribo/scribo/primitive/link/internal/dmax_width_only.hh
@@ -66,12 +66,14 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+ inline
dmax_width_only::dmax_width_only()
: super_(0)
{
}
+ inline
float
dmax_width_only::operator()(const box2d& b) const
{
diff --git a/scribo/scribo/text/merging.hh b/scribo/scribo/text/merging.hh
index ed48e57..3087465 100644
--- a/scribo/scribo/text/merging.hh
+++ b/scribo/scribo/text/merging.hh
@@ -150,6 +150,7 @@ namespace scribo
+ inline
unsigned my_find_root(mln::util::array<unsigned>& parent, unsigned x)
{
if (parent[x] == x)
@@ -158,6 +159,7 @@ namespace scribo
}
+ inline
void swap_ordering(unsigned l1, unsigned l2)
{
if (l2 > l1)
@@ -211,6 +213,7 @@ namespace scribo
+ inline
box2d enlarge(const box2d& b, int delta)
{
box2d b_(point2d(b.pmin().row(), b.pmin().col() - delta),
diff --git a/scribo/scribo/text/recognition.hh b/scribo/scribo/text/recognition.hh
index 07f585d..ab5e3e2 100644
--- a/scribo/scribo/text/recognition.hh
+++ b/scribo/scribo/text/recognition.hh
@@ -99,8 +99,6 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- unsigned debug_id = 0;
-
template <typename L>
void
--
1.5.6.5
1
0