LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
March 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
7 participants
277 discussions
Start a n
N
ew thread
last-svn-commit-793-ge93e375 Small fixes in viewer.
by Guillaume Lazzara
* demo/viewer/main.cc: Add more includes. * demo/viewer/viewer.cc: Add debug output. --- scribo/ChangeLog | 8 ++++++++ scribo/demo/viewer/main.cc | 5 ++++- scribo/demo/viewer/viewer.cc | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 9e63c2a..358201c 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,11 @@ +2011-03-11 Guillaume Lazzara <z(a)lrde.epita.fr> + + Small fixes in viewer. + + * demo/viewer/main.cc: Add more includes. + + * demo/viewer/viewer.cc: Add debug output. + 2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> * scribo/io/xml/internal/extended_page_xml_visitor.hh: Save diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc index 6d1cb18..069d5e9 100644 --- a/scribo/demo/viewer/main.cc +++ b/scribo/demo/viewer/main.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -23,6 +24,8 @@ #include <mln/math/pi.hh> #include <mln/io/magick/load.hh> #include <scribo/make/debug_filename.hh> +#include <mln/debug/filename.hh> +#include <mln/literal/white.hh> int main(int argc, char** argv) { diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc index f34b3e7..173cb3b 100644 --- a/scribo/demo/viewer/viewer.cc +++ b/scribo/demo/viewer/viewer.cc @@ -372,7 +372,10 @@ Viewer::add_text(QDomNode line) coords = coords.nextSibling(); if (coords.isNull()) + { + qDebug() << "Warning : textline without coordinates..."; return; + } QDomNode point = coords.firstChild(); @@ -393,7 +396,7 @@ Viewer::add_text(QDomNode line) point = point.nextSibling(); } - QString text = line.toElement().attribute("text", "none"); + QString text = line.toElement().attribute("text", ""); QFont font("Times"); font.setPixelSize(a_height + d_height); QGraphicsTextItem* text_item = scene_->addText(text, font); @@ -417,7 +420,10 @@ Viewer::add_region(QDomNode father, QString attr_id) coords = coords.nextSibling(); if (coords.isNull()) + { + qDebug() << "Warning : add_region - region without coordinates"; return; + } QDomNode point = coords.firstChild(); QVector<QPoint> points; -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-792-g446d792 scribo/io/xml/internal/extended_page_xml_visitor.hh: Save separators data.
by Guillaume Lazzara
--- scribo/ChangeLog | 5 +++++ .../io/xml/internal/extended_page_xml_visitor.hh | 4 ++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 3f17098..9e63c2a 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,10 @@ 2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/io/xml/internal/extended_page_xml_visitor.hh: Save + separators data. + +2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/io/xml/internal/full_xml_visitor.hh: Do not copy image data. diff --git a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh index 4da0755..f573d88 100644 --- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh +++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh @@ -113,6 +113,10 @@ namespace scribo if (doc.has_elements()) doc.elements().accept(*this); + // line seraparators + if (doc.has_line_seps()) + doc.line_seps_comps().accept(*this); + // Whitespace seraparators if (doc.has_whitespace_seps()) doc.whitespace_seps_comps().accept(*this); -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-791-g79532c9 scribo/io/xml/internal/full_xml_visitor.hh: Do not copy image data.
by Guillaume Lazzara
--- scribo/ChangeLog | 5 +++++ scribo/scribo/io/xml/internal/full_xml_visitor.hh | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 2af84c0..3f17098 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,10 @@ 2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/io/xml/internal/full_xml_visitor.hh: Do not copy image + data. + +2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> + Make OCR step optional in viewer. * demo/viewer/Makefile.am: Add new files. diff --git a/scribo/scribo/io/xml/internal/full_xml_visitor.hh b/scribo/scribo/io/xml/internal/full_xml_visitor.hh index 2b09b3a..8576c27 100644 --- a/scribo/scribo/io/xml/internal/full_xml_visitor.hh +++ b/scribo/scribo/io/xml/internal/full_xml_visitor.hh @@ -279,8 +279,9 @@ namespace scribo // FIXME: Try to avoid that! border::resize(lbl, 0); - QByteArray lbl64((const char *)lbl.buffer(), - lbl.nelements() * sizeof(mln_value(L))); + QByteArray + lbl64 = QByteArray::fromRawData((const char *)lbl.buffer(), + lbl.nelements() * sizeof(mln_value(L))); lbl64 = qCompress(lbl64, COMPRESSION_LEVEL); lbl64 = lbl64.toBase64(); @@ -299,8 +300,9 @@ namespace scribo << "<![CDATA["; border::resize(seps, 0); - QByteArray seps64((const char *)seps.buffer(), - seps.nelements() * sizeof(bool)); + QByteArray + seps64 = QByteArray::fromRawData((const char *)seps.buffer(), + seps.nelements() * sizeof(bool)); seps64 = qCompress(seps64, COMPRESSION_LEVEL); seps64 = seps64.toBase64(); @@ -346,7 +348,6 @@ namespace scribo break; } - default: case component::Image: { -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-790-g3c3cd93 Make OCR step optional in viewer.
by Guillaume Lazzara
* demo/viewer/Makefile.am: Add new files. * demo/viewer/config.cc, * demo/viewer/config.hh: Add OCR settings. * demo/viewer/toolchain_options.cc, * demo/viewer/toolchain_options.hh, * demo/viewer/toolchain_options.ui: Remove. * demo/viewer/ocr_options.cc, * demo/viewer/ocr_options.hh, * demo/viewer/ocr_options.ui, * demo/viewer/preprocessing_options.cc, * demo/viewer/preprocessing_options.hh, * demo/viewer/preprocessing_options.ui, * demo/viewer/segmentation_options.cc, * demo/viewer/segmentation_options.hh, * demo/viewer/segmentation_options.ui: New option widgets. * demo/viewer/preferences_dialog.cc: Insert new widgets. * demo/viewer/runner.cc: Take OCR settings into account. --- scribo/ChangeLog | 30 +++++++- scribo/demo/viewer/Makefile.am | 20 ++++- scribo/demo/viewer/config.cc | 28 ++++++- scribo/demo/viewer/config.hh | 11 ++- scribo/demo/viewer/ocr_options.cc | 74 ++++++++++++++++ scribo/demo/viewer/ocr_options.hh | 40 +++++++++ scribo/demo/viewer/ocr_options.ui | 62 ++++++++++++++ scribo/demo/viewer/preferences_dialog.cc | 26 +++++- scribo/demo/viewer/preprocessing_options.cc | 66 +++++++++++++++ scribo/demo/viewer/preprocessing_options.hh | 38 +++++++++ scribo/demo/viewer/preprocessing_options.ui | 76 +++++++++++++++++ scribo/demo/viewer/runner.cc | 3 +- scribo/demo/viewer/segmentation_options.cc | 56 ++++++++++++ scribo/demo/viewer/segmentation_options.hh | 37 ++++++++ scribo/demo/viewer/segmentation_options.ui | 52 ++++++++++++ scribo/demo/viewer/toolchain_options.cc | 75 ----------------- scribo/demo/viewer/toolchain_options.hh | 37 -------- scribo/demo/viewer/toolchain_options.ui | 121 --------------------------- 18 files changed, 605 insertions(+), 247 deletions(-) create mode 100644 scribo/demo/viewer/ocr_options.cc create mode 100644 scribo/demo/viewer/ocr_options.hh create mode 100644 scribo/demo/viewer/ocr_options.ui create mode 100644 scribo/demo/viewer/preprocessing_options.cc create mode 100644 scribo/demo/viewer/preprocessing_options.hh create mode 100644 scribo/demo/viewer/preprocessing_options.ui create mode 100644 scribo/demo/viewer/segmentation_options.cc create mode 100644 scribo/demo/viewer/segmentation_options.hh create mode 100644 scribo/demo/viewer/segmentation_options.ui delete mode 100644 scribo/demo/viewer/toolchain_options.cc delete mode 100644 scribo/demo/viewer/toolchain_options.hh delete mode 100644 scribo/demo/viewer/toolchain_options.ui diff --git a/scribo/ChangeLog b/scribo/ChangeLog index f4a56fd..2af84c0 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,6 +1,34 @@ 2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> - * scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR step optional. + Make OCR step optional in viewer. + + * demo/viewer/Makefile.am: Add new files. + + * demo/viewer/config.cc, + * demo/viewer/config.hh: Add OCR settings. + + * demo/viewer/toolchain_options.cc, + * demo/viewer/toolchain_options.hh, + * demo/viewer/toolchain_options.ui: Remove. + + * demo/viewer/ocr_options.cc, + * demo/viewer/ocr_options.hh, + * demo/viewer/ocr_options.ui, + * demo/viewer/preprocessing_options.cc, + * demo/viewer/preprocessing_options.hh, + * demo/viewer/preprocessing_options.ui, + * demo/viewer/segmentation_options.cc, + * demo/viewer/segmentation_options.hh, + * demo/viewer/segmentation_options.ui: New option widgets. + + * demo/viewer/preferences_dialog.cc: Insert new widgets. + + * demo/viewer/runner.cc: Take OCR settings into account. + +2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> + + * scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR + step optional. 2011-03-03 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/demo/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am index 2c5e4cf..09d9ecc 100644 --- a/scribo/demo/viewer/Makefile.am +++ b/scribo/demo/viewer/Makefile.am @@ -30,7 +30,9 @@ scribo_viewer_SOURCES = viewer.cc \ image_region.cc \ help_dialog.cc \ step_widget.cc \ - toolchain_options.cc \ + preprocessing_options.cc\ + segmentation_options.cc \ + ocr_options.cc \ runner.cc \ preprocess.cc \ process.cc \ @@ -65,8 +67,12 @@ BUILT_SOURCES = viewer.moc.cc \ image_region.moc.cc \ help_dialog.ui.h \ step_widget.moc.cc \ - toolchain_options.moc.cc \ - toolchain_options.ui.h \ + preprocessing_options.moc.cc \ + preprocessing_options.ui.h \ + segmentation_options.moc.cc \ + segmentation_options.ui.h \ + ocr_options.moc.cc \ + ocr_options.ui.h \ runner.moc.cc \ preprocess.moc.cc \ process.moc.cc \ @@ -91,7 +97,9 @@ noinst_HEADERS = viewer.hh \ common.hh \ help_dialog.hh \ step_widget.hh \ - toolchain_options.hh \ + preprocessing_options.hh\ + segmentation_options.hh\ + ocr_options.hh \ runner.hh \ preprocess.hh \ process.hh \ @@ -121,7 +129,9 @@ EXTRA_DIST = \ general_options.ui \ preferences_dialog.ui \ README \ - toolchain_options.ui \ + preprocessing_options.ui\ + segmentation_options.ui \ + ocr_options.ui \ help_dialog.ui \ demodir.hh.in diff --git a/scribo/demo/viewer/config.cc b/scribo/demo/viewer/config.cc index bf12e95..6bdcd35 100644 --- a/scribo/demo/viewer/config.cc +++ b/scribo/demo/viewer/config.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -108,6 +109,31 @@ void config::set_segmentation_find_seps(int seps) } +// OCR + +bool config::ocr_enabled() +{ + return value("ocr/enabled", true).toBool(); +} + +void config::set_ocr_enabled(bool b) +{ + setValue("ocr/enabled", b); +} + + + +QString config::ocr_language() +{ + return value("ocr/language", 0).toString(); +} + +void config::set_ocr_language(const QString& lang) +{ + setValue("ocr/language", lang); +} + + // General options diff --git a/scribo/demo/viewer/config.hh b/scribo/demo/viewer/config.hh index 07d193c..74dab3b 100644 --- a/scribo/demo/viewer/config.hh +++ b/scribo/demo/viewer/config.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -49,6 +50,14 @@ public: void set_segmentation_find_seps(int seps); + // OCR + bool ocr_enabled(); + void set_ocr_enabled(bool b); + + QString ocr_language(); + void set_ocr_language(const QString& lang); + + // General options bool general_save_xml_enabled(); void set_general_save_xml_enabled(bool b); diff --git a/scribo/demo/viewer/ocr_options.cc b/scribo/demo/viewer/ocr_options.cc new file mode 100644 index 0000000..0ff09d9 --- /dev/null +++ b/scribo/demo/viewer/ocr_options.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#include "defs.hh" +#include "ocr_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; + + +static const char *language[][2] = { + { "English", "eng" }, + { "French", "fra" }, + { 0, 0 } +}; + + +ocr_options::ocr_options(QWidget *parent) + : OptionWidget(parent) +{ + setupUi(this); + + for (unsigned i = 0; language[i][0]; ++i) + ocr_language->insertItem(i, language[i][0]); + + load_config(); +} + +ocr_options::~ocr_options() +{ +} + + +int ocr_options::find_index(const QString& lang) +{ + for (unsigned i = 0; language[i][0]; ++i) + if (lang == language[i][1]) + return i; + return 0; +} + + +void ocr_options::load_config() +{ + config * const conf = config::get_instance(); + + enable_ocr->setChecked(conf->ocr_enabled()); + ocr_language->setCurrentIndex(find_index(conf->ocr_language())); +} + + +void ocr_options::save_config() +{ + config * const conf = config::get_instance(); + + conf->set_ocr_enabled(enable_ocr->isChecked()); + conf->set_ocr_language(language[ocr_language->currentIndex()][1]); +} diff --git a/scribo/demo/viewer/ocr_options.hh b/scribo/demo/viewer/ocr_options.hh new file mode 100644 index 0000000..67ab4ef --- /dev/null +++ b/scribo/demo/viewer/ocr_options.hh @@ -0,0 +1,40 @@ +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#ifndef SCRIBO_DEMO_VIEWER_OCR_OPTIONS_HH +# define SCRIBO_DEMO_VIEWER_OCR_OPTIONS_HH + +# include <QtGui> +# include <ocr_options.ui.h> +# include "option_widget.hh" + +class ocr_options : public OptionWidget, private Ui::OcrOptions +{ + Q_OBJECT; + +public: + ocr_options(QWidget *parent = 0); + ~ocr_options(); + + void load_config(); + void save_config(); + +private: + int find_index(const QString& lang); + +}; + +#endif // ! SCRIBO_DEMO_VIEWER_OCR_OPTIONS_HH diff --git a/scribo/demo/viewer/ocr_options.ui b/scribo/demo/viewer/ocr_options.ui new file mode 100644 index 0000000..d001c64 --- /dev/null +++ b/scribo/demo/viewer/ocr_options.ui @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>OcrOptions</class> + <widget class="QWidget" name="OcrOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>366</width> + <height>112</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="enable_ocr"> + <property name="title"> + <string>Enable OCR</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="1"> + <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> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Language</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="ocr_language"/> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/scribo/demo/viewer/preferences_dialog.cc b/scribo/demo/viewer/preferences_dialog.cc index dfd6061..1eb80a7 100644 --- a/scribo/demo/viewer/preferences_dialog.cc +++ b/scribo/demo/viewer/preferences_dialog.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -15,8 +16,10 @@ // along with Olena. If not, see <
http://www.gnu.org/licenses/
>. #include "preferences_dialog.hh" -#include "toolchain_options.hh" #include "general_options.hh" +#include "ocr_options.hh" +#include "preprocessing_options.hh" +#include "segmentation_options.hh" @@ -41,7 +44,7 @@ preferences_dialog::~preferences_dialog() void preferences_dialog::load_option_list() { - static const char *options[] = { "General", "Toolchain", 0 }; + static const char *options[] = { "General", "Preprocessing", "Segmentation", "OCR", 0 }; int i; for (i = 0; options[i]; ++i) @@ -66,19 +69,32 @@ void preferences_dialog::select_option_widget(int row) if (!widgets_[row]) { + QWidget *widget = 0; + switch (row) { case 0: - widgets_[0] = new general_options(this); + widget = new general_options(this); break; case 1: - widgets_[1] = new toolchain_options(this); + widget = new preprocessing_options(this); + break; + + case 2: + widget = new segmentation_options(this); + break; + + case 3: + widget = new ocr_options(this); break; default: qDebug() << "select_option_widget - Hu? Something wrong..."; } + + if (widget) + widgets_[row] = widget; } if (horizontalLayout_2->count() == 2) diff --git a/scribo/demo/viewer/preprocessing_options.cc b/scribo/demo/viewer/preprocessing_options.cc new file mode 100644 index 0000000..2d55fea --- /dev/null +++ b/scribo/demo/viewer/preprocessing_options.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#include "defs.hh" +#include "preprocessing_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; + +preprocessing_options::preprocessing_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"); + + load_config(); +} + +preprocessing_options::~preprocessing_options() +{ +} + + +void preprocessing_options::load_config() +{ + config * const conf = config::get_instance(); + + 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()); +} + + +void preprocessing_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()); +} diff --git a/scribo/demo/viewer/preprocessing_options.hh b/scribo/demo/viewer/preprocessing_options.hh new file mode 100644 index 0000000..c676880 --- /dev/null +++ b/scribo/demo/viewer/preprocessing_options.hh @@ -0,0 +1,38 @@ +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#ifndef SCRIBO_DEMO_VIEWER_PREPROCESSING_OPTIONS_HH +# define SCRIBO_DEMO_VIEWER_PREPROCESSING_OPTIONS_HH + +# include <QtGui> +# include <preprocessing_options.ui.h> +# include "option_widget.hh" + +class preprocessing_options : public OptionWidget, private Ui::PreprocessingOptions +{ + Q_OBJECT; + +public: + preprocessing_options(QWidget *parent = 0); + ~preprocessing_options(); + + void load_config(); + void save_config(); + +}; + +#endif // ! SCRIBO_DEMO_VIEWER_PREPROCESSING_OPTIONS_HH diff --git a/scribo/demo/viewer/preprocessing_options.ui b/scribo/demo/viewer/preprocessing_options.ui new file mode 100644 index 0000000..962cf49 --- /dev/null +++ b/scribo/demo/viewer/preprocessing_options.ui @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreprocessingOptions</class> + <widget class="QWidget" name="PreprocessingOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>466</width> + <height>198</height> + </rect> + </property> + <property name="windowTitle"> + <string>Configure toolchain</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <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 row="1" column="0"> + <widget class="QCheckBox" name="subsampleCb"> + <property name="text"> + <string>Run on subsampled image</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="remove_bgCb"> + <property name="text"> + <string>Remove background (slow)</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="deskewCb"> + <property name="text"> + <string>Deskew</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QCheckBox" name="remove_noiseCb"> + <property name="text"> + <string>Remove noise</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>48</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/scribo/demo/viewer/runner.cc b/scribo/demo/viewer/runner.cc index a3cc883..e923db7 100644 --- a/scribo/demo/viewer/runner.cc +++ b/scribo/demo/viewer/runner.cc @@ -156,7 +156,8 @@ void runner::process(const image2d<value::rgb8>& original_ima, || find_seps == defs::LinesAndWhitespaces); f.enable_whitespace_seps = (find_seps == defs::Whitespaces || find_seps == defs::LinesAndWhitespaces); - + f.enable_ocr = conf->ocr_enabled(); + f.ocr_language = conf->ocr_language().toAscii().data(); f.xml_format = scribo::io::xml::PageExtended; diff --git a/scribo/demo/viewer/segmentation_options.cc b/scribo/demo/viewer/segmentation_options.cc new file mode 100644 index 0000000..c120879 --- /dev/null +++ b/scribo/demo/viewer/segmentation_options.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#include "defs.hh" +#include "segmentation_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; + +segmentation_options::segmentation_options(QWidget *parent) + : OptionWidget(parent) +{ + setupUi(this); + + find_sepsCbox->insertItem(defs::Lines, "Lines"); + find_sepsCbox->insertItem(defs::Whitespaces, "Whitespaces"); + find_sepsCbox->insertItem(defs::LinesAndWhitespaces, "Lines and whitespaces"); + + load_config(); +} + +segmentation_options::~segmentation_options() +{ +} + + +void segmentation_options::load_config() +{ + config * const conf = config::get_instance(); + + find_sepsCbox->setCurrentIndex(conf->segmentation_find_seps()); +} + + +void segmentation_options::save_config() +{ + config * const conf = config::get_instance(); + + conf->set_segmentation_find_seps(find_sepsCbox->currentIndex()); +} diff --git a/scribo/demo/viewer/segmentation_options.hh b/scribo/demo/viewer/segmentation_options.hh new file mode 100644 index 0000000..bdf65f9 --- /dev/null +++ b/scribo/demo/viewer/segmentation_options.hh @@ -0,0 +1,37 @@ +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#ifndef SCRIBO_DEMO_VIEWER_SEGMENTATION_OPTIONS_HH +# define SCRIBO_DEMO_VIEWER_SEGMENTATION_OPTIONS_HH + +# include <QtGui> +# include <segmentation_options.ui.h> +# include "option_widget.hh" + +class segmentation_options : public OptionWidget, private Ui::SegmentationOptions +{ + Q_OBJECT; + +public: + segmentation_options(QWidget *parent = 0); + ~segmentation_options(); + + void load_config(); + void save_config(); + +}; + +#endif // ! SCRIBO_DEMO_VIEWER_SEGMENTATION_OPTIONS_HH diff --git a/scribo/demo/viewer/segmentation_options.ui b/scribo/demo/viewer/segmentation_options.ui new file mode 100644 index 0000000..485e448 --- /dev/null +++ b/scribo/demo/viewer/segmentation_options.ui @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SegmentationOptions</class> + <widget class="QWidget" name="SegmentationOptions"> + <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="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <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"> + <property name="editable"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>258</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/scribo/demo/viewer/toolchain_options.cc b/scribo/demo/viewer/toolchain_options.cc deleted file mode 100644 index 6024ff3..0000000 --- a/scribo/demo/viewer/toolchain_options.cc +++ /dev/null @@ -1,75 +0,0 @@ -// 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 deleted file mode 100644 index afad3e7..0000000 --- a/scribo/demo/viewer/toolchain_options.hh +++ /dev/null @@ -1,37 +0,0 @@ -// 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 deleted file mode 100644 index 748696d..0000000 --- a/scribo/demo/viewer/toolchain_options.ui +++ /dev/null @@ -1,121 +0,0 @@ -<?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
13 years, 9 months
1
0
0
0
last-svn-commit-789-g8461438 scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR step optional.
by Guillaume Lazzara
--- scribo/ChangeLog | 8 ++++++-- .../toolchain/internal/content_in_doc_functor.hh | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 52da198..f4a56fd 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,9 +1,13 @@ +2011-03-04 Guillaume Lazzara <z(a)lrde.epita.fr> + + * scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR step optional. + 2011-03-03 Guillaume Lazzara <z(a)lrde.epita.fr> Compress image data in XML output. - * scribo/scribo/io/xml/internal/full_xml_visitor.hh, - * scribo/scribo/io/xml/load.hh: Here. + * scribo/io/xml/internal/full_xml_visitor.hh, + * scribo/io/xml/load.hh: Here. 2011-03-03 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 index dcbb4f7..40f013c 100644 --- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh @@ -111,6 +111,7 @@ namespace scribo bool enable_denoising; bool enable_line_seps; bool enable_whitespace_seps; + bool enable_ocr; bool enable_debug; bool save_doc_as_xml; scribo::io::xml::Format xml_format; @@ -136,6 +137,7 @@ namespace scribo : enable_denoising(true), enable_line_seps(true), enable_whitespace_seps(true), + enable_ocr(true), enable_debug(false), save_doc_as_xml(false), xml_format(scribo::io::xml::PageExtended), @@ -373,11 +375,14 @@ namespace scribo // Text recognition - on_new_progress_label("Recognizing text"); - scribo::text::recognition(lines, ocr_language.c_str()); + if (enable_ocr) + { + on_new_progress_label("Recognizing text"); - on_progress(); + scribo::text::recognition(lines, ocr_language.c_str()); + on_progress(); + } // Link text lines on_new_progress_label("Linking text lines"); @@ -390,7 +395,7 @@ namespace scribo image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); for_all_lines(l, lines) { - if (! lines(l).is_valid() || lines(l).is_hidden() || lines(l).type() != line::Text) + if (! lines(l).is_textline()) continue; mln::draw::box(debug, lines(l).bbox(), literal::blue); @@ -427,7 +432,7 @@ namespace scribo mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements()); for_all_lines(i, lines) { - if (! lines(i).is_valid() || lines(i).is_hidden() || lines(i).type() != line::Text) + if (! lines(i).is_textline()) continue; mln::draw::box(debug, lines(i).bbox(), literal::red); @@ -497,8 +502,8 @@ namespace scribo int content_in_doc_functor<I>::nsteps() const { - return 11 + enable_denoising + enable_line_seps - + enable_whitespace_seps + save_doc_as_xml; + return 10 + enable_denoising + enable_line_seps + + enable_whitespace_seps + enable_ocr + save_doc_as_xml; } -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-788-ge334996 Compress image data in XML output.
by Guillaume Lazzara
* scribo/scribo/io/xml/internal/full_xml_visitor.hh, * scribo/scribo/io/xml/load.hh: Here. --- scribo/ChangeLog | 7 ++++ scribo/scribo/io/xml/internal/full_xml_visitor.hh | 34 ++++++++++++++------ scribo/scribo/io/xml/load.hh | 12 +++++-- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index da0d095..52da198 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,12 @@ 2011-03-03 Guillaume Lazzara <z(a)lrde.epita.fr> + Compress image data in XML output. + + * scribo/scribo/io/xml/internal/full_xml_visitor.hh, + * scribo/scribo/io/xml/load.hh: Here. + +2011-03-03 Guillaume Lazzara <z(a)lrde.epita.fr> + Small fixes in Scribo. * scribo/convert/from_base64.hh: Remove guards HAVE_QT. diff --git a/scribo/scribo/io/xml/internal/full_xml_visitor.hh b/scribo/scribo/io/xml/internal/full_xml_visitor.hh index 9c5bd1d..2b09b3a 100644 --- a/scribo/scribo/io/xml/internal/full_xml_visitor.hh +++ b/scribo/scribo/io/xml/internal/full_xml_visitor.hh @@ -31,6 +31,9 @@ /// XML serializer Visitor. # include <fstream> + +# include <QByteArray> + # include <scribo/core/internal/doc_xml_serializer.hh> # include <scribo/core/document.hh> # include <scribo/core/component_set.hh> @@ -40,11 +43,12 @@ # include <scribo/core/line_links.hh> # include <scribo/core/line_info.hh> -# include <scribo/convert/to_base64.hh> - # include <scribo/io/xml/internal/print_box_coords.hh> # include <scribo/io/xml/internal/print_page_preambule.hh> +// Compression level 0-9. 9 is the best but is slow. +// 5 seems to be a good compromise. +# define COMPRESSION_LEVEL 5 namespace scribo { @@ -273,15 +277,20 @@ namespace scribo << "\" width=\"" << lbl.domain().width() << "\">" << "<![CDATA["; - util::array<unsigned char> lbl64; - convert::to_base64(lbl, lbl64); - output.write((const char *)lbl64.std_vector().data(), - lbl64.nelements()); + // FIXME: Try to avoid that! + border::resize(lbl, 0); + QByteArray lbl64((const char *)lbl.buffer(), + lbl.nelements() * sizeof(mln_value(L))); + lbl64 = qCompress(lbl64, COMPRESSION_LEVEL); + lbl64 = lbl64.toBase64(); + + output.write(lbl64.data(), lbl64.size()); output << "]]></labeled_image>" << std::endl; } // Save separators image + if (comp_set.has_separators()) { const mln_ch_value(L,bool)& seps = comp_set.separators(); output << "<separators_image " @@ -289,10 +298,13 @@ namespace scribo << "\" width=\"" << seps.domain().width() << "\">" << "<![CDATA["; - util::array<unsigned char> seps64; - convert::to_base64(seps, seps64); - output.write((const char *)seps64.std_vector().data(), - seps64.nelements()); + border::resize(seps, 0); + QByteArray seps64((const char *)seps.buffer(), + seps.nelements() * sizeof(bool)); + seps64 = qCompress(seps64, COMPRESSION_LEVEL); + seps64 = seps64.toBase64(); + + output.write(seps64.data(), seps64.size()); output << "]]></separators_image>" << std::endl; } @@ -453,4 +465,6 @@ namespace scribo } // end of namespace scribo +# undef COMPRESSION_LEVEL + #endif // SCRIBO_IO_XML_INTERNAL_FULL_XML_VISITOR_HH diff --git a/scribo/scribo/io/xml/load.hh b/scribo/scribo/io/xml/load.hh index e0f4548..8042c75 100644 --- a/scribo/scribo/io/xml/load.hh +++ b/scribo/scribo/io/xml/load.hh @@ -50,8 +50,6 @@ # include <scribo/core/line_set.hh> # include <scribo/core/line_info.hh> -# include <scribo/convert/from_base64.hh> - namespace scribo { @@ -405,13 +403,19 @@ namespace scribo { case LabeledImage: { - scribo::convert::from_base64(ch, comp_set_data->ima_); + QByteArray data = ch.toAscii(); + data = QByteArray::fromBase64(data); + data = qUncompress(data); + memcpy((char *) comp_set_data->ima_.buffer(), data.data(), data.size()); } break; case SeparatorsImage: { - scribo::convert::from_base64(ch, comp_set_data->separators_); + QByteArray data = ch.toAscii(); + data = QByteArray::fromBase64(data); + data = qUncompress(data); + memcpy((char *) comp_set_data->separators_.buffer(), data.data(), data.size()); } break; -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-787-g8ef4bff Small fixes in Scribo.
by Guillaume Lazzara
* scribo/convert/from_base64.hh: Remove guards HAVE_QT. * scribo/core/document.hh: Initialize ImageMagick. * scribo/io/xml/internal/html_markups_replace.hh: Remove. Move code... * scribo/core/line_info.hh: ... here. * scribo/core/line_links.hh: Make use of is_textline method. * scribo/core/paragraph_info.hh: Add nlines method. * scribo/core/paragraph_set.hh: Add a construction routine using a line_set. * scribo/io/xml/internal/extended_page_xml_visitor.hh, * scribo/io/xml/internal/print_box_coords.hh, * scribo/io/xml/internal/print_page_preambule.hh, * src/primitive/extract/separators_nonvisible.cc: Fix includes. * scribo/io/xml/save.hh: Add a precondition. * scribo/text/extract_lines.hh, * src/debug/show_info_median_inter_characters.cc, * src/debug/show_info_x_height.cc, * src/debug/show_text_lines.cc: Fix label type. --- scribo/ChangeLog | 30 ++++++ scribo/scribo/convert/from_base64.hh | 8 -- scribo/scribo/core/document.hh | 1 + scribo/scribo/core/line_info.hh | 45 ++++++++- scribo/scribo/core/line_links.hh | 5 +- scribo/scribo/core/paragraph_info.hh | 9 ++ scribo/scribo/core/paragraph_set.hh | 28 ++++++ .../io/xml/internal/extended_page_xml_visitor.hh | 2 - .../scribo/io/xml/internal/html_markups_replace.hh | 97 -------------------- scribo/scribo/io/xml/internal/print_box_coords.hh | 3 + .../scribo/io/xml/internal/print_page_preambule.hh | 5 + scribo/scribo/io/xml/save.hh | 2 + scribo/scribo/text/extract_lines.hh | 16 ++-- .../src/debug/show_info_median_inter_characters.cc | 12 +- scribo/src/debug/show_info_x_height.cc | 12 +- scribo/src/debug/show_text_lines.cc | 2 +- .../src/primitive/extract/separators_nonvisible.cc | 2 +- 17 files changed, 143 insertions(+), 136 deletions(-) delete mode 100644 scribo/scribo/io/xml/internal/html_markups_replace.hh diff --git a/scribo/ChangeLog b/scribo/ChangeLog index a300b37..da0d095 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,33 @@ +2011-03-03 Guillaume Lazzara <z(a)lrde.epita.fr> + + Small fixes in Scribo. + + * scribo/convert/from_base64.hh: Remove guards HAVE_QT. + + * scribo/core/document.hh: Initialize ImageMagick. + + * scribo/io/xml/internal/html_markups_replace.hh: Remove. Move code... + * scribo/core/line_info.hh: ... here. + + * scribo/core/line_links.hh: Make use of is_textline method. + + * scribo/core/paragraph_info.hh: Add nlines method. + + * scribo/core/paragraph_set.hh: Add a construction routine using a + line_set. + + * scribo/io/xml/internal/extended_page_xml_visitor.hh, + * scribo/io/xml/internal/print_box_coords.hh, + * scribo/io/xml/internal/print_page_preambule.hh, + * src/primitive/extract/separators_nonvisible.cc: Fix includes. + + * scribo/io/xml/save.hh: Add a precondition. + + * scribo/text/extract_lines.hh, + * src/debug/show_info_median_inter_characters.cc, + * src/debug/show_info_x_height.cc, + * src/debug/show_text_lines.cc: Fix label type. + 2011-03-02 Guillaume Lazzara <z(a)lrde.epita.fr> Regen mk files. diff --git a/scribo/scribo/convert/from_base64.hh b/scribo/scribo/convert/from_base64.hh index 8c14a0f..5eeeb53 100644 --- a/scribo/scribo/convert/from_base64.hh +++ b/scribo/scribo/convert/from_base64.hh @@ -82,13 +82,9 @@ namespace scribo Image<I>& output); -# if defined HAVE_QT - template <typename I> void from_base64(const QString& data64, Image<I>& output_); -# endif // ! HAVE_QT - # ifndef MLN_INCLUDE_ONLY @@ -191,8 +187,6 @@ namespace scribo } -# if defined HAVE_QT - template <typename I> void from_base64(const QString& data64, Image<I>& output_) @@ -205,8 +199,6 @@ namespace scribo trace::exiting("scribo::convert::to_base64"); } -# endif // ! HAVE_QT - # endif // ! MLN_INCLUDE_ONLY diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh index 372f0a4..689d0e3 100644 --- a/scribo/scribo/core/document.hh +++ b/scribo/scribo/core/document.hh @@ -160,6 +160,7 @@ namespace scribo void document<L>::open() { + Magick::InitializeMagick(0); mln::io::magick::load(image_, filename_); } diff --git a/scribo/scribo/core/line_info.hh b/scribo/scribo/core/line_info.hh index 33a1529..46ba720 100644 --- a/scribo/scribo/core/line_info.hh +++ b/scribo/scribo/core/line_info.hh @@ -35,9 +35,10 @@ /// from the x_height and the baseline. /// /// \fixme The way the meanline and the baseline are computed is not -/// optimal and does not work is the components are too high (because +/// optimal and does not work if the components are too high (because /// of the median accumulator and int_u12 overflows). +# include <map> # include <mln/core/alias/box2d.hh> # include <mln/core/alias/point2d.hh> @@ -53,8 +54,6 @@ # include <scribo/core/line_set.hh> # include <scribo/core/component_set.hh> -# include <scribo/io/xml/internal/html_markups_replace.hh> - # include <scribo/core/concept/serializable.hh> @@ -287,6 +286,42 @@ namespace scribo namespace internal { + // INTERNAL TOOLS + + static inline std::map<char, std::string> init_map() + { + std::map<char, std::string> html_map; + html_map['\"'] = """; + html_map['<'] = "<"; + html_map['>'] = ">"; + html_map['&'] = "&"; + return html_map; + } + + + inline + std::string + html_markups_replace(const std::string& input) + { + static std::map<char, std::string> map = init_map(); + + std::string output = input; + for (unsigned i = 0; i < input.size(); ++i) + { + std::map<char, std::string>::iterator it = map.find(output.at(i)); + if (it != map.end()) + { + output.replace(i, 1, it->second); + i += it->second.size() - 1; + } + } + return output; + } + + + + // LINE INFO DATA + template <typename L> line_info_data<L>::line_info_data() { @@ -641,7 +676,7 @@ namespace scribo line_info<L>::update_text(const std::string& str) { data_->text_ = str; - data_->html_text_ = scribo::io::xml::internal::html_markups_replace(str); + data_->html_text_ = scribo::internal::html_markups_replace(str); } @@ -869,6 +904,8 @@ namespace scribo ref_line = mln::math::min(comp_set(c).bbox().pmin().row(), ref_line); } + // FIXME: compute font color! + for_all_elements(i, data_->components_) { unsigned c = data_->components_(i); diff --git a/scribo/scribo/core/line_links.hh b/scribo/scribo/core/line_links.hh index fdd09a5..ab36a73 100644 --- a/scribo/scribo/core/line_links.hh +++ b/scribo/scribo/core/line_links.hh @@ -215,9 +215,8 @@ namespace scribo line_links<L>::init() { for (unsigned i = 0; i < nelements(); ++i) - if (! data_->lines_(i).is_valid() - || data_->lines_(i).is_hidden() - || data_->lines_(i).type() != line::Text) + if (!data_->lines_(i).is_valid() + || !data_->lines_(i).is_textline()) { data_->line_to_link_(i) = 0; } diff --git a/scribo/scribo/core/paragraph_info.hh b/scribo/scribo/core/paragraph_info.hh index 17f847f..f4b1309 100644 --- a/scribo/scribo/core/paragraph_info.hh +++ b/scribo/scribo/core/paragraph_info.hh @@ -52,6 +52,8 @@ namespace scribo const mln::util::array<line_id_t>& line_ids() const; + unsigned nlines() const; + bool is_valid() const; private: @@ -106,6 +108,13 @@ namespace scribo } template <typename L> + unsigned + paragraph_info<L>::nlines() const + { + return line_ids_.nelements(); + } + + template <typename L> bool paragraph_info<L>::is_valid() const { diff --git a/scribo/scribo/core/paragraph_set.hh b/scribo/scribo/core/paragraph_set.hh index 5451069..f081472 100644 --- a/scribo/scribo/core/paragraph_set.hh +++ b/scribo/scribo/core/paragraph_set.hh @@ -215,6 +215,7 @@ namespace scribo } // end of namespace scribo::make::internal + // FIXME: move that code into paragraph_set constructor? template <typename L> scribo::paragraph_set<L> paragraph(const line_links<L>& llinks) @@ -241,6 +242,33 @@ namespace scribo return parset; } + + // FIXME: move that code into paragraph_set constructor? + template <typename L> + scribo::paragraph_set<L> + paragraph(const scribo::line_set<L>& lines) + { + line_links<L> links(lines); + links.init(); + + unsigned npars; + mln::fun::i2v::array<unsigned> + par_ids = mln::make::relabelfun(links.line_to_link(), + links.nelements() - 1, npars); + paragraph_set<L> parset(links, npars); + + for_all_links(l, links) + if (links(l)) + { + value::int_u16 par_id = par_ids(l); + parset(par_id).add_line(lines(l)); + } + + return parset; + } + + + } // end of namespace scribo::make diff --git a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh index 5d8a672..4da0755 100644 --- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh +++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh @@ -40,8 +40,6 @@ # include <scribo/core/line_links.hh> # include <scribo/core/line_info.hh> -# include <scribo/convert/to_base64.hh> - # include <scribo/io/xml/internal/print_box_coords.hh> # include <scribo/io/xml/internal/print_page_preambule.hh> diff --git a/scribo/scribo/io/xml/internal/html_markups_replace.hh b/scribo/scribo/io/xml/internal/html_markups_replace.hh deleted file mode 100644 index 76f8107..0000000 --- a/scribo/scribo/io/xml/internal/html_markups_replace.hh +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) -// -// This file is part of Olena. -// -// Olena is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free -// Software Foundation, version 2 of the License. -// -// Olena is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. -// -// As a special exception, you may use this file as part of a free -// software project without restriction. Specifically, if other files -// instantiate templates or use macros or inline functions from this -// file, or you compile this file and link it with other files to produce -// an executable, this file does not by itself cause the resulting -// executable to be covered by the GNU General Public License. This -// exception does not however invalidate any other reasons why the -// executable file might be covered by the GNU General Public License. - -#ifndef SCRIBO_IO_XML_INTERNAL_HTML_MARKUPS_REPLACE_HH -# define SCRIBO_IO_XML_INTERNAL_HTML_MARKUPS_REPLACE_HH - -/// \file -/// -/// \brief Replace HTML markups characters by their corresponding -/// markups. - - -namespace scribo -{ - - namespace io - { - - namespace xml - { - - namespace internal - { - - /*! \brief Replace HTML markups characters by their corresponding - markups. - */ - inline - std::string - html_markups_replace(std::string& input); - - -# ifndef MLN_INCLUDE_ONLY - - static inline std::map<char, std::string> init_map() - { - std::map<char, std::string> html_map; - html_map['\"'] = """; - html_map['<'] = "<"; - html_map['>'] = ">"; - html_map['&'] = "&"; - return html_map; - } - - - inline - std::string - html_markups_replace(const std::string& input) - { - static std::map<char, std::string> map = init_map(); - - std::string output = input; - for (unsigned i = 0; i < input.size(); ++i) - { - std::map<char, std::string>::iterator it = map.find(output.at(i)); - if (it != map.end()) - { - output.replace(i, 1, it->second); - i += it->second.size() - 1; - } - } - return output; - } - -# endif // ! MLN_INCLUDE_ONLY - - } // end of namespace scribo::io::xml::internal - - } // end of namespace scribo::io::xml - - } // end of namespace scribo::io - -} // end of namespace scribo - -#endif // ! SCRIBO_IO_XML_INTERNAL_HTML_MARKUPS_REPLACE_HH diff --git a/scribo/scribo/io/xml/internal/print_box_coords.hh b/scribo/scribo/io/xml/internal/print_box_coords.hh index d3aeedf..ad84709 100644 --- a/scribo/scribo/io/xml/internal/print_box_coords.hh +++ b/scribo/scribo/io/xml/internal/print_box_coords.hh @@ -30,6 +30,7 @@ /// /// \brief Prints box2d coordinates to XML data. +# include <fstream> # include <mln/core/alias/box2d.hh> namespace scribo @@ -44,6 +45,8 @@ namespace scribo namespace internal { + using namespace mln; + /*! \brief Prints box2d coordinates to XML data. */ void diff --git a/scribo/scribo/io/xml/internal/print_page_preambule.hh b/scribo/scribo/io/xml/internal/print_page_preambule.hh index b5ae891..3ee29be 100644 --- a/scribo/scribo/io/xml/internal/print_page_preambule.hh +++ b/scribo/scribo/io/xml/internal/print_page_preambule.hh @@ -30,7 +30,9 @@ /// /// \brief Print PAGE XML format preambule. +# include <fstream> # include <mln/core/alias/box2d.hh> +# include <scribo/core/document.hh> namespace scribo { @@ -44,6 +46,9 @@ namespace scribo namespace internal { + using namespace mln; + + /// \brief Print PAGE XML format preambule. template <typename L> void print_PAGE_preambule(std::ofstream& output, diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh index 30579d0..7428e5d 100644 --- a/scribo/scribo/io/xml/save.hh +++ b/scribo/scribo/io/xml/save.hh @@ -121,6 +121,8 @@ namespace scribo { trace::entering("scribo::io::xml::save"); + mln_precondition(doc.is_open()); + // Open file std::ofstream output(output_name.c_str()); if (! output) diff --git a/scribo/scribo/text/extract_lines.hh b/scribo/scribo/text/extract_lines.hh index b81cb79..9949d09 100644 --- a/scribo/scribo/text/extract_lines.hh +++ b/scribo/scribo/text/extract_lines.hh @@ -33,8 +33,8 @@ # include <mln/core/concept/image.hh> -# include <mln/value/int_u16.hh> +# include <scribo/core/def/lbl_type.hh> # include <scribo/core/line_set.hh> # include <scribo/primitive/extract/components.hh> @@ -71,13 +71,13 @@ namespace scribo ** \return A set of lines. */ template <typename I, typename N> - line_set<mln_ch_value(I,value::int_u16)> + line_set<mln_ch_value(I,scribo::def::lbl_type)> extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_, const mln_ch_value(I,bool)& separators); /// \overload template <typename I, typename N> - line_set<mln_ch_value(I,value::int_u16)> + line_set<mln_ch_value(I,scribo::def::lbl_type)> extract_lines(const Image<I>& input, const Neighborhood<N>& nbh); @@ -85,7 +85,7 @@ namespace scribo template <typename I, typename N> - line_set<mln_ch_value(I,value::int_u16)> + line_set<mln_ch_value(I,scribo::def::lbl_type)> extract_lines(const Image<I>& input, const Neighborhood<N>& nbh) { mln_ch_value(I,bool) seps; @@ -94,7 +94,7 @@ namespace scribo template <typename I, typename N> - line_set<mln_ch_value(I,value::int_u16)> + line_set<mln_ch_value(I,scribo::def::lbl_type)> extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_, const mln_ch_value(I,bool)& separators) { @@ -107,10 +107,10 @@ namespace scribo mln_precondition(nbh.is_valid()); /// Finding comps. - typedef mln_ch_value(I,value::int_u16) L; - value::int_u16 ncomps; + typedef mln_ch_value(I,scribo::def::lbl_type) L; + scribo::def::lbl_type ncomps; component_set<L> - comps = scribo::primitive::extract::components(input, c8(), ncomps); + comps = scribo::primitive::extract::components(input, nbh, ncomps); /// First filtering. comps = scribo::filter::components_small(comps, 3); diff --git a/scribo/src/debug/show_info_median_inter_characters.cc b/scribo/src/debug/show_info_median_inter_characters.cc index b55079d..2ba240e 100644 --- a/scribo/src/debug/show_info_median_inter_characters.cc +++ b/scribo/src/debug/show_info_median_inter_characters.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -35,7 +35,7 @@ #include <mln/io/ppm/save.hh> #include <mln/value/rgb8.hh> -#include <mln/value/label_16.hh> +#include <mln/value/int_u16.hh> #include <mln/draw/box.hh> #include <mln/draw/line.hh> @@ -71,14 +71,14 @@ int main(int argc, char* argv[]) image2d<bool> input; - io::pbm::load(input, argv[1]); + mln::io::pbm::load(input, argv[1]); - typedef image2d<value::label_16> L; + typedef image2d<scribo::def::lbl_type> L; line_set<L> line = scribo::text::extract_lines(input, c8()); image2d<value::rgb8> output = scribo::debug::char_space_image(input, line); - io::ppm::save(output, argv[2]); + mln::io::ppm::save(output, argv[2]); trace::exiting("main"); } diff --git a/scribo/src/debug/show_info_x_height.cc b/scribo/src/debug/show_info_x_height.cc index e5ff8d2..2997230 100644 --- a/scribo/src/debug/show_info_x_height.cc +++ b/scribo/src/debug/show_info_x_height.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -35,8 +35,8 @@ #include <mln/io/ppm/save.hh> #include <mln/value/rgb8.hh> -#include <mln/value/label_16.hh> +#include <scribo/core/def/lbl_type.hh> #include <scribo/text/extract_lines.hh> #include <scribo/debug/line_info_image.hh> #include <scribo/debug/usage.hh> @@ -66,14 +66,14 @@ int main(int argc, char* argv[]) image2d<bool> input; - io::pbm::load(input, argv[1]); + mln::io::pbm::load(input, argv[1]); - typedef image2d<value::label_16> L; + typedef image2d<scribo::def::lbl_type> L; line_set<L> line = scribo::text::extract_lines(input, c8()); image2d<value::rgb8> output = scribo::debug::line_info_image(input, line); - io::ppm::save(output, argv[2]); + mln::io::ppm::save(output, argv[2]); trace::exiting("main"); } diff --git a/scribo/src/debug/show_text_lines.cc b/scribo/src/debug/show_text_lines.cc index a031072..368f375 100644 --- a/scribo/src/debug/show_text_lines.cc +++ b/scribo/src/debug/show_text_lines.cc @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) util::timer t; t.start(); - typedef image2d<value::int_u16> L; + typedef image2d<scribo::def::lbl_type> L; line_set<L> lines = text::extract_lines(input, c8(), input_seps); t.stop(); diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc index 82d4787..d50cc73 100644 --- a/scribo/src/primitive/extract/separators_nonvisible.cc +++ b/scribo/src/primitive/extract/separators_nonvisible.cc @@ -27,7 +27,7 @@ #include <mln/io/pbm/all.hh> #include <mln/data/convert.hh> -#include <scribo/primitive/extract/separators_nonvisible2.hh> +#include <scribo/primitive/extract/separators_nonvisible.hh> #include <scribo/debug/usage.hh> const char *args_desc[][2] = -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-786-gb4cc9d5 Regen mk files.
by Guillaume Lazzara
* scribo/headers.mk, * scribo/tests/unit_test/unit-tests.mk: Regen. * scribo/tests/unit_test/cond_tests_qt: Add scribo/io/xml/load.hh. --- scribo/ChangeLog | 9 +++++++++ scribo/headers.mk | 13 ++++++++++++- scribo/tests/unit_test/cond_tests_qt | 1 + scribo/tests/unit_test/unit-tests.mk | 30 +++++++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 9914b73..a300b37 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,12 @@ +2011-03-02 Guillaume Lazzara <z(a)lrde.epita.fr> + + Regen mk files. + + * scribo/headers.mk, + * scribo/tests/unit_test/unit-tests.mk: Regen. + + * scribo/tests/unit_test/cond_tests_qt: Add scribo/io/xml/load.hh. + 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> * scribo/primitive/extract/non_text.hh: Remove debug. diff --git a/scribo/headers.mk b/scribo/headers.mk index 7603f8a..0b21a3f 100644 --- a/scribo/headers.mk +++ b/scribo/headers.mk @@ -14,17 +14,22 @@ scribo/binarization/sauvola_ms.hh \ scribo/binarization/sauvola_ms_split.hh \ scribo/binarization/sauvola_threshold_image.hh \ scribo/canvas/integral_browsing.hh \ +scribo/convert/from_base64.hh \ scribo/convert/from_qimage.hh \ +scribo/convert/to_base64.hh \ scribo/core/all.hh \ scribo/core/central_sites.hh \ scribo/core/component_info.hh \ scribo/core/component_set.hh \ scribo/core/concept/dmax_functor.hh \ scribo/core/concept/link_functor.hh \ +scribo/core/concept/serializable.hh \ +scribo/core/concept/serialize_visitor.hh \ scribo/core/def/lbl_type.hh \ scribo/core/document.hh \ scribo/core/erase_objects.hh \ scribo/core/init_integral_image.hh \ +scribo/core/internal/doc_xml_serializer.hh \ scribo/core/line_info.hh \ scribo/core/line_links.hh \ scribo/core/line_set.hh \ @@ -93,6 +98,12 @@ scribo/fun/v2b/label_to_bool.hh \ scribo/fun/v2b/objects_large_filter.hh \ scribo/fun/v2b/objects_small_filter.hh \ scribo/io/text_boxes/save.hh \ +scribo/io/xml/internal/extended_page_xml_visitor.hh \ +scribo/io/xml/internal/full_xml_visitor.hh \ +scribo/io/xml/internal/page_xml_visitor.hh \ +scribo/io/xml/internal/print_box_coords.hh \ +scribo/io/xml/internal/print_page_preambule.hh \ +scribo/io/xml/load.hh \ scribo/io/xml/save.hh \ scribo/make/all.hh \ scribo/make/debug_filename.hh \ @@ -115,7 +126,6 @@ scribo/primitive/extract/all.hh \ scribo/primitive/extract/canvas.hh \ scribo/primitive/extract/cells.hh \ scribo/primitive/extract/components.hh \ -scribo/primitive/extract/elements.hh \ scribo/primitive/extract/horizontal_separators.hh \ scribo/primitive/extract/lines_discontinued.hh \ scribo/primitive/extract/lines_h_discontinued.hh \ @@ -130,6 +140,7 @@ scribo/primitive/extract/lines_v_pattern.hh \ scribo/primitive/extract/lines_v_single.hh \ scribo/primitive/extract/lines_v_thick.hh \ scribo/primitive/extract/lines_v_thick_and_single.hh \ +scribo/primitive/extract/non_text.hh \ scribo/primitive/extract/separators.hh \ scribo/primitive/extract/separators_nonvisible.hh \ scribo/primitive/extract/vertical_separators.hh \ diff --git a/scribo/tests/unit_test/cond_tests_qt b/scribo/tests/unit_test/cond_tests_qt index 5428215..577f9e6 100644 --- a/scribo/tests/unit_test/cond_tests_qt +++ b/scribo/tests/unit_test/cond_tests_qt @@ -1 +1,2 @@ scribo/convert/from_qimage.hh +scribo/io/xml/load.hh diff --git a/scribo/tests/unit_test/unit-tests.mk b/scribo/tests/unit_test/unit-tests.mk index 6a8f29d..71b0b5b 100644 --- a/scribo/tests/unit_test/unit-tests.mk +++ b/scribo/tests/unit_test/unit-tests.mk @@ -19,11 +19,15 @@ endif HAVE_MAGICKXX # Starting a conditional unit test list. if HAVE_QT check_PROGRAMS += \ -scribo_convert_from_qimage +scribo_convert_from_qimage \ +scribo_io_xml_load scribo_convert_from_qimage_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS} scribo_convert_from_qimage_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS} scribo_convert_from_qimage_SOURCES = scribo_convert_from_qimage.cc +scribo_io_xml_load_CPPFLAGS= ${QT_CPPFLAGS} ${AM_CPPFLAGS} +scribo_io_xml_load_LDFLAGS= ${QT_LDFLAGS} ${AM_LDFLAGS} +scribo_io_xml_load_SOURCES = scribo_io_xml_load.cc endif HAVE_QT # Starting a conditional unit test list. @@ -79,16 +83,21 @@ scribo_binarization_sauvola_ms \ scribo_binarization_sauvola_ms_split \ scribo_binarization_sauvola_threshold_image \ scribo_canvas_integral_browsing \ +scribo_convert_from_base64 \ +scribo_convert_to_base64 \ scribo_core_all \ scribo_core_central_sites \ scribo_core_component_info \ scribo_core_component_set \ scribo_core_concept_dmax_functor \ scribo_core_concept_link_functor \ +scribo_core_concept_serializable \ +scribo_core_concept_serialize_visitor \ scribo_core_def_lbl_type \ scribo_core_document \ scribo_core_erase_objects \ scribo_core_init_integral_image \ +scribo_core_internal_doc_xml_serializer \ scribo_core_line_info \ scribo_core_line_links \ scribo_core_line_set \ @@ -157,6 +166,11 @@ scribo_fun_v2b_label_to_bool \ scribo_fun_v2b_objects_large_filter \ scribo_fun_v2b_objects_small_filter \ scribo_io_text_boxes_save \ +scribo_io_xml_internal_extended_page_xml_visitor \ +scribo_io_xml_internal_full_xml_visitor \ +scribo_io_xml_internal_page_xml_visitor \ +scribo_io_xml_internal_print_box_coords \ +scribo_io_xml_internal_print_page_preambule \ scribo_io_xml_save \ scribo_make_all \ scribo_make_debug_filename \ @@ -179,7 +193,6 @@ scribo_primitive_extract_all \ scribo_primitive_extract_canvas \ scribo_primitive_extract_cells \ scribo_primitive_extract_components \ -scribo_primitive_extract_elements \ scribo_primitive_extract_horizontal_separators \ scribo_primitive_extract_lines_discontinued \ scribo_primitive_extract_lines_h_discontinued \ @@ -194,6 +207,7 @@ scribo_primitive_extract_lines_v_pattern \ scribo_primitive_extract_lines_v_single \ scribo_primitive_extract_lines_v_thick \ scribo_primitive_extract_lines_v_thick_and_single \ +scribo_primitive_extract_non_text \ scribo_primitive_extract_separators \ scribo_primitive_extract_separators_nonvisible \ scribo_primitive_extract_vertical_separators \ @@ -286,16 +300,21 @@ scribo_binarization_sauvola_ms_SOURCES = scribo_binarization_sauvola_ms.cc scribo_binarization_sauvola_ms_split_SOURCES = scribo_binarization_sauvola_ms_split.cc scribo_binarization_sauvola_threshold_image_SOURCES = scribo_binarization_sauvola_threshold_image.cc scribo_canvas_integral_browsing_SOURCES = scribo_canvas_integral_browsing.cc +scribo_convert_from_base64_SOURCES = scribo_convert_from_base64.cc +scribo_convert_to_base64_SOURCES = scribo_convert_to_base64.cc scribo_core_all_SOURCES = scribo_core_all.cc scribo_core_central_sites_SOURCES = scribo_core_central_sites.cc scribo_core_component_info_SOURCES = scribo_core_component_info.cc scribo_core_component_set_SOURCES = scribo_core_component_set.cc scribo_core_concept_dmax_functor_SOURCES = scribo_core_concept_dmax_functor.cc scribo_core_concept_link_functor_SOURCES = scribo_core_concept_link_functor.cc +scribo_core_concept_serializable_SOURCES = scribo_core_concept_serializable.cc +scribo_core_concept_serialize_visitor_SOURCES = scribo_core_concept_serialize_visitor.cc scribo_core_def_lbl_type_SOURCES = scribo_core_def_lbl_type.cc scribo_core_document_SOURCES = scribo_core_document.cc scribo_core_erase_objects_SOURCES = scribo_core_erase_objects.cc scribo_core_init_integral_image_SOURCES = scribo_core_init_integral_image.cc +scribo_core_internal_doc_xml_serializer_SOURCES = scribo_core_internal_doc_xml_serializer.cc scribo_core_line_info_SOURCES = scribo_core_line_info.cc scribo_core_line_links_SOURCES = scribo_core_line_links.cc scribo_core_line_set_SOURCES = scribo_core_line_set.cc @@ -364,6 +383,11 @@ scribo_fun_v2b_label_to_bool_SOURCES = scribo_fun_v2b_label_to_bool.cc scribo_fun_v2b_objects_large_filter_SOURCES = scribo_fun_v2b_objects_large_filter.cc scribo_fun_v2b_objects_small_filter_SOURCES = scribo_fun_v2b_objects_small_filter.cc scribo_io_text_boxes_save_SOURCES = scribo_io_text_boxes_save.cc +scribo_io_xml_internal_extended_page_xml_visitor_SOURCES = scribo_io_xml_internal_extended_page_xml_visitor.cc +scribo_io_xml_internal_full_xml_visitor_SOURCES = scribo_io_xml_internal_full_xml_visitor.cc +scribo_io_xml_internal_page_xml_visitor_SOURCES = scribo_io_xml_internal_page_xml_visitor.cc +scribo_io_xml_internal_print_box_coords_SOURCES = scribo_io_xml_internal_print_box_coords.cc +scribo_io_xml_internal_print_page_preambule_SOURCES = scribo_io_xml_internal_print_page_preambule.cc scribo_io_xml_save_SOURCES = scribo_io_xml_save.cc scribo_make_all_SOURCES = scribo_make_all.cc scribo_make_debug_filename_SOURCES = scribo_make_debug_filename.cc @@ -386,7 +410,6 @@ scribo_primitive_extract_all_SOURCES = scribo_primitive_extract_all.cc scribo_primitive_extract_canvas_SOURCES = scribo_primitive_extract_canvas.cc scribo_primitive_extract_cells_SOURCES = scribo_primitive_extract_cells.cc scribo_primitive_extract_components_SOURCES = scribo_primitive_extract_components.cc -scribo_primitive_extract_elements_SOURCES = scribo_primitive_extract_elements.cc scribo_primitive_extract_horizontal_separators_SOURCES = scribo_primitive_extract_horizontal_separators.cc scribo_primitive_extract_lines_discontinued_SOURCES = scribo_primitive_extract_lines_discontinued.cc scribo_primitive_extract_lines_h_discontinued_SOURCES = scribo_primitive_extract_lines_h_discontinued.cc @@ -401,6 +424,7 @@ scribo_primitive_extract_lines_v_pattern_SOURCES = scribo_primitive_extract_line scribo_primitive_extract_lines_v_single_SOURCES = scribo_primitive_extract_lines_v_single.cc scribo_primitive_extract_lines_v_thick_SOURCES = scribo_primitive_extract_lines_v_thick.cc scribo_primitive_extract_lines_v_thick_and_single_SOURCES = scribo_primitive_extract_lines_v_thick_and_single.cc +scribo_primitive_extract_non_text_SOURCES = scribo_primitive_extract_non_text.cc scribo_primitive_extract_separators_SOURCES = scribo_primitive_extract_separators.cc scribo_primitive_extract_separators_nonvisible_SOURCES = scribo_primitive_extract_separators_nonvisible.cc scribo_primitive_extract_vertical_separators_SOURCES = scribo_primitive_extract_vertical_separators.cc -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-785-g4d0483d scribo/primitive/extract/non_text.hh: Remove debug.
by Guillaume Lazzara
--- scribo/ChangeLog | 4 ++++ scribo/scribo/primitive/extract/non_text.hh | 21 --------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 1eb71a3..9914b73 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,9 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/primitive/extract/non_text.hh: Remove debug. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + Add new debug tools. * scribo/src/debug/Makefile.am: New targets. diff --git a/scribo/scribo/primitive/extract/non_text.hh b/scribo/scribo/primitive/extract/non_text.hh index a017f1f..8528782 100644 --- a/scribo/scribo/primitive/extract/non_text.hh +++ b/scribo/scribo/primitive/extract/non_text.hh @@ -58,10 +58,6 @@ # include <mln/clustering/kmean_rgb.hh> # include <mln/fun/v2v/rgb8_to_rgbn.hh> -# include <mln/util/timer.hh> - -# include <mln/io/pbm/save.hh> - namespace scribo { @@ -139,16 +135,9 @@ namespace scribo image2d<t_rgb5> img_rgb5 = mln::data::transform(doc.image(), t_rgb8_to_rgb5()); - // DEBUG - io::pbm::save(content, "text_area.pbm"); - - mln::util::timer t; - t.start(); img_lbl8 = mln::clustering::kmean_rgb<double,5>((img_rgb5 | pw::value(content)), 3, 10, 10).unmorph_(); data::fill((img_lbl8 | !pw::value(content)).rw(), 0u); - t.stop(); - std::cout << t << std::endl; mln::util::array<unsigned> card = mln::labeling::compute(accu::math::count<value::label_8>(), @@ -178,19 +167,9 @@ namespace scribo data::fill(elts, false); data::fill((elts | (pw::value(img_lbl8) != pw::cst(0))).rw(), true); - // DEBUG - data::fill((elts | (pw::value(doc.line_seps()) != pw::cst(0))).rw(), - false); - // END OF DEBUG - - scribo::def::lbl_type nlabels; elts = filter::components_small(elts, c8(), nlabels, 40); - // DEBUG - io::pbm::save(elts, "elements.pbm"); - // END OF DEBUG - output = primitive::extract::components(elts, c8(), nlabels); } -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-784-ga5f7281 Add new debug tools.
by Guillaume Lazzara
* scribo/src/debug/Makefile.am: New targets. * scribo/src/debug/show_separators.cc, * scribo/src/debug/show_stoppers.cc, * scribo/src/debug/show_text_lines.cc: New. --- scribo/ChangeLog | 10 ++ scribo/src/debug/Makefile.am | 12 ++- .../lines_pattern.cc => debug/show_separators.cc} | 74 +++++++++----- scribo/src/debug/show_stoppers.cc | 104 ++++++++++++++++++++ .../show_text_lines.cc} | 100 +++++++++++-------- 5 files changed, 225 insertions(+), 75 deletions(-) copy scribo/src/{primitive/extract/lines_pattern.cc => debug/show_separators.cc} (50%) create mode 100644 scribo/src/debug/show_stoppers.cc copy scribo/src/{text/pbm_lines_recognition.cc => debug/show_text_lines.cc} (52%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index c41b0bb..1eb71a3 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,15 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + Add new debug tools. + + * scribo/src/debug/Makefile.am: New targets. + + * scribo/src/debug/show_separators.cc, + * scribo/src/debug/show_stoppers.cc, + * scribo/src/debug/show_text_lines.cc: New. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/text/extract_lines.hh: Update code. 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/src/debug/Makefile.am b/scribo/src/debug/Makefile.am index d203f5c..cdb1f30 100644 --- a/scribo/src/debug/Makefile.am +++ b/scribo/src/debug/Makefile.am @@ -1,5 +1,5 @@ -# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -# (LRDE). +# Copyright (C) 2009, 2010, 2011 EPITA Research and Development +# Laboratory (LRDE). # # This file is part of Olena. # @@ -20,6 +20,7 @@ include $(top_srcdir)/scribo/scribo.mk noinst_PROGRAMS = \ show_info_x_height \ show_info_median_inter_characters \ + show_separators \ show_links_left_right_links_validation \ show_links_bbox_h_ratio \ show_links_bbox_overlap \ @@ -43,11 +44,14 @@ noinst_PROGRAMS = \ show_objects_large_small \ show_objects_small \ show_objects_thick \ - show_objects_thin + show_objects_thin \ + show_stoppers \ + show_text_lines show_info_x_height_SOURCES = show_info_x_height.cc show_info_median_inter_characters_SOURCES = show_info_median_inter_characters.cc +show_separators_SOURCES = show_separators.cc show_links_left_right_links_validation_SOURCES = show_links_left_right_links_validation.cc show_links_bbox_h_ratio_SOURCES = show_links_bbox_h_ratio.cc show_links_bbox_overlap_SOURCES = show_links_bbox_overlap.cc @@ -72,6 +76,8 @@ show_objects_large_small_SOURCES = show_objects_large_small.cc show_objects_small_SOURCES = show_objects_small.cc show_objects_thick_SOURCES = show_objects_thick.cc show_objects_thin_SOURCES = show_objects_thin.cc +show_stoppers_SOURCES = show_stoppers.cc +show_text_lines_SOURCES = show_text_lines.cc if HAVE_MAGICKXX diff --git a/scribo/src/primitive/extract/lines_pattern.cc b/scribo/src/debug/show_separators.cc similarity index 50% copy from scribo/src/primitive/extract/lines_pattern.cc copy to scribo/src/debug/show_separators.cc index cb56b36..ef80da6 100644 --- a/scribo/src/primitive/extract/lines_pattern.cc +++ b/scribo/src/debug/show_separators.cc @@ -1,5 +1,4 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -14,33 +13,25 @@ // // 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 <mln/core/image/image2d.hh> +#include <mln/core/alias/box2d.hh> +#include <mln/core/alias/neighb2d.hh> #include <mln/io/pbm/all.hh> -#include <mln/pw/all.hh> -#include <mln/data/fill.hh> -#include <mln/core/image/dmorph/image_if.hh> +#include <mln/arith/plus.hh> +#include <mln/labeling/foreground.hh> #include <scribo/primitive/extract/lines_h_pattern.hh> #include <scribo/primitive/extract/lines_v_pattern.hh> #include <scribo/debug/usage.hh> +#include <scribo/debug/save_bboxes_image.hh> const char *args_desc[][2] = { - { "input.pbm", "A binary image." }, - { "length", " Minimum line length. (Common value : 51)" }, + { "length", " Minimum line length. (default: 101)" }, { "delta", " Distance between the object pixel and the background pixel" - "(Common value : 4)" }, + "(default: 4)" }, {0, 0} }; @@ -49,10 +40,10 @@ int main(int argc, char *argv[]) { using namespace mln; - if (argc != 5) + if (argc != 7 && argc != 5) return scribo::debug::usage(argv, - "Extract horizontal lines patterns", - "input.pbm length delta output.pbm", + "Extract horizontal and vertical lines patterns", + "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta", args_desc); trace::entering("main"); @@ -60,19 +51,46 @@ int main(int argc, char *argv[]) image2d<bool> input; io::pbm::load(input, argv[1]); + // Set default option value + unsigned + length = 101, + delta = 4; + if (argc > 5) + { + length = atoi(argv[5]); + delta = atoi(argv[6]); + } + + util::timer t; + t.start(); + image2d<bool> - h_lines = scribo::primitive::extract::lines_h_pattern(input, - atoi(argv[2]), - atoi(argv[3])); + h_lines = scribo::primitive::extract::lines_h_pattern(input, length, delta); image2d<bool> - v_lines = scribo::primitive::extract::lines_v_pattern(input, - atoi(argv[2]), - atoi(argv[3])); + v_lines = scribo::primitive::extract::lines_v_pattern(input, length, delta); + + v_lines += h_lines; + + t.stop(); + std::cout << t << "s" << std::endl; + + // Save binary image. + io::pbm::save(v_lines, argv[2]); - data::fill((v_lines | pw::value(h_lines)).rw(), true); + // Save input without separators + { + image2d<bool> in_wo_seps = duplicate(input); + data::fill((in_wo_seps | pw::value(v_lines)).rw(), false); + io::pbm::save(in_wo_seps, argv[3]); + } - io::pbm::save(v_lines, argv[4]); + // Save bbox image + value::int_u8 nlabels; + image2d<value::int_u8> lbl = labeling::foreground(v_lines, c4(), nlabels); + mln::util::array<box2d> + bbox = labeling::compute(accu::shape::bbox<point2d>(), lbl, nlabels); + scribo::debug::save_bboxes_image(input, bbox, argv[4], literal::red); trace::exiting("main"); } diff --git a/scribo/src/debug/show_stoppers.cc b/scribo/src/debug/show_stoppers.cc new file mode 100644 index 0000000..a108da1 --- /dev/null +++ b/scribo/src/debug/show_stoppers.cc @@ -0,0 +1,104 @@ +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <
http://www.gnu.org/licenses/
>. + +#include <mln/core/image/image2d.hh> +#include <mln/core/alias/box2d.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/io/pbm/all.hh> +#include <mln/arith/plus.hh> +#include <mln/labeling/foreground.hh> + +#include <scribo/primitive/extract/lines_h_pattern.hh> +#include <scribo/primitive/extract/lines_v_pattern.hh> +#include <scribo/primitive/extract/separators_nonvisible.hh> +#include <scribo/debug/usage.hh> +#include <scribo/debug/save_bboxes_image.hh> + + +const char *args_desc[][2] = +{ + { "length", " Minimum line length. (default: 101)" }, + { "delta", " Distance between the object pixel and the background pixel" + "(default: 4)" }, + {0, 0} +}; + + +int main(int argc, char *argv[]) +{ + using namespace mln; + + if (argc != 7 && argc != 5) + return scribo::debug::usage(argv, + "Extract horizontal, vertical lines and stoppers", + "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta", + args_desc); + + trace::entering("main"); + + image2d<bool> input; + io::pbm::load(input, argv[1]); + + // Set default option value + unsigned + length = 101, + delta = 4; + if (argc > 5) + { + length = atoi(argv[5]); + delta = atoi(argv[6]); + } + + util::timer t; + + t.start(); + image2d<bool> + h_lines = scribo::primitive::extract::lines_h_pattern(input, length, delta); + + image2d<bool> + v_lines = scribo::primitive::extract::lines_v_pattern(input, length, delta); + + v_lines += h_lines; + + t.stop(); + + // Save input without separators + { + image2d<bool> in_wo_seps = duplicate(input); + data::fill((in_wo_seps | pw::value(v_lines)).rw(), false); + io::pbm::save(in_wo_seps, argv[3]); + } + + // Save bbox image + value::int_u8 nlabels; + image2d<value::int_u8> lbl = labeling::foreground(v_lines, c4(), nlabels); + mln::util::array<box2d> + bbox = labeling::compute(accu::shape::bbox<point2d>(), lbl, nlabels); + scribo::debug::save_bboxes_image(input, bbox, argv[4], literal::red); + + t.resume(); + + // Non visible separators + v_lines += scribo::primitive::extract::separators_nonvisible(input); + + t.stop(); + std::cout << t << "s" << std::endl; + + // Save binary image. + io::pbm::save(v_lines, argv[2]); + + trace::exiting("main"); +} diff --git a/scribo/src/text/pbm_lines_recognition.cc b/scribo/src/debug/show_text_lines.cc similarity index 52% copy from scribo/src/text/pbm_lines_recognition.cc copy to scribo/src/debug/show_text_lines.cc index 3451449..a031072 100644 --- a/scribo/src/text/pbm_lines_recognition.cc +++ b/scribo/src/debug/show_text_lines.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -23,15 +23,15 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - #include <iostream> #include <mln/core/image/image2d.hh> #include <mln/io/pbm/load.hh> #include <mln/value/int_u16.hh> +#include <mln/draw/box_plain.hh> +#include <mln/pw/all.hh> +#include <mln/core/image/dmorph/image_if.hh> +#include <mln/data/convert.hh> #include <scribo/text/recognition.hh> @@ -41,19 +41,15 @@ #include <scribo/core/object_links.hh> #include <scribo/core/object_groups.hh> -#include <scribo/text/merging.hh> -#include <scribo/primitive/extract/components.hh> -#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh> -#include <scribo/primitive/group/from_single_link.hh> +#include <scribo/text/extract_lines.hh> #include <scribo/io/text_boxes/save.hh> +#include <scribo/debug/save_bboxes_image.hh> + const char *args_desc[][2] = { - { "input.pbm", "A binary image. 'True' for objects, 'False'\ -for the background." }, - { "lang", "Must be set to \"eng\", \"fra\", \"deu\", \"spa\", \"ita\" (Default \"fra\")" }, {0, 0} }; @@ -64,10 +60,10 @@ int main(int argc, char* argv[]) using namespace scribo; using namespace mln; - if (argc != 2 && argc != 3 && argc != 4) + if (argc != 6) return scribo::debug::usage(argv, - "Text recognition", - "input.pbm [lang] [file]", + "Show text lines", + "input.pbm input_seps.pbm out.ppm out.pbm comps.pbm", args_desc); trace::entering("main"); @@ -75,37 +71,53 @@ int main(int argc, char* argv[]) image2d<bool> input; mln::io::pbm::load(input, argv[1]); - typedef image2d<value::int_u16> L; - value::int_u16 ncomps; - component_set<L> - comps = scribo::primitive::extract::components(input, c8(), ncomps); - std::cout << "ncomps = " << ncomps << std::endl; - - object_links<L> - links = scribo::primitive::link::with_single_left_link_dmax_ratio(comps, 2); - - object_groups<L> - groups = scribo::primitive::group::from_single_link(links); + image2d<bool> input_seps; + mln::io::pbm::load(input_seps, argv[2]); - line_set<L> lines(groups); - lines = text::merging(lines); + util::timer t; + t.start(); - std::string str = argv[2]; - const char *lang; - if (argc < 3 || (str != "eng" && str != "fra" - && str != "deu" && str != "spa" - && str != "ita")) - lang = "fra"; - else - lang = argv[2]; - - char *output = 0; - if (argc >= 4) - output = argv[3]; - - scribo::text::recognition(lines, lang); - - scribo::io::text_boxes::save(lines, output); + typedef image2d<value::int_u16> L; + line_set<L> lines = text::extract_lines(input, c8(), input_seps); + + t.stop(); + std::cout << t << "s" << std::endl; + + // Color image with line bboxes. + { + image2d<value::rgb8> output = data::convert(value::rgb8(), input); + for_all_lines(l, lines) + if (lines(l).is_textline()) + mln::draw::box(output, lines(l).bbox(), literal::red); + mln::io::ppm::save(output, argv[3]); + } + + // Binary image with line bboxes. + { + image2d<bool> output; + initialize(output, input); + data::fill(output, false); + for_all_lines(l, lines) + if (lines(l).is_textline()) + mln::draw::box_plain(output, lines(l).bbox(), true); + mln::io::pbm::save(output, argv[4]); + } + + { + image2d<bool> output; + initialize(output, input); + data::fill(output, false); + for_all_lines(l, lines) + if (lines(l).is_textline()) + { + const util::array<component_id_t>& comps = lines(l).components(); + const L& lbl = lines.components().labeled_image(); + for_all_elements(c, comps) + data::fill((output | lines.components()(comps(c)).bbox()).rw(), + ((input | lines.components()(comps(c)).bbox()) | (pw::value(lbl) == comps(c)))); + } + mln::io::pbm::save(output, argv[5]); + } trace::exiting("main"); } -- 1.5.6.5
13 years, 9 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200