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-763-g1cd8d75 src/text_in_picture.cc: Initialize ImageMagick and fix usage message.
by Guillaume Lazzara
--- scribo/ChangeLog | 5 +++++ scribo/src/text_in_picture.cc | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 4c39daf..f3f150f 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,8 @@ +2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + + * src/text_in_picture.cc: Initialize ImageMagick and fix usage + message. + 2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> * demo/viewer/xml_widget.cc: Fix data tracking of selected diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc index 042b8d3..e2f30de 100644 --- a/scribo/src/text_in_picture.cc +++ b/scribo/src/text_in_picture.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -176,7 +176,7 @@ int main(int argc, char* argv[]) if (argc < 3 || argc > 11) return scribo::debug::usage(argv, "Find text in a photo.\n\n" - "Common usage: ./text_in_photo_fast input.*" + "Common usage: ./text_in_picture input.*" " output.ppm 1 1 1 1 1", "input.ppm output.ppm <bg/fg enabled>" " <sauvola_ms enabled> " @@ -197,6 +197,8 @@ int main(int argc, char* argv[]) trace::entering("main"); + Magick::InitializeMagick(*argv); + image2d<value::rgb8> input_rgb; io::magick::load(input_rgb, argv[1]); -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-762-g47af3d9 demo/viewer/xml_widget.cc: Fix data tracking of selected objects.
by Guillaume Lazzara
--- scribo/ChangeLog | 5 ++ scribo/demo/viewer/xml_widget.cc | 117 ++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 03705c9..4c39daf 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,10 @@ 2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> + * demo/viewer/xml_widget.cc: Fix data tracking of selected + objects. + +2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> + Display baseline and meanline in Scribo viewer. * demo/viewer/common.hh: Add new enums. diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc index c45177b..1f2bc83 100644 --- a/scribo/demo/viewer/xml_widget.cc +++ b/scribo/demo/viewer/xml_widget.cc @@ -50,21 +50,14 @@ XmlWidget::select(QString id, QString name) { QDomNode n = node_map_[item_map_[id]]; - if (name.contains("Text line")) - { - n = n.firstChild(); - while (!n.isNull() && !n.toElement().tagName().contains("line")) - n = n.nextSibling(); - } - if (!n.isNull()) - { - QTreeWidgetItem* item = node_map_.key(n); + { + QTreeWidgetItem* item = node_map_.key(n); - tree_->setCurrentItem(item, 0); - item->setExpanded(true); - check_item(item); - } + tree_->setCurrentItem(item, 0); + item->setExpanded(true); + check_item(item); + } } void @@ -73,17 +66,17 @@ XmlWidget::check_item (QTreeWidgetItem* item) QDomNode node = node_map_[item]; if (node.hasAttributes()) + { + property_->clear(); + QDomNamedNodeMap attributes = node.toElement().attributes(); + + for (int i = 0; i < attributes.count(); ++i) { - property_->clear(); - QDomNamedNodeMap attributes = node.toElement().attributes(); - - for (int i = 0; i < attributes.count(); ++i) - { - QStringList values; - values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value(); - property_->addTopLevelItem(new QTreeWidgetItem(values)); - } + QStringList values; + values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value(); + property_->addTopLevelItem(new QTreeWidgetItem(values)); } + } property_->resizeColumnToContents(0); } @@ -91,42 +84,42 @@ XmlWidget::check_item (QTreeWidgetItem* item) void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item) { if (!node.isNull()) + { + QString append; + if (node.toElement().tagName().contains("point")) + { + QString x = node.toElement().attribute("x", "0"); + QString y = node.toElement().attribute("y", "0"); + append.append(" = (" + x + ", " + y + ")"); + } + + QTreeWidgetItem* child = + new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append)); + + if (node.hasAttributes()) + { + QString id = node.toElement().attribute("id", "none"); + item_map_[id] = child; + } + + node_map_[child] = node; + item->addChild(child); + + QDomNode sibling = node.firstChild(); + while (!sibling.isNull()) { - QString append; - if (node.toElement().tagName().contains("point")) - { - QString x = node.toElement().attribute("x", "0"); - QString y = node.toElement().attribute("y", "0"); - append.append(" = (" + x + ", " + y + ")"); - } - - QTreeWidgetItem* child = - new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append)); - - if (node.hasAttributes()) - { - QString id = node.toElement().attribute("id", "none"); - item_map_[id] = child; - } - - node_map_[child] = node; - item->addChild(child); - - QDomNode sibling = node.firstChild(); - while (!sibling.isNull()) - { - if (!sibling.toElement().tagName().contains("data")) - NFS(sibling, child); - else - { - QTreeWidgetItem* child_son = - new QTreeWidgetItem(QStringList("data = base64-encoded")); - - child->addChild(child_son); - } - sibling = sibling.nextSibling(); - } + if (!sibling.toElement().tagName().contains("data")) + NFS(sibling, child); + else + { + QTreeWidgetItem* child_son = + new QTreeWidgetItem(QStringList("data = base64-encoded")); + + child->addChild(child_son); + } + sibling = sibling.nextSibling(); } + } } void XmlWidget::fill_widget(QString xml) @@ -147,17 +140,17 @@ void XmlWidget::fill_widget(QString xml) QDomElement root = doc.documentElement(); QTreeWidgetItem* root_item= - new QTreeWidgetItem(QStringList(root.tagName())); + new QTreeWidgetItem(QStringList(root.tagName())); tree_->addTopLevelItem(root_item); root = root.firstChild().toElement(); while (!root.isNull()) - { - ++i; - NFS(root, root_item); - root = root.nextSibling().toElement(); - } + { + ++i; + NFS(root, root_item); + root = root.nextSibling().toElement(); + } } void -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-761-gd5019dd Display baseline and meanline in Scribo viewer.
by Guillaume Lazzara
* demo/viewer/common.hh: Add new enums. * demo/viewer/key_widget.cc, * demo/viewer/key_widget.hh: Revamp code and add support for more region types. * demo/viewer/viewer.cc, * demo/viewer/viewer.hh: Insert line blocks. --- scribo/ChangeLog | 13 ++++ scribo/demo/viewer/common.hh | 11 ++++ scribo/demo/viewer/key_widget.cc | 123 ++++++++++++++++++------------------- scribo/demo/viewer/key_widget.hh | 4 +- scribo/demo/viewer/viewer.cc | 106 +++++++++++++++++++++++++++++++- scribo/demo/viewer/viewer.hh | 1 + 6 files changed, 190 insertions(+), 68 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 52006a7..03705c9 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,16 @@ +2011-02-05 Guillaume Lazzara <z(a)lrde.epita.fr> + + Display baseline and meanline in Scribo viewer. + + * demo/viewer/common.hh: Add new enums. + + * demo/viewer/key_widget.cc, + * demo/viewer/key_widget.hh: Revamp code and add support for more + region types. + + * demo/viewer/viewer.cc, + * demo/viewer/viewer.hh: Insert line blocks. + 2011-02-04 Guillaume Lazzara <z(a)lrde.epita.fr> Add printing support in Scribo viewer. diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh index b2d8f7e..46f20c1 100644 --- a/scribo/demo/viewer/common.hh +++ b/scribo/demo/viewer/common.hh @@ -26,6 +26,9 @@ namespace region { Text = 0, Line, + + EndOfTextRegion, + Image, Noise, Separator, @@ -34,6 +37,14 @@ namespace region Graphic, Chart, Maths, + + EndOfMiscRegion, + + Baseline, + Meanline, + + EndOfTypoRegion, + RegionIdCount }; } diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc index 3a4b47b..cc10308 100644 --- a/scribo/demo/viewer/key_widget.cc +++ b/scribo/demo/viewer/key_widget.cc @@ -19,29 +19,31 @@ #include "common.hh" KeyWidget::KeyWidget(const region::KeyMap& key_map) - : items_(new QTreeWidget()), - text_(new QTreeWidgetItem(QStringList("Text"))), - regions_(new QTreeWidgetItem(QStringList("Regions"))) + : items_(new QTreeWidget()) { + item_list_.append(new QTreeWidgetItem(QStringList("Text"))); + item_list_.append(new QTreeWidgetItem(QStringList("Regions"))); + item_list_.append(new QTreeWidgetItem(QStringList("Typographical Lines"))); + QLabel* title = new QLabel(tr("Key")); title->setAlignment(Qt::AlignHCenter); - items_->addTopLevelItem(text_); - items_->addTopLevelItem(regions_); + foreach(QTreeWidgetItem* item, item_list_) + { + items_->addTopLevelItem(item); + item->setCheckState(0, Qt::Checked); + item->setExpanded(true); + } items_->setHeaderHidden(true); - text_->setCheckState(0, Qt::Checked); - text_->setExpanded(true); - - regions_->setCheckState(0, Qt::Checked); - regions_->setExpanded(true); + base_id_.append(0); + base_id_.append(region::EndOfTextRegion + 1); + base_id_.append(region::EndOfMiscRegion + 1); + base_id_.append(region::EndOfTypoRegion + 1); - for (int i = 0; i < 2; ++i) - add_item_(key_map.at(i).first, key_map.at(i).second, - i == region::Line, text_); - - for (int i = 2; i < key_map.size(); ++i) - add_item_(key_map.at(i).first, key_map.at(i).second, false, regions_); + for (int j = 0; j < base_id_.size() - 1; ++j) + for (int i = base_id_.at(j); i < base_id_.at(j + 1) - 1; ++i) + add_item_(key_map.at(i).first, key_map.at(i).second, false, item_list_.at(j)); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(title); @@ -55,11 +57,9 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map) void KeyWidget::update_all() { - for (int i = 0; i < text_->childCount(); ++i) - update(text_->child(i)); - - for (int i = 0; i < regions_->childCount(); ++i) - update(regions_->child(i)); + foreach(QTreeWidgetItem* item, item_list_) + for (int i = 0; i < item->childCount(); ++i) + update(item->child(i)); } void KeyWidget::setAll(bool b) @@ -70,8 +70,8 @@ void KeyWidget::setAll(bool b) else state = Qt::Unchecked; - text_->setCheckState(0, state); - regions_->setCheckState(0, state); + foreach(QTreeWidgetItem* item, item_list_) + item->setCheckState(0, state); } void KeyWidget::setAllCheck(QTreeWidgetItem* parent) @@ -89,20 +89,8 @@ void KeyWidget::setAllCheck(QTreeWidgetItem* parent) void KeyWidget::change_mode(bool b) { - int id_line = region::Line; - - if (b) - { - //text_->child(id_region)->setCheckState(0, Qt::Checked); - // text_->child(id_line)->setCheckState(0, Qt::Checked); - text_->child(id_line)->setHidden(false); - } - else - { - //text_->child(id_region)->setCheckState(0, Qt::Unchecked); - // text_->child(id_line)->setCheckState(0, Qt::Unchecked); - text_->child(id_line)->setHidden(true); - } + item_list_.at(0)->child(region::Line)->setHidden(!b); + // FIXME: we may like to hide also typographical objects. } void @@ -118,43 +106,52 @@ KeyWidget::add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent item->setHidden(b); } - bool +bool KeyWidget::isChecked(region::RegionId id) { - QTreeWidgetItem* item = text_->child(id); - if (item) - return item->checkState(0) == Qt::Checked; - else - { - item = regions_->child(id); - if(item) - return item->checkState(0) == Qt::Checked; - else - return false; - } + QTreeWidgetItem* current_item = 0; + + foreach(QTreeWidgetItem* item, item_list_) + { + current_item = item->child(id); + if (item) + break; + else + current_item = 0; + } + + if (!current_item) + return false; + + return current_item->checkState(0) == Qt::Checked; } void -KeyWidget::update(QTreeWidgetItem* item) +KeyWidget::update(QTreeWidgetItem* item_up) { int id = -1; - if (item == text_ || item == regions_) - { - setAllCheck(item); - } - else + + foreach(QTreeWidgetItem* item, item_list_) + if (item_up == item) + { + setAllCheck(item); + return; + } + + + int i = 0; + foreach(QTreeWidgetItem* item, item_list_) { - id = text_->indexOfChild(item); - if (id == -1) + id = item->indexOfChild(item_up); + if (id != -1) { - // +2 since image region id starts from 0 to the number of - // region type without considering categories. There are 2 - // elements in text category and the rest is in the region's - // one. - id = regions_->indexOfChild(item) + 2; + id += base_id_.at(i); + break; } - emit updated(id, item->checkState(0) == Qt::Checked); + ++i; } + + emit updated(id, item_up->checkState(0) == Qt::Checked); } KeyWidget::~KeyWidget() diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh index fd0b514..1a3518e 100644 --- a/scribo/demo/viewer/key_widget.hh +++ b/scribo/demo/viewer/key_widget.hh @@ -48,8 +48,8 @@ private: void add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent); QTreeWidget* items_; - QTreeWidgetItem* text_; - QTreeWidgetItem* regions_; + QVector<QTreeWidgetItem*> item_list_; + QVector<int> base_id_; }; #endif // ! SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc index 57a67c2..1d48b1a 100644 --- a/scribo/demo/viewer/viewer.cc +++ b/scribo/demo/viewer/viewer.cc @@ -65,6 +65,9 @@ Viewer::Viewer(int &argc, char** argv) key_map_[region::Chart] = qMakePair(tr("Chart"), QColor(0, 204, 255)); key_map_[region::Maths] = qMakePair(tr("Maths"), QColor(170, 0, 255)); + key_map_[region::Baseline] = qMakePair(tr("Baseline"), QColor(128, 0, 255)); + key_map_[region::Meanline] = qMakePair(tr("Meanline"), QColor(128, 0, 255)); + // Region ids region_ids_["text_region"] = region::Text; @@ -78,7 +81,6 @@ Viewer::Viewer(int &argc, char** argv) region_ids_["chart_region"] = region::Chart; region_ids_["maths_region"] = region::Maths; - win_->resize(1152, 864); win_->statusBar(); @@ -154,7 +156,7 @@ Viewer::Viewer(int &argc, char** argv) precise_action_ = create_action("Precise outline", view_menu, "1px outline relative to the image " "(1px relative to the view if off).", - "Ctrl+p"); + "Shift+Ctrl+p"); precise_action_->setCheckable(true); precise_action_->setChecked(false); connect(precise_action_, SIGNAL(toggled(bool)), @@ -432,6 +434,100 @@ Viewer::add_region(QDomNode father, QString attr_id) scene_->addItem(r); } + +void +Viewer::add_typo_lines(QDomNode father, QString attr_id) +{ + // Retrieve typographical information + int baseline = father.toElement().attribute("baseline").toInt(); + int meanline = father.toElement().attribute("meanline").toInt(); + + QRect bbox; + + // Looking for bbox coordinates. + { + QDomNode coords = father.firstChild(); + while (!coords.isNull() && !coords.toElement().tagName().contains("coords")) + coords = coords.nextSibling(); + + if (coords.isNull()) + return; + + + QDomNode point = coords.firstChild(); + QVector<QPoint> points; + + while (!point.isNull()) + { + int x = point.toElement().attribute("x", "0").toInt(); + int y = point.toElement().attribute("y", "0").toInt(); + + points << QPoint(x, y); + point = point.nextSibling(); + } + + QPolygon polygon(points); + bbox = polygon.boundingRect(); + } + + // Creating blocks + + // Baseline + { + QVector<QPoint> points; + points.append(QPoint(bbox.topLeft().x(), baseline)); + points.append(QPoint(bbox.topRight().x(), baseline)); + + ImageRegion* r = new ImageRegion(region::Baseline, + key_map_[region::Baseline].first, + key_map_[region::Baseline].second, + attr_id, points, + outline_action_->isChecked(), + fill_action_->isChecked(), + precise_action_->isChecked(), + key_wgt_->isChecked(region::Baseline)); + + connect(this, SIGNAL(key_updated(int, bool)), + r, SLOT(setDrawIfSameId(int, bool))); + connect(this, SIGNAL(setOutline(bool)), + r, SLOT(setOutline(bool))); + connect(this, SIGNAL(setPrecise(bool)), + r, SLOT(setPrecise(bool))); + connect(this, SIGNAL(setFill(bool)), + r, SLOT(setFill(bool))); + + scene_->addItem(r); + } + + // Meanline + { + QVector<QPoint> points; + points.append(QPoint(bbox.topLeft().x(), meanline)); + points.append(QPoint(bbox.topRight().x(), meanline)); + + ImageRegion* r = new ImageRegion(region::Meanline, + key_map_[region::Meanline].first, + key_map_[region::Meanline].second, + attr_id, points, + outline_action_->isChecked(), + fill_action_->isChecked(), + precise_action_->isChecked(), + key_wgt_->isChecked(region::Meanline)); + + connect(this, SIGNAL(key_updated(int, bool)), + r, SLOT(setDrawIfSameId(int, bool))); + connect(this, SIGNAL(setOutline(bool)), + r, SLOT(setOutline(bool))); + connect(this, SIGNAL(setPrecise(bool)), + r, SLOT(setPrecise(bool))); + connect(this, SIGNAL(setFill(bool)), + r, SLOT(setFill(bool))); + + scene_->addItem(r); + } +} + + void Viewer::load_xml(QString filename) { @@ -557,7 +653,11 @@ Viewer::load_xml(QString filename) if (!line.isNull()) { if (extended_mode_) - add_region(line, attr_id); + { + QString line_id = line.toElement().attribute("id", "none"); + add_region(line, line_id); + add_typo_lines(line, line_id); + } add_text(line); } } diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh index c4b99e8..c68dd02 100644 --- a/scribo/demo/viewer/viewer.hh +++ b/scribo/demo/viewer/viewer.hh @@ -84,6 +84,7 @@ private: QPixmap load_base64(QString xml); void add_region(QDomNode father, QString attr_id); void add_text(QDomNode line); + void add_typo_lines(QDomNode father, QString attr_id); QAction *create_action(QString name, QMenu* menu, QString status, QString shortcut); void reset_progress_dialog(); void configure_printer(QPrinter& printer); -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-760-gc96edd6 Add printing support in Scribo viewer.
by Guillaume Lazzara
* demo/viewer/image_scene.cc, * demo/viewer/image_scene.hh: Accept a parent widget. * demo/viewer/image_widget.cc, * demo/viewer/image_widget.hh: Add an accessor to the underlying view. * demo/viewer/viewer.cc, * demo/viewer/viewer.hh: Add print and print preview menu entries --- scribo/ChangeLog | 14 +++++ scribo/demo/viewer/image_scene.cc | 7 ++- scribo/demo/viewer/image_scene.hh | 2 +- scribo/demo/viewer/image_widget.cc | 15 +++++- scribo/demo/viewer/image_widget.hh | 6 ++- scribo/demo/viewer/viewer.cc | 95 ++++++++++++++++++++++++++++++++++-- scribo/demo/viewer/viewer.hh | 9 +++- 7 files changed, 135 insertions(+), 13 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 620dcfb..52006a7 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,17 @@ +2011-02-04 Guillaume Lazzara <z(a)lrde.epita.fr> + + Add printing support in Scribo viewer. + + * demo/viewer/image_scene.cc, + * demo/viewer/image_scene.hh: Accept a parent widget. + + * demo/viewer/image_widget.cc, + * demo/viewer/image_widget.hh: Add an accessor to the underlying + view. + + * demo/viewer/viewer.cc, + * demo/viewer/viewer.hh: Add print and print preview menu entries. + 2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> Improve about dialog in scribo viewer. diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc index 2c56113..a800896 100644 --- a/scribo/demo/viewer/image_scene.cc +++ b/scribo/demo/viewer/image_scene.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,8 +19,8 @@ #include "image_scene.hh" #include "image_region.hh" -ImageScene::ImageScene() - : selected_(0) +ImageScene::ImageScene(QObject *parent) + : QGraphicsScene(parent), selected_(0) { } diff --git a/scribo/demo/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh index 136f1a2..b141478 100644 --- a/scribo/demo/viewer/image_scene.hh +++ b/scribo/demo/viewer/image_scene.hh @@ -27,7 +27,7 @@ class ImageScene Q_OBJECT public: - ImageScene(); + ImageScene(QObject *parent = 0); ~ImageScene(); void mousePressEvent(QGraphicsSceneMouseEvent* event); diff --git a/scribo/demo/viewer/image_widget.cc b/scribo/demo/viewer/image_widget.cc index e9e5e79..f86ff1d 100644 --- a/scribo/demo/viewer/image_widget.cc +++ b/scribo/demo/viewer/image_widget.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -20,6 +21,8 @@ ImageWidget::ImageWidget(QGraphicsScene* scene) : view_ (new ImageView(scene)) { + scene->setParent(view_); + QLabel* title = new QLabel(tr("Layout")); title->setAlignment(Qt::AlignHCenter); @@ -38,6 +41,12 @@ ImageWidget::ImageWidget(QGraphicsScene* scene) setLayout(layout); } + +ImageWidget::~ImageWidget() +{ +} + + void ImageWidget::update() { @@ -45,6 +54,8 @@ ImageWidget::update() view_->scaleUpdate(); } -ImageWidget::~ImageWidget() +ImageView * +ImageWidget::view() const { + return view_; } diff --git a/scribo/demo/viewer/image_widget.hh b/scribo/demo/viewer/image_widget.hh index 826b873..79dd672 100644 --- a/scribo/demo/viewer/image_widget.hh +++ b/scribo/demo/viewer/image_widget.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,6 +19,7 @@ # define SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH # include <QtGui> +# include "image_view.hh" class ImageView; @@ -30,6 +32,8 @@ public: ImageWidget(QGraphicsScene* scene); ~ImageWidget(); + ImageView * view() const; + public slots: void update(); diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc index 46172ce..57a67c2 100644 --- a/scribo/demo/viewer/viewer.cc +++ b/scribo/demo/viewer/viewer.cc @@ -22,10 +22,10 @@ #include "viewer.hh" #include "key_widget.hh" #include "browser_widget.hh" -#include "image_widget.hh" #include "xml_widget.hh" #include "step_widget.hh" #include "image_scene.hh" +#include "image_view.hh" #include "image_region.hh" #include "help_dialog.hh" #include "preferences_dialog.hh" @@ -107,6 +107,23 @@ Viewer::Viewer(int &argc, char** argv) file_menu->addSeparator(); + QAction *preview_print_action = create_action("Printing preview", file_menu, + "Printint preview", "Ctrl+P"); + connect(preview_print_action, SIGNAL(triggered()), + this, SLOT(preview_print())); + file_menu->addAction(preview_print_action); + preview_print_action->setEnabled(false); + + + QAction *print_action = create_action("Print", file_menu, + "Print", "Ctrl+P"); + connect(print_action, SIGNAL(triggered()), + this, SLOT(print())); + file_menu->addAction(print_action); + print_action->setEnabled(false); + + file_menu->addSeparator(); + QAction* quit_action = create_action("Quit", file_menu, "Exit the program.", "Ctrl+q"); @@ -220,10 +237,14 @@ Viewer::Viewer(int &argc, char** argv) step_widget_ = new StepWidget(); XmlWidget* xml_wgt = new XmlWidget(); browser_wgt_ = new BrowserWidget(files_, argc != 2 ? QString() : argv[1]); - ImageWidget* image_wgt = new ImageWidget(scene_); + image_wgt_ = new ImageWidget(scene_); connect(step_widget_, SIGNAL(step_selected(bool)), export_action_, SLOT(setEnabled(bool))); + connect(step_widget_, SIGNAL(step_selected(bool)), + print_action, SLOT(setEnabled(bool))); + connect(step_widget_, SIGNAL(step_selected(bool)), + preview_print_action, SLOT(setEnabled(bool))); scene_->setBackgroundBrush(scene_->palette().window()); @@ -231,7 +252,7 @@ Viewer::Viewer(int &argc, char** argv) v_splitter->addWidget(key_wgt_); v_splitter->addWidget(browser_wgt_); - v_splitter2->addWidget(image_wgt); + v_splitter2->addWidget(image_wgt_); v_splitter2->addWidget(xml_wgt); h_splitter->addWidget(v_splitter); @@ -264,7 +285,7 @@ Viewer::Viewer(int &argc, char** argv) connect(this, SIGNAL(mode_changed(bool)), key_wgt_, SLOT(change_mode(bool))); connect(this, SIGNAL(updated()), - image_wgt, SLOT(update())); + image_wgt_, SLOT(update())); connect(this, SIGNAL(fill_xml(QString)), xml_wgt, SLOT(fill_widget(QString))); @@ -276,7 +297,7 @@ Viewer::Viewer(int &argc, char** argv) connect(scene_, SIGNAL(deselected()), xml_wgt, SLOT(deselect())); - connect(image_wgt, SIGNAL(scaleUpdated(qreal)), + connect(image_wgt_, SIGNAL(scaleUpdated(qreal)), this, SLOT(maybeChangeCacheMode(qreal))); @@ -808,3 +829,67 @@ Viewer::reset_progress_dialog() pdialog_.setLabelText(""); pdialog_.show(); } + + +void +Viewer::print() +{ + QPrinter printer(QPrinter::HighResolution); + configure_printer(printer); + + QPrintDialog dialog(&printer); + dialog.setWindowTitle(tr("Print Document")); + if (dialog.exec() != QDialog::Accepted) + return; + + do_print(&printer); +} + +void +Viewer::preview_print() +{ + QPrinter printer(QPrinter::HighResolution); + configure_printer(printer); + + QPrintPreviewDialog preview(&printer); + connect(&preview, SIGNAL(paintRequested(QPrinter *)), + this, SLOT(do_print(QPrinter *))); + + preview.exec(); +} + +void Viewer::do_print(QPrinter * printer) +{ + QList<QGraphicsItem *> items = image_wgt_->view()->items(); + + QPainter painter(printer); + + QGraphicsItem *item; + QStyleOptionGraphicsItem options; + + // Painting backward objects first. + for (int i = items.size() - 1; i >= 0; --i) + { + item = items.at(i); + + if (item != image_) + { + QRect vport = image_->mapRectFromItem(item, + item->boundingRect()).toRect(); + + painter.translate(std::abs(item->boundingRect().x() - vport.x()), + std::abs(item->boundingRect().y() - vport.y())); + } + + + item->paint(&painter, &options); + painter.resetTransform(); + } +} + +void +Viewer::configure_printer(QPrinter& printer) +{ + printer.setPageSize(QPrinter::A4); + printer.setResolution(300); +} diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh index 3aefaf6..c4b99e8 100644 --- a/scribo/demo/viewer/viewer.hh +++ b/scribo/demo/viewer/viewer.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -21,6 +22,7 @@ # include <QDomNode> # include "common.hh" # include "runner.hh" +# include "image_widget.hh" class ImageScene; class DomModel; @@ -61,6 +63,9 @@ private slots: void run_progress(); void on_xml_saved(const QString& filename); void export_as(); + void print(); + void preview_print(); + void do_print(QPrinter * printer); signals: void updated(); @@ -81,6 +86,7 @@ private: void add_text(QDomNode line); QAction *create_action(QString name, QMenu* menu, QString status, QString shortcut); void reset_progress_dialog(); + void configure_printer(QPrinter& printer); QApplication* app_; QMainWindow* win_; @@ -90,6 +96,7 @@ private: QGraphicsPixmapItem* image_; ImageScene* scene_; + ImageWidget* image_wgt_; QDirModel* files_; DomModel* doc_layout_; -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-759-g79b3aaa Improve about dialog in scribo viewer.
by Guillaume Lazzara
* demo/shared/icons/olena_smaller.jpg: New. * demo/shared/shared.qrc: Add new image in resources. * demo/viewer/Makefile.am: Build qrc file. * demo/viewer/help_dialog.cc, * demo/viewer/help_dialog.hh: Make use of the new dialog. * demo/viewer/help_dialog.ui: New. * demo/viewer/viewer.qrc: New. --- scribo/ChangeLog | 17 ++++ scribo/demo/shared/icons/olena_smaller.jpg | Bin 0 -> 8028 bytes scribo/demo/shared/shared.qrc | 3 +- scribo/demo/viewer/Makefile.am | 6 +- scribo/demo/viewer/help_dialog.cc | 43 +-------- scribo/demo/viewer/help_dialog.hh | 11 +-- scribo/demo/viewer/help_dialog.ui | 138 ++++++++++++++++++++++++++++ scribo/demo/viewer/viewer.qrc | 5 + 8 files changed, 173 insertions(+), 50 deletions(-) create mode 100644 scribo/demo/shared/icons/olena_smaller.jpg create mode 100644 scribo/demo/viewer/help_dialog.ui create mode 100644 scribo/demo/viewer/viewer.qrc diff --git a/scribo/ChangeLog b/scribo/ChangeLog index be2e395..620dcfb 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,22 @@ 2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + Improve about dialog in scribo viewer. + + * demo/shared/icons/olena_smaller.jpg: New. + + * demo/shared/shared.qrc: Add new image in resources. + + * demo/viewer/Makefile.am: Build qrc file. + + * demo/viewer/help_dialog.cc, + * demo/viewer/help_dialog.hh: Make use of the new dialog. + + * demo/viewer/help_dialog.ui: New. + + * demo/viewer/viewer.qrc: New. + +2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + * demo/viewer/runner.cc: Clear arguments on new process. 2011-01-28 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/demo/shared/icons/olena_smaller.jpg b/scribo/demo/shared/icons/olena_smaller.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c6b9110b047424a3ff83f2dcfce93ae2d2a172d9 GIT binary patch literal 8028 zcmbW41y~hZ*MR3V-QC?G2uP=tfTVOE4&B`#A}B2)5()?i(gM;*NQZzl5>g6CNK5k{ z?){#7@Ap5?pX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0 HcmV?d00001 diff --git a/scribo/demo/shared/shared.qrc b/scribo/demo/shared/shared.qrc index 051c986..3e1fd85 100644 --- a/scribo/demo/shared/shared.qrc +++ b/scribo/demo/shared/shared.qrc @@ -1,5 +1,6 @@ <RCC> - <qresource prefix="icons" > + <qresource prefix="icons"> + <file>icons/olena_smaller.jpg</file> <file>icons/close.gif</file> <file>icons/image-next-icon.png</file> <file>icons/page-down-icon.png</file> diff --git a/scribo/demo/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am index fa143c9..2c5e4cf 100644 --- a/scribo/demo/viewer/Makefile.am +++ b/scribo/demo/viewer/Makefile.am @@ -63,7 +63,7 @@ BUILT_SOURCES = viewer.moc.cc \ image_scene.moc.cc \ image_view.moc.cc \ image_region.moc.cc \ - help_dialog.moc.cc \ + help_dialog.ui.h \ step_widget.moc.cc \ toolchain_options.moc.cc \ toolchain_options.ui.h \ @@ -74,7 +74,8 @@ BUILT_SOURCES = viewer.moc.cc \ preferences_dialog.ui.h \ general_options.moc.cc \ general_options.ui.h \ - demodir.hh + demodir.hh \ + viewer.qrc.cc noinst_HEADERS = viewer.hh \ @@ -121,5 +122,6 @@ EXTRA_DIST = \ preferences_dialog.ui \ README \ toolchain_options.ui \ + help_dialog.ui \ demodir.hh.in diff --git a/scribo/demo/viewer/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc index 1f4a775..2d5ce6c 100644 --- a/scribo/demo/viewer/help_dialog.cc +++ b/scribo/demo/viewer/help_dialog.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,43 +19,5 @@ HelpDialog::HelpDialog() { - QPushButton *closeButton = new QPushButton(tr("Close")); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); - - QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(closeButton); - - QVBoxLayout *mainLayout = new QVBoxLayout; - - QString help = tr( - "Document layout viewer:\n" - "\n" - "Usage:\n" - " - Choose an image file in the file browser,\n" - "if XML file(s) whose prefix name is the same as\n" - "the image name (i.e.image _name(_ .*)?.xml) is present\n" - "then you can choose the one you want in the step\n" - "chooser to display it on the scene.\n" - "- To load a base 64 encoded XML file,\n" - "its extension has to be .xmlc otherwise \n" - "the program won't recognize it !\n" - " - Select regions to display their properties.\n" - " - Use the mouse or keyboard to move and zoom\n" - " (Arrows, PageUp, PageDown, Home, End).\n" - "\n"); - - - QLabel* label = new QLabel(help); - - mainLayout->addWidget(label); - mainLayout->addLayout(buttonsLayout); - - setLayout(mainLayout); - setWindowTitle(tr("About")); -} - -void HelpDialog::done() -{ - emit close(); + setupUi(this); } diff --git a/scribo/demo/viewer/help_dialog.hh b/scribo/demo/viewer/help_dialog.hh index 41be95d..9f179c6 100644 --- a/scribo/demo/viewer/help_dialog.hh +++ b/scribo/demo/viewer/help_dialog.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -18,17 +19,13 @@ # define SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH # include <QtGui> +# include <help_dialog.ui.h> -class HelpDialog - : public QDialog +class HelpDialog : public QDialog, private Ui::HelpDialog { - Q_OBJECT - public: HelpDialog(); -public slots: - void done(); }; #endif // ! SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH diff --git a/scribo/demo/viewer/help_dialog.ui b/scribo/demo/viewer/help_dialog.ui new file mode 100644 index 0000000..9ab7e58 --- /dev/null +++ b/scribo/demo/viewer/help_dialog.ui @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>HelpDialog</class> + <widget class="QDialog" name="HelpDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>557</width> + <height>390</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>557</width> + <height>390</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>557</width> + <height>390</height> + </size> + </property> + <property name="windowTitle"> + <string>About</string> + </property> + <property name="windowIcon"> + <iconset resource="viewer.qrc"> + <normaloff>:/icons/shared/icons/olena_smaller.jpg</normaloff>:/icons/shared/icons/olena_smaller.jpg</iconset> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="viewer.qrc">:/icons/shared/icons/olena_smaller.jpg</pixmap> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Document Image Analysis Tool</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This project is powered by <span style=" font-weight:600; font-style:italic;">Milena</span>, a generic image processing library.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">It is part of <span style=" font-weight:600; font-style:italic;">Olena</span>, an Image Processing Platform and its module <span style=" font-weight:600; font-style:italic;">Scribo</span>, a set of tools for Document Image Analysis.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://olena.lrde.epita.fr"><span style=" text-decoration: underline; color:#0057ae;">http://olena.lrde.epita.fr</span></a></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Thanks to Arthur Crépin-Leblond, Samuel Da Mota, Loic Denuziere, </span><span style=" font-size:8pt;">Jérôme Galtier,</span><span style=" font-size:8pt;"> </span><span style=" font-size:8pt;">Florent d'Halluin, </span><span style=" font-size:8pt;">Alex Hamelin, </span><span style=" font-size:8pt;">Damien Lefortier, </span><span style=" font-size:8pt;">Vincent Ordy, </span><span style=" font-size:8pt;">Guillaume Sadegh and</span><span style=" font-size:8pt;"> </span><span style=" font-size:8pt;">Warren Seine </span><span style=" font-size:8pt;">for their contribution.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p align="justify" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt;">This application has been developed in the context of the SCRIBO project of the Free Software Thematic Group, part of the &quot;System@tic Paris-Région&quot; Cluster (France). This project is partially funded by the French Government, its economic development agencies, and by the Paris-Région institutions.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:7pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt;">Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE)</span></p></body></html></string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Ok</set> + </property> + <property name="centerButtons"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="viewer.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>HelpDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>281</x> + <y>391</y> + </hint> + <hint type="destinationlabel"> + <x>240</x> + <y>203</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/scribo/demo/viewer/viewer.qrc b/scribo/demo/viewer/viewer.qrc new file mode 100644 index 0000000..361b332 --- /dev/null +++ b/scribo/demo/viewer/viewer.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="icons"> + <file>../shared/icons/olena_smaller.jpg</file> + </qresource> +</RCC> -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-758-g11325f7 demo/viewer/runner.cc: Clear arguments on new process.
by Guillaume Lazzara
--- scribo/ChangeLog | 4 ++++ scribo/demo/viewer/runner.cc | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index b19115d..be2e395 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,7 @@ +2011-02-18 Guillaume Lazzara <z(a)lrde.epita.fr> + + * demo/viewer/runner.cc: Clear arguments on new process. + 2011-01-28 Guillaume Lazzara <z(a)lrde.epita.fr> * tests/unit_test/unit-tests.mk: Regen. diff --git a/scribo/demo/viewer/runner.cc b/scribo/demo/viewer/runner.cc index 085ef39..86ff5dc 100644 --- a/scribo/demo/viewer/runner.cc +++ b/scribo/demo/viewer/runner.cc @@ -94,6 +94,7 @@ void runner::stop() void runner::start_demat(const QString& filename) { + args_.clear(); args_ << filename; mode_ = Demat; @@ -191,6 +192,7 @@ void runner::process(const image2d<value::rgb8>& original_ima, void runner::start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile) { + args_.clear(); args_ << imgfile << xmlfile << outfile; mode_ = Export; -- 1.5.6.5
13 years, 9 months
1
0
0
0
branch next-build-test updated: last-svn-commit-817-gdb74571
by lazzara@lrde.epita.fr
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Olena, a generic and efficient image processing platform". The branch next-build-test has been updated via db7457153f9ac3811483be20a4d8981e31443785 (commit) via 4e7a87b8c9aa19b264a9eaae5fd4eacd7ff7b947 (commit) via 76d581414104c04a8954b083b24cf9caf58154e7 (commit) via 1e74eb51d3243487f13ea104079737c53ac0361b (commit) via 2d12896ac7a0e42de83bed33c3dde02bbae4b6e5 (commit) via 6adf703bc7b05f9ff00719b7cbbc845a234d3f9d (commit) via b71d6973bdcfda3c47cc9a4211339555a6cf0a27 (commit) via 2f870e06bc47707e86500bfb905e013545d81ee0 (commit) via 4b5b9f8ea9ff23a59ee7bdca6297a57b5b16bdc1 (commit) via 3f14376ad38b8967e5af7d63ddac93989f58ac39 (commit) via 8ee4c1acd45d4bd6c1a8805fe41de65c1153ba17 (commit) via 8aaa787401d5d6681ab824550216d5abee24c324 (commit) via 3038605191b650a8a86d10ffb986d165bca13f31 (commit) via eae112f79b28e0e6f217b6cfe130a4a1dc1ca0c4 (commit) via 294c4219261707af15a0d5593ddefd6f86851c44 (commit) via 80b10b678600c73da186ebe4662652096c98673b (commit) via 1a5cc61c52a905239876107d1ac2143a62e23968 (commit) via 500be97a841a57b0cf6f580d6573a6ef1f941803 (commit) via 3f06d28a852c01e7f49ec0320a2cdf254ad11ec4 (commit) via 07b076ce0ba19ac3741350db76a881252cab9313 (commit) via d045991c53396fcbf462e8824b9bd68657c3824b (commit) via 9721b83ee36739262562acd9a53019351e476044 (commit) via 2cd9b0158f329056d6baf732c8c94da4a58f9477 (commit) via 00e84b1ea30ed7f4d9adb3e46576f0da37d4701b (commit) via 7a467ce53641d6df7084ad28c230b59e741b3158 (commit) via c4bfbf3039ad1bc22e9d6a84898e1aa30204b165 (commit) via 88a5659a616bb9a61144ce29447da7c78afd1d16 (commit) via 55dec68d501bf9aea0237bc734f8e34a2c2b8659 (commit) via 525a77d49f93c4d8af8f0f98311a59fa91ad37f5 (commit) via be7296a994a74454aed04e9ac5697b1ebf7f1239 (commit) via 3e799ae9a6155fe25743f551e029b8f407ba5f87 (commit) via c6aef9e87ecd21dc02545f3ff234dfa37c49ef0e (commit) via 71e09952f8956d7969923783e4d11785ed69ac70 (commit) via f4cad33327251f4d0d7c9f03ba309b0472671685 (commit) via 38639f48cf630d9773a72825adf3e1c2bd33d699 (commit) via 08507d9f6ee6460473604cd94e1cc094ca4dcb6f (commit) via 300d0d76ad8aba7dbf1f793b8bfbbc32b80016a8 (commit) via b37a853c16b36dc73376fbc32562772a0a1778eb (commit) via 5127a7b422860a30f96a86f71f5bb1e6961894fa (commit) via b1fe7b822ef9667e06e4a61465cca47a19c728d8 (commit) via 67e03b2fa427dbcea04133c7c62ed6b9e3b40770 (commit) via 37420bc1bc21b94431344d5ed978f6b537333816 (commit) via 9fc92d2022701f48b1471d7899df48eefe5c3281 (commit) via 36bdfe6bd32b4e4fc6f5e4ca6443de39ea7ed1d5 (commit) via 09b76a65da9f752c14797fe845b5d9f3c2e9e193 (commit) via 9ce4470df6ec50f7c5776cc78c9ef8b804579b27 (commit) via cff396c972728565d654eab1ff4258ef18fa51c6 (commit) via b9a628915f1d9728cacca0049eccb7272427164d (commit) via 7bdf8a260b084ca369db30a705dd5c3e8a1ecec3 (commit) via 26501abd4604deb0a0670c6b8bf3a212145477b3 (commit) via c027c16fdbc3ffe8b1623764a56bd9cfad77a8bc (commit) via e05c9c33f0bf1a7a3b2499f872f2a4167ceba41f (commit) via a192077679cb7736a2dc6f096bac377b0f4453ba (commit) via 209645b7fdd312ecf6b9f6e37281e6b1122792b5 (commit) via 1cd8d75d23d5d2a54b1847d7ea6bae714b39b37f (commit) via 47af3d9cb24e89d843ca9648f55db11b575b4bc7 (commit) via d5019dd2432f7e82eb2ac079a3ab14576b8badb8 (commit) via c96edd6fb6f8e3ab339b1b565941007a5da9a4c7 (commit) via 79b3aaa9765b6a9f86d71ddf55d3556d4f922cfd (commit) via 11325f7f2dd2278993de4dd4a11e9a136617a398 (commit) from c4bfdc8ca94fc3283920876a447bf21b1efaf9bb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- db74571 Regen generated files. 4e7a87b mln/labeling/colorize.hh: Add a missing inline. 76d5814 Add more from_to overloards. 1e74eb5 build-aux/build_unit_test.sh: Define HAVE_* for unit-tests. 2d12896 Regen generated files. 6adf703 tests/toolchain/nepomuk/Makefile.am: Add MAGICKXX flags. b71d697 scribo/core/def/lbl_type.hh: Use int_u<n> as label type. 2f870e0 Set unit tests dependencies. 4b5b9f8 New debug tools. 3f14376 New non-text components extraction routine. 8ee4c1a Introduce result image output. 8aaa787 Save image edge coordinates in XML output. 3038605 scribo/filter/object_links_aligned.hh: New. eae112f scribo/primitive/extract/separators_nonvisible.hh: Cleanup and improve debug support. 294c421 Various small fixes. 80b10b6 Introduce a new component linking method. 1a5cc61 Spread anchor value to more methods in link functors. 500be97 Introduce a logger class. 3f06d28 Introduce a logger class. 07b076c Introduce new anchors. d045991 Rename document serializer base class. 9721b83 Store more information in scribo::document. 2cd9b01 Rename line_info::components() to line_info::component_ids. 00e84b1 Some changes in debug routines. 7a467ce Add HAVE_QT guards. c4bfbf3 Small fixes in viewer. 88a5659 scribo/io/xml/internal/extended_page_xml_visitor.hh: Save separators data. 55dec68 scribo/io/xml/internal/full_xml_visitor.hh: Do not copy image data. 525a77d Make OCR step optional in viewer. be7296a scribo/toolchain/internal/content_in_doc_functor.hh: Make OCR step optional. 3e799ae Compress image data in XML output. c6aef9e Small fixes in Scribo. 71e0995 Regen mk files. f4cad33 scribo/primitive/extract/non_text.hh: Remove debug. 38639f4 Add new debug tools. 08507d9 scribo/text/extract_lines.hh: Update code. 300d0d7 Make use of mln::fun::v2v::rgb_to_luma. b37a853 mln/labeling/fill_holes.hh: Improve speed. 5127a7b mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion. b1fe7b8 scribo/io/xml/load.hh: New XML loader. 67e03b2 Make XML output more flexible. 37420bc Set component type during component extraction. 9fc92d2 configure.ac: scribo/src/primitive/remove. 36bdfe6 Add new tools in Scribo. 09b76a6 Small fixes in Scribo. 9ce4470 Improve and cleanup whitespace separator detection. cff396c Add new conversion routines from string to tag. b9a6289 Various changes in scribo core structures. 7bdf8a2 Rename files in Scribo. 26501ab mln/util/array.hh: Add last() method. c027c16 Add an optional base index for debug::iota. e05c9c3 configure.ac: configure scribo/tests/convert. a192077 Add Base64 conversion routines. 209645b =Add support for whitespace separators visualization. 1cd8d75 src/text_in_picture.cc: Initialize ImageMagick and fix usage message. 47af3d9 demo/viewer/xml_widget.cc: Fix data tracking of selected objects. d5019dd Display baseline and meanline in Scribo viewer. c96edd6 Add printing support in Scribo viewer. 79b3aaa Improve about dialog in scribo viewer. 11325f7 demo/viewer/runner.cc: Clear arguments on new process. ----------------------------------------------------------------------- Summary of changes: ChangeLog | 12 + build-aux/build_unit_test.sh | 2 +- configure.ac | 2 + milena/ChangeLog | 38 + milena/headers.mk | 2 + milena/mln/convert/impl/from_unsigned_to_value.hh | 26 +- milena/mln/debug/iota.hh | 22 +- milena/mln/debug/iota.spe.hh | 9 +- milena/mln/fun/v2v/rgb_to_luma.hh | 72 ++ milena/mln/labeling/colorize.hh | 3 +- milena/mln/labeling/fill_holes.hh | 17 +- milena/mln/util/array.hh | 25 +- milena/mln/value/label.hh | 20 +- milena/tests/unit_test/unit-tests.mk | 30 +- scribo/ChangeLog | 616 +++++++++++++++ scribo/demo/shared/icons/olena_smaller.jpg | Bin 0 -> 8028 bytes scribo/demo/shared/shared.qrc | 3 +- scribo/demo/viewer/Makefile.am | 26 +- scribo/demo/viewer/common.hh | 33 +- scribo/demo/viewer/config.cc | 28 +- scribo/demo/viewer/config.hh | 11 +- scribo/demo/viewer/help_dialog.cc | 43 +- scribo/demo/viewer/help_dialog.hh | 11 +- scribo/demo/viewer/help_dialog.ui | 138 ++++ scribo/demo/viewer/image_scene.cc | 7 +- scribo/demo/viewer/image_scene.hh | 2 +- scribo/demo/viewer/image_widget.cc | 15 +- scribo/demo/viewer/image_widget.hh | 6 +- scribo/demo/viewer/key_widget.cc | 125 ++-- scribo/demo/viewer/key_widget.hh | 4 +- scribo/demo/viewer/main.cc | 5 +- scribo/demo/viewer/ocr_options.cc | 74 ++ scribo/demo/viewer/ocr_options.hh | 40 + scribo/demo/viewer/ocr_options.ui | 62 ++ scribo/demo/viewer/preferences_dialog.cc | 26 +- scribo/demo/viewer/preprocessing_options.cc | 66 ++ scribo/demo/viewer/preprocessing_options.hh | 38 + scribo/demo/viewer/preprocessing_options.ui | 76 ++ scribo/demo/viewer/runner.cc | 10 +- scribo/demo/viewer/segmentation_options.cc | 56 ++ scribo/demo/viewer/segmentation_options.hh | 37 + scribo/demo/viewer/segmentation_options.ui | 52 ++ scribo/demo/viewer/step_widget.cc | 1 + scribo/demo/viewer/toolchain_options.cc | 75 -- scribo/demo/viewer/toolchain_options.hh | 37 - scribo/demo/viewer/toolchain_options.ui | 121 --- scribo/demo/viewer/viewer.cc | 227 ++++++- scribo/demo/viewer/viewer.hh | 10 +- scribo/demo/viewer/viewer.qrc | 5 + scribo/demo/viewer/xml_widget.cc | 117 ++-- scribo/headers.mk | 35 +- scribo/scribo/convert/from_base64.hh | 221 ++++++ scribo/scribo/convert/to_base64.hh | 185 +++++ scribo/scribo/core/component_info.hh | 26 +- scribo/scribo/core/component_set.hh | 122 ++- scribo/scribo/core/concept/serializable.hh | 64 ++ scribo/scribo/core/concept/serialize_visitor.hh | 49 ++ scribo/scribo/core/def/lbl_type.hh | 12 +- scribo/scribo/core/document.hh | 171 ++++- scribo/scribo/core/internal/doc_serializer.hh | 140 ++++ scribo/scribo/core/line_info.hh | 419 ++++++----- scribo/scribo/core/line_links.hh | 10 +- scribo/scribo/core/line_set.hh | 29 +- scribo/scribo/core/macros.hh | 7 +- scribo/scribo/core/object_groups.hh | 4 +- scribo/scribo/core/object_links.hh | 8 +- scribo/scribo/core/paragraph_info.hh | 19 + scribo/scribo/core/paragraph_set.hh | 116 +++- scribo/scribo/core/tag/anchor.hh | 11 +- scribo/scribo/core/tag/component.hh | 51 ++- scribo/scribo/core/tag/line.hh | 34 +- scribo/scribo/debug/alignment_decision_image.hh | 87 +-- scribo/scribo/debug/all.hh | 7 +- scribo/scribo/debug/bboxes_image.hh | 166 ++++ scribo/scribo/debug/char_space_image.hh | 8 +- scribo/scribo/debug/linked_bboxes_image.hh | 262 +++++++ scribo/scribo/debug/links_image.hh | 106 +++ scribo/scribo/debug/logger.hh | 293 ++++++++ scribo/scribo/debug/save_bboxes_image.hh | 174 ----- scribo/scribo/debug/save_linked_bboxes_image.hh | 277 ------- .../scribo/debug/several_links_decision_image.hh | 179 ----- scribo/scribo/filter/internal/alignment_angle.hh | 146 +++-- scribo/scribo/filter/object_links_aligned.hh | 114 +++ .../scribo/filter/object_links_bottom_aligned.hh | 8 +- .../filter/object_links_non_aligned_simple.hh | 3 +- scribo/scribo/filter/object_links_top_aligned.hh | 7 +- scribo/scribo/fun/v2v/highlight.hh | 77 ++ scribo/scribo/io/img/internal/debug_img_visitor.hh | 263 +++++++ scribo/scribo/io/img/internal/draw_edges.hh | 97 +++ scribo/scribo/io/img/internal/full_img_visitor.hh | 194 +++++ .../scribo/io/img/internal/non_text_img_visitor.hh | 162 ++++ scribo/scribo/io/img/internal/text_img_visitor.hh | 164 ++++ scribo/scribo/io/img/save.hh | 242 ++++++ .../io/xml/internal/extended_page_xml_visitor.hh | 304 ++++++++ scribo/scribo/io/xml/internal/full_xml_visitor.hh | 469 ++++++++++++ scribo/scribo/io/xml/internal/page_xml_visitor.hh | 224 ++++++ scribo/scribo/io/xml/internal/print_box_coords.hh | 95 +++ .../scribo/io/xml/internal/print_image_coords.hh | 94 +++ .../scribo/io/xml/internal/print_page_preambule.hh | 100 +++ scribo/scribo/io/xml/load.hh | 529 +++++++++++++ scribo/scribo/io/xml/save.hh | 383 ++-------- scribo/scribo/make/text_blocks_image.hh | 136 ++++ scribo/scribo/make/text_components_image.hh | 101 +++ scribo/scribo/preprocessing/rotate_90.hh | 25 +- scribo/scribo/primitive/extract/components.hh | 18 +- scribo/scribo/primitive/extract/elements.hh | 236 ------ .../primitive/extract/horizontal_separators.hh | 27 +- scribo/scribo/primitive/extract/internal/union.hh | 246 ++++++ scribo/scribo/primitive/extract/non_text.hh | 369 +++++++++ scribo/scribo/primitive/extract/non_text_kmean.hh | 224 ++++++ scribo/scribo/primitive/extract/separators.hh | 9 +- .../primitive/extract/separators_nonvisible.hh | 790 ++++++-------------- scribo/scribo/primitive/identify.hh | 30 +- .../primitive/link/internal/compute_anchor.hh | 42 +- scribo/scribo/primitive/link/internal/find_link.hh | 5 +- .../primitive/link/internal/link_functor_base.hh | 31 +- .../link_single_dmax_ratio_aligned_base.hh | 268 +++++++ .../link/internal/link_single_dmax_ratio_base.hh | 7 +- .../with_single_left_link_dmax_ratio_aligned.hh | 217 ++++++ .../primitive/link/with_single_right_link.hh | 16 +- .../with_single_right_link_dmax_ratio_aligned.hh | 69 +-- .../primitive/link/with_single_right_link_top.hh | 28 +- scribo/scribo/table/extract.hh | 6 +- scribo/scribo/text/extract_lines.hh | 73 ++- scribo/scribo/text/merging.hh | 6 +- scribo/scribo/text/recognition.hh | 6 +- scribo/scribo/toolchain/content_in_doc.hh | 10 +- .../toolchain/internal/content_in_doc_functor.hh | 260 ++++--- .../toolchain/internal/text_in_doc_functor.hh | 107 ++-- .../internal/text_in_doc_preprocess_functor.hh | 7 +- scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +- scribo/scribo/toolchain/text_in_doc.hh | 11 +- scribo/scribo/toolchain/text_in_picture.hh | 20 +- scribo/src/Makefile.am | 32 +- scribo/src/binarization/ppm_sauvola.cc | 9 +- scribo/src/binarization/ppm_sauvola_ms.cc | 9 +- scribo/src/binarization/ppm_sauvola_ms_fg.cc | 8 +- scribo/src/binarization/ppm_sauvola_ms_split.cc | 5 +- scribo/src/binarization/sauvola.cc | 4 +- scribo/src/binarization/sauvola_debug.cc | 8 +- scribo/src/binarization/sauvola_ms.cc | 9 +- scribo/src/binarization/sauvola_ms_debug.cc | 9 +- scribo/src/binarization/sauvola_ms_fg.cc | 8 +- scribo/src/content_in_doc.cc | 28 +- scribo/src/debug/Makefile.am | 66 ++- scribo/src/debug/non_text_mask.cc | 26 + scribo/src/debug/show_components_bboxes.cc | 59 ++ scribo/src/debug/show_groups_bboxes.cc | 91 +++ .../src/debug/show_info_median_inter_characters.cc | 12 +- scribo/src/debug/show_info_x_height.cc | 12 +- scribo/src/debug/show_links_bottom_aligned.cc | 16 +- .../src/debug/show_links_bottom_aligned_2angles.cc | 100 +++ scribo/src/debug/show_links_center_aligned.cc | 6 +- scribo/src/debug/show_links_several_right.cc | 90 --- .../src/debug/show_links_several_right_overlap.cc | 6 +- scribo/src/debug/show_links_single_down.cc | 5 +- .../debug/show_links_single_down_left_aligned.cc | 11 +- .../debug/show_links_single_down_right_aligned.cc | 14 +- scribo/src/debug/show_links_single_left.cc | 5 +- .../src/debug/show_links_single_left_dmax_ratio.cc | 5 +- scribo/src/debug/show_links_single_right.cc | 5 +- .../debug/show_links_single_right_dmax_ratio.cc | 5 +- scribo/src/debug/show_links_single_up.cc | 5 +- .../src/debug/show_links_single_up_left_aligned.cc | 15 +- .../debug/show_links_single_up_right_aligned.cc | 15 +- scribo/src/debug/show_links_top_aligned.cc | 18 +- scribo/src/debug/show_links_top_aligned_2angles.cc | 100 +++ scribo/src/debug/show_paragraph_blocks.cc | 185 +++++ scribo/src/debug/show_separators.cc | 98 +++ scribo/src/debug/show_stoppers.cc | 124 +++ scribo/src/debug/show_text_lines.cc | 130 ++++ scribo/src/non_text_components.cc | 128 ++++ scribo/src/pbm_text_in_doc.cc | 16 +- scribo/src/preprocessing/rotate.cc | 1 + scribo/src/preprocessing/rotate_90.cc | 1 + scribo/src/primitive/extract/Makefile.am | 28 +- ...scontinued_hlines.cc => discontinued_hlines.cc} | 0 ...discontinued_lines.cc => discontinued_lines.cc} | 0 ...scontinued_vlines.cc => discontinued_vlines.cc} | 0 .../src/primitive/extract/separators_nonvisible.cc | 64 ++ .../{extract_thick_hlines.cc => thick_hlines.cc} | 0 .../{extract_thick_vlines.cc => thick_vlines.cc} | 0 .../src/primitive/group/group_from_double_link.cc | 28 +- .../group/group_from_double_several_links.cc | 25 +- .../group/group_from_several_left_links.cc | 23 +- .../src/primitive/group/group_from_single_link.cc | 36 +- scribo/src/primitive/remove/Makefile.am | 23 + scribo/src/primitive/remove/separators.cc | 63 ++ scribo/src/text_in_picture.cc | 32 +- scribo/src/text_in_picture_neg.cc | 7 +- scribo/src/text_recognition_in_picture.cc | 11 +- scribo/tests/Makefile.am | 1 + scribo/tests/convert/Makefile.am | 27 + scribo/tests/convert/base64.cc | 89 +++ scribo/tests/filter/components_large.cc | 8 +- scribo/tests/filter/components_small.cc | 8 +- scribo/tests/toolchain/nepomuk/Makefile.am | 5 +- scribo/tests/unit_test/Makefile.am | 7 +- .../cond_tests_magickxx_qt_tesseract_tiff | 2 + scribo/tests/unit_test/cond_tests_qt | 3 + .../tests/unit_test/cond_tests_qt_tesseract_tiff | 2 +- scribo/tests/unit_test/unit-tests.mk | 114 +++- 202 files changed, 11626 insertions(+), 3338 deletions(-) create mode 100644 milena/mln/fun/v2v/rgb_to_luma.hh create mode 100644 scribo/demo/shared/icons/olena_smaller.jpg create mode 100644 scribo/demo/viewer/help_dialog.ui create mode 100644 scribo/demo/viewer/ocr_options.cc create mode 100644 scribo/demo/viewer/ocr_options.hh create mode 100644 scribo/demo/viewer/ocr_options.ui create mode 100644 scribo/demo/viewer/preprocessing_options.cc create mode 100644 scribo/demo/viewer/preprocessing_options.hh create mode 100644 scribo/demo/viewer/preprocessing_options.ui create mode 100644 scribo/demo/viewer/segmentation_options.cc create mode 100644 scribo/demo/viewer/segmentation_options.hh create mode 100644 scribo/demo/viewer/segmentation_options.ui delete mode 100644 scribo/demo/viewer/toolchain_options.cc delete mode 100644 scribo/demo/viewer/toolchain_options.hh delete mode 100644 scribo/demo/viewer/toolchain_options.ui create mode 100644 scribo/demo/viewer/viewer.qrc create mode 100644 scribo/scribo/convert/from_base64.hh create mode 100644 scribo/scribo/convert/to_base64.hh create mode 100644 scribo/scribo/core/concept/serializable.hh create mode 100644 scribo/scribo/core/concept/serialize_visitor.hh create mode 100644 scribo/scribo/core/internal/doc_serializer.hh create mode 100644 scribo/scribo/debug/bboxes_image.hh create mode 100644 scribo/scribo/debug/linked_bboxes_image.hh create mode 100644 scribo/scribo/debug/links_image.hh create mode 100644 scribo/scribo/debug/logger.hh delete mode 100644 scribo/scribo/debug/save_bboxes_image.hh delete mode 100644 scribo/scribo/debug/save_linked_bboxes_image.hh delete mode 100644 scribo/scribo/debug/several_links_decision_image.hh create mode 100644 scribo/scribo/filter/object_links_aligned.hh create mode 100644 scribo/scribo/fun/v2v/highlight.hh create mode 100644 scribo/scribo/io/img/internal/debug_img_visitor.hh create mode 100644 scribo/scribo/io/img/internal/draw_edges.hh create mode 100644 scribo/scribo/io/img/internal/full_img_visitor.hh create mode 100644 scribo/scribo/io/img/internal/non_text_img_visitor.hh create mode 100644 scribo/scribo/io/img/internal/text_img_visitor.hh create mode 100644 scribo/scribo/io/img/save.hh create mode 100644 scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh create mode 100644 scribo/scribo/io/xml/internal/full_xml_visitor.hh create mode 100644 scribo/scribo/io/xml/internal/page_xml_visitor.hh create mode 100644 scribo/scribo/io/xml/internal/print_box_coords.hh create mode 100644 scribo/scribo/io/xml/internal/print_image_coords.hh create mode 100644 scribo/scribo/io/xml/internal/print_page_preambule.hh create mode 100644 scribo/scribo/io/xml/load.hh create mode 100644 scribo/scribo/make/text_blocks_image.hh create mode 100644 scribo/scribo/make/text_components_image.hh delete mode 100644 scribo/scribo/primitive/extract/elements.hh create mode 100644 scribo/scribo/primitive/extract/internal/union.hh create mode 100644 scribo/scribo/primitive/extract/non_text.hh create mode 100644 scribo/scribo/primitive/extract/non_text_kmean.hh create mode 100644 scribo/scribo/primitive/link/internal/link_single_dmax_ratio_aligned_base.hh create mode 100644 scribo/scribo/primitive/link/with_single_left_link_dmax_ratio_aligned.hh create mode 100644 scribo/src/debug/non_text_mask.cc create mode 100644 scribo/src/debug/show_components_bboxes.cc create mode 100644 scribo/src/debug/show_groups_bboxes.cc create mode 100644 scribo/src/debug/show_links_bottom_aligned_2angles.cc delete mode 100644 scribo/src/debug/show_links_several_right.cc create mode 100644 scribo/src/debug/show_links_top_aligned_2angles.cc create mode 100644 scribo/src/debug/show_paragraph_blocks.cc create mode 100644 scribo/src/debug/show_separators.cc create mode 100644 scribo/src/debug/show_stoppers.cc create mode 100644 scribo/src/debug/show_text_lines.cc create mode 100644 scribo/src/non_text_components.cc rename scribo/src/primitive/extract/{extract_discontinued_hlines.cc => discontinued_hlines.cc} (100%) rename scribo/src/primitive/extract/{extract_discontinued_lines.cc => discontinued_lines.cc} (100%) rename scribo/src/primitive/extract/{extract_discontinued_vlines.cc => discontinued_vlines.cc} (100%) create mode 100644 scribo/src/primitive/extract/separators_nonvisible.cc rename scribo/src/primitive/extract/{extract_thick_hlines.cc => thick_hlines.cc} (100%) rename scribo/src/primitive/extract/{extract_thick_vlines.cc => thick_vlines.cc} (100%) create mode 100644 scribo/src/primitive/remove/Makefile.am create mode 100644 scribo/src/primitive/remove/separators.cc create mode 100644 scribo/tests/convert/Makefile.am create mode 100644 scribo/tests/convert/base64.cc create mode 100644 scribo/tests/unit_test/cond_tests_magickxx_qt_tesseract_tiff hooks/post-receive -- Olena, a generic and efficient image processing platform
13 years, 9 months
1
0
0
0
last-svn-commit-801-ge441edb Introduce a logger class.
by Guillaume Lazzara
* scribo/debug/logger.hh: New. * scribo/toolchain/internal/content_in_doc_functor.hh, * scribo/toolchain/internal/text_in_doc_functor.hh, * scribo/toolchain/nepomuk/text_extraction.hh, * scribo/toolchain/text_in_doc.hh, * src/content_in_doc.cc, * src/pbm_text_in_doc.cc, * src/primitive/extract/separators_nonvisible.cc Make use of that class for saving debug images. --- scribo/ChangeLog | 15 ++ scribo/scribo/toolchain/content_in_doc.hh | 10 +- .../toolchain/internal/content_in_doc_functor.hh | 202 ++++++++++++------- .../toolchain/internal/text_in_doc_functor.hh | 107 ++++++----- scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +- scribo/scribo/toolchain/text_in_doc.hh | 11 +- scribo/src/content_in_doc.cc | 21 +-- scribo/src/pbm_text_in_doc.cc | 16 +- .../src/primitive/extract/separators_nonvisible.cc | 8 +- 9 files changed, 234 insertions(+), 165 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index a377ba0..1e9b57e 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -4,6 +4,21 @@ * scribo/debug/logger.hh: New. + * scribo/toolchain/internal/content_in_doc_functor.hh, + * scribo/toolchain/internal/text_in_doc_functor.hh, + * scribo/toolchain/nepomuk/text_extraction.hh, + * scribo/toolchain/text_in_doc.hh, + * src/content_in_doc.cc, + * src/pbm_text_in_doc.cc, + * src/primitive/extract/separators_nonvisible.cc Make use of that + class for saving debug images. + +2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr> + + Introduce a logger class. + + * scribo/debug/logger.hh: New. + 2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr> Introduce new anchors. diff --git a/scribo/scribo/toolchain/content_in_doc.hh b/scribo/scribo/toolchain/content_in_doc.hh index f2938d9..4469afa 100644 --- a/scribo/scribo/toolchain/content_in_doc.hh +++ b/scribo/scribo/toolchain/content_in_doc.hh @@ -45,10 +45,10 @@ namespace scribo document<mln_ch_value(I, def::lbl_type)> content_in_doc(const Image<I>& input, const Image<J>& input_preproc, bool denoise, - const std::string& language = std::string("eng"), bool find_line_seps = true, bool find_whitespace_seps = true, - bool debug = false); + bool enable_ocr = true, + const std::string& language = std::string("eng")); # ifndef MLN_INCLUDE_ONLY @@ -58,10 +58,10 @@ namespace scribo document<mln_ch_value(I, def::lbl_type)> content_in_doc(const Image<I>& input, const Image<J>& input_preproc, bool denoise, - const std::string& language = std::string("eng"), bool find_line_seps = true, bool find_whitespace_seps = true, - bool debug = false) + bool enable_ocr = true, + const std::string& language = std::string("eng")) { mln_precondition(input.is_valid()); mln_precondition(input_preproc.is_valid()); @@ -70,8 +70,8 @@ namespace scribo f.enable_denoising = denoise; f.enable_line_seps = find_line_seps; f.enable_whitespace_seps = find_whitespace_seps; - f.enable_debug = debug; f.ocr_language = language; + f.enable_ocr = enable_ocr; document<mln_ch_value(I, def::lbl_type)> doc = f(input, input_preproc); diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh index 3e6668f..624a54e 100644 --- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh @@ -27,8 +27,6 @@ #ifndef SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH # define SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH -# include <mln/io/ppm/save.hh> - # include <scribo/core/def/lbl_type.hh> # include <scribo/core/document.hh> # include <scribo/core/line_set.hh> @@ -37,6 +35,8 @@ # include <scribo/primitive/extract/non_text.hh> # include <scribo/primitive/extract/components.hh> # include <scribo/primitive/extract/separators.hh> +# include <scribo/primitive/extract/vertical_separators.hh> +# include <scribo/primitive/extract/horizontal_separators.hh> # include <scribo/primitive/extract/separators_nonvisible.hh> # include <scribo/primitive/identify.hh> @@ -62,8 +62,9 @@ # include <scribo/make/debug_filename.hh> -# include <scribo/debug/save_bboxes_image.hh> -# include <scribo/debug/save_linked_bboxes_image.hh> +# include <scribo/debug/decision_image.hh> +# include <scribo/debug/bboxes_image.hh> +# include <scribo/debug/linked_bboxes_image.hh> # include <scribo/debug/bboxes_enlarged_image.hh> # include <scribo/debug/mean_and_base_lines_image.hh> # include <scribo/debug/looks_like_a_text_line_image.hh> @@ -87,7 +88,7 @@ namespace scribo struct content_in_doc_functor : public Toolchain_Functor { - typedef value::label<30> V; + typedef scribo::def::lbl_type V; typedef mln_ch_value(I,V) L; content_in_doc_functor(const char *doc_filename); @@ -112,7 +113,6 @@ namespace scribo bool enable_line_seps; bool enable_whitespace_seps; bool enable_ocr; - bool enable_debug; bool save_doc_as_xml; scribo::io::xml::Format xml_format; @@ -138,7 +138,6 @@ namespace scribo enable_line_seps(true), enable_whitespace_seps(true), enable_ocr(true), - enable_debug(false), save_doc_as_xml(false), xml_format(scribo::io::xml::PageExtended), ocr_language("eng"), @@ -209,21 +208,30 @@ namespace scribo on_progress(); } - if (enable_debug) + + // Debug +# ifndef SCRIBO_NDEBUG + if (enable_whitespace_seps) + debug::logger().log_image(debug::AuxiliaryResults, + whitespaces, "whitespaces"); + + // Debug + if (enable_line_seps) { - if (enable_whitespace_seps) - mln::io::pbm::save(whitespaces, - scribo::make::debug_filename("whitespaces.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + doc.vline_seps(), + "vseparators"); - if (enable_line_seps) - { - mln::io::pbm::save(separators, - scribo::make::debug_filename("vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + doc.hline_seps(), + "hseparators"); - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("input_wo_vseparators.pbm")); - } + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, + "input_wo_separators"); } +# endif // ! SCRIBO_NDEBUG + // Denoise if (enable_denoising) @@ -232,9 +240,11 @@ namespace scribo input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); - if (enable_debug) - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("denoised.pbm")); + // Debug +# ifndef SCRIBO_NDEBUG + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "denoised"); +# endif // ! SCRIBO_NDEBUG on_progress(); } @@ -244,7 +254,8 @@ namespace scribo V ncomponents; component_set<L> - components = scribo::primitive::extract::components(input_cleaned, c8(), + components = scribo::primitive::extract::components(input_cleaned, + c8(), ncomponents); on_progress(); @@ -258,9 +269,12 @@ namespace scribo doc.set_whitespace_separators(whitespaces); } - if (enable_debug) - mln::io::pbm::save(components.separators(), - scribo::make::debug_filename("all_separators.pbm")); + // Debug +# ifndef SCRIBO_NDEBUG + debug::logger().log_image(debug::AuxiliaryResults, + components.separators(), + "all_separators"); +# endif // ! SCRIBO_NDEBUG on_new_progress_label("Filtering components"); @@ -274,24 +288,34 @@ namespace scribo on_new_progress_label("Linking objects..."); object_links<L> left_link - = primitive::link::with_single_left_link_dmax_ratio(components, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); - object_links<L> right_link - = primitive::link::with_single_right_link_dmax_ratio(components, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); + = primitive::link::with_single_left_link_dmax_ratio( + components, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); - if (enable_debug) + object_links<L> right_link + = primitive::link::with_single_right_link_dmax_ratio( + components, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); + + // Debug +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - debug::save_linked_bboxes_image(processed_image, left_link, right_link, - literal::blue, - literal::cyan, - literal::yellow, - literal::green, - anchor::MassCenter, - scribo::make::debug_filename("object_links.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + debug::linked_bboxes_image(processed_image, + left_link, + right_link, + literal::blue, + literal::cyan, + literal::yellow, + literal::green, + anchor::MassCenter), + "object_links"); } +# endif // ! SCRIBO_NDEBUG // Validating left and right links. @@ -309,16 +333,20 @@ namespace scribo = filter::object_links_bbox_h_ratio(merged_links, 2.5f); - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { mln_ch_value(I,value::rgb8) hratio_decision_image = scribo::debug::decision_image(processed_image, merged_links, hratio_filtered_links, anchor::MassCenter); - mln::io::ppm::save(hratio_decision_image, - scribo::make::debug_filename("hratio_links_decision_image.ppm")); + // Debug + debug::logger().log_image(debug::AuxiliaryResults, + hratio_decision_image, + "hratio_links_decision_image"); } +# endif // ! SCRIBO_NDEBUG on_progress(); @@ -336,28 +364,35 @@ namespace scribo //===== DEBUG ===== - - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { // Bboxes image. - scribo::debug::save_bboxes_image(processed_image, lines, - scribo::make::debug_filename("step1_bboxes.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_image(processed_image, lines), + "step1_bboxes"); // Bboxes enlarged - mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines), - scribo::make::debug_filename("step1_bboxes_enlarged.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_enlarged_image(processed_image, lines), + "step1_bboxes_enlarged"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines), - scribo::make::debug_filename("step1_looks_like_a_text_line.ppm")); - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(processed_image, lines), + "step1_looks_like_a_text_line"); // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines), - scribo::make::debug_filename("step1_x_height.ppm")); - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(processed_image, lines), + "step1_x_height"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== @@ -366,23 +401,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines), - scribo::make::debug_filename("step2_x_height.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(processed_image, lines), + "step2_x_height"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines), - scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(processed_image, lines), + "step2_looks_like_a_text_line"); // Bboxes image. - scribo::debug::save_bboxes_image(processed_image, lines, - scribo::make::debug_filename("step2_bboxes.ppm")); - - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_image(processed_image, lines), + "step2_bboxes"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -404,20 +445,25 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); + image2d<value::rgb8> + debug = data::convert(value::rgb8(), original_image); for_all_lines(l, lines) { if (! lines(l).is_textline()) continue; mln::draw::box(debug, lines(l).bbox(), literal::blue); - mln::draw::line(debug, lines(l).bbox().pcenter(), lines(llinks(l)).bbox().pcenter(), literal::green); + mln::draw::line(debug, lines(l).bbox().pcenter(), + lines(llinks(l)).bbox().pcenter(), literal::green); } - mln::io::ppm::save(debug, scribo::make::debug_filename("links_raw.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + debug, "links_raw"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -428,22 +474,26 @@ namespace scribo llinks = scribo::filter::line_links_x_height(llinks); //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); + image2d<value::rgb8> + debug = data::convert(value::rgb8(), original_image); for_all_links(i, llinks) if (llinks(i) && llinks(i) != i) mln::draw::line(debug, lines(i).bbox().pcenter(), lines(llinks(i)).bbox().pcenter(), literal::red); - mln::io::ppm::save(debug, scribo::make::debug_filename("links.ppm")); - + debug::logger().log_image(debug::AuxiliaryResults, + debug, "links"); for (unsigned i = 1; i < llinks.nelements(); ++i) llinks(i) = scribo::make::internal::find_root(llinks, i); debug = data::convert(value::rgb8(), original_image); - mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements()); + mln::util::array<accu::shape::bbox<point2d> > + nbbox(llinks.nelements()); + for_all_lines(i, lines) { if (! lines(i).is_textline()) @@ -464,8 +514,10 @@ namespace scribo mln::draw::box(debug, b, literal::green); } - mln::io::ppm::save(debug, scribo::make::debug_filename("par.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + debug, "par"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -482,7 +534,7 @@ namespace scribo // Extract other Elements on_new_progress_label("Extracting Elements"); component_set<L> - elements = scribo::primitive::extract::non_text(doc, original_image); + elements = scribo::primitive::extract::non_text(doc, 3); on_progress(); diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh index 16e981d..62074f0 100644 --- a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh @@ -27,8 +27,6 @@ #ifndef SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH # define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH -# include <mln/io/ppm/save.hh> - # include <scribo/core/def/lbl_type.hh> # include <scribo/primitive/extract/components.hh> @@ -54,8 +52,10 @@ # include <scribo/make/debug_filename.hh> -# include <scribo/debug/save_bboxes_image.hh> -# include <scribo/debug/save_linked_bboxes_image.hh> +# include <scribo/debug/logger.hh> +# include <scribo/debug/decision_image.hh> +# include <scribo/debug/bboxes_image.hh> +# include <scribo/debug/linked_bboxes_image.hh> # include <scribo/debug/bboxes_enlarged_image.hh> # include <scribo/debug/mean_and_base_lines_image.hh> # include <scribo/debug/looks_like_a_text_line_image.hh> @@ -77,7 +77,7 @@ namespace scribo struct text_in_doc_functor : public Toolchain_Functor { - typedef value::label<30> V; + typedef scribo::def::lbl_type V; typedef mln_ch_value(I,V) L; text_in_doc_functor(); @@ -97,7 +97,6 @@ namespace scribo bool enable_denoising; bool enable_line_seps; bool enable_whitespace_seps; - bool enable_debug; //============ // Parameters @@ -118,7 +117,6 @@ namespace scribo : enable_denoising(true), enable_line_seps(true), enable_whitespace_seps(true), - enable_debug(false), ocr_language("eng") { } @@ -164,19 +162,19 @@ namespace scribo on_progress(); } - if (enable_debug) + if (debug::logger().is_enabled()) { if (enable_whitespace_seps) - mln::io::pbm::save(whitespaces, - scribo::make::debug_filename("whitespaces.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + whitespaces, "whitespaces"); if (enable_line_seps) { - mln::io::pbm::save(separators, - scribo::make::debug_filename("vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + separators, "vseparators"); - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("input_wo_vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "input_wo_vseparators"); } } @@ -187,9 +185,9 @@ namespace scribo input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); - if (enable_debug) - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("denoised.pbm")); + if (debug::logger().is_enabled()) + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "denoised"); on_progress(); } @@ -210,9 +208,9 @@ namespace scribo if (enable_whitespace_seps) components.add_separators(whitespaces); - if (enable_debug) - mln::io::pbm::save(components.separators(), - scribo::make::debug_filename("all_separators.pbm")); + if (debug::logger().is_enabled()) + debug::logger().log_image(debug::AuxiliaryResults, + components.separators(), "all_separators"); on_new_progress_label("Filtering components"); @@ -234,15 +232,19 @@ namespace scribo primitive::link::internal::dmax_width_and_height(1), anchor::MassCenter); - if (enable_debug) + if (debug::logger().is_enabled()) { - debug::save_linked_bboxes_image(input, left_link, right_link, - literal::blue, - literal::cyan, - literal::yellow, - literal::green, - anchor::MassCenter, - scribo::make::debug_filename("object_links.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + debug::linked_bboxes_image(input, + left_link, + right_link, + literal::blue, + literal::cyan, + literal::yellow, + literal::green, + anchor::MassCenter), + "object_links"); } @@ -261,15 +263,16 @@ namespace scribo = filter::object_links_bbox_h_ratio(merged_links, 2.5f); - if (enable_debug) + if (debug::logger().is_enabled()) { mln_ch_value(I,value::rgb8) hratio_decision_image = scribo::debug::decision_image(input, merged_links, hratio_filtered_links, anchor::MassCenter); - io::ppm::save(hratio_decision_image, - scribo::make::debug_filename("hratio_links_decision_image.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + hratio_decision_image, + "hratio_links_decision_image"); } on_progress(); @@ -289,25 +292,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) + if (debug::logger().is_enabled()) { // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, - scribo::make::debug_filename("step1_bboxes.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_image(input, lines), + "step1_bboxes"); // Bboxes enlarged - mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines), - scribo::make::debug_filename("step1_bboxes_enlarged.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_enlarged_image(input, lines), + "step1_bboxes_enlarged"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines), - scribo::make::debug_filename("step1_looks_like_a_text_line.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(input, lines), + "step1_looks_like_a_text_line"); // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines), - scribo::make::debug_filename("step1_x_height.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(input, lines), + "step1_x_height"); } //===== END OF DEBUG ===== @@ -320,27 +327,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) + if (debug::logger().is_enabled()) { // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines), - scribo::make::debug_filename("step2_x_height.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(input, lines), + "step2_x_height"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines), - scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(input, lines), + "step2_looks_like_a_text_line"); // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, - scribo::make::debug_filename("step2_bboxes.ppm")); - + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_image(input, lines), + "step2_bboxes"); } - if (enable_debug) + if (debug::logger().is_enabled()) { std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str()); diff --git a/scribo/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/scribo/toolchain/nepomuk/text_extraction.hh index 0447cef..2534ce8 100644 --- a/scribo/scribo/toolchain/nepomuk/text_extraction.hh +++ b/scribo/scribo/toolchain/nepomuk/text_extraction.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -121,8 +122,7 @@ namespace scribo // Run document toolchain. lines_bg = scribo::toolchain::text_in_doc(input_bin, true, - language.toUtf8().data(), - false); + language.toUtf8().data()); // Negate document. logical::not_inplace(input_bin); @@ -130,8 +130,7 @@ namespace scribo // Run document toolchain. lines_fg = scribo::toolchain::text_in_doc(input_bin, true, - language.toUtf8().data(), - false); + language.toUtf8().data()); } diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh index e6ba69e..9f20b39 100644 --- a/scribo/scribo/toolchain/text_in_doc.hh +++ b/scribo/scribo/toolchain/text_in_doc.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -47,8 +47,7 @@ namespace scribo text_in_doc(const Image<I>& input, bool denoise, const std::string& language = std::string("eng"), bool find_line_seps = true, - bool find_whitespace_seps = true, - bool debug = false); + bool find_whitespace_seps = true); # ifndef MLN_INCLUDE_ONLY @@ -59,14 +58,12 @@ namespace scribo text_in_doc(const Image<I>& input, bool denoise, const std::string& language = std::string("eng"), bool find_line_seps = true, - bool find_whitespace_seps = true, - bool debug = false) + bool find_whitespace_seps = true) { internal::text_in_doc_functor<I> f; f.enable_denoising = denoise; f.enable_line_seps = find_line_seps; f.enable_whitespace_seps = find_whitespace_seps; - f.enable_debug = debug; f.ocr_language = language; line_set<mln_ch_value(I, def::lbl_type)> lines = f(input); diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc index d8d4e52..81ec4fb 100644 --- a/scribo/src/content_in_doc.cc +++ b/scribo/src/content_in_doc.cc @@ -40,8 +40,7 @@ #include <scribo/core/document.hh> #include <scribo/debug/usage.hh> - -#include <scribo/make/debug_filename.hh> +#include <scribo/debug/logger.hh> #include <scribo/preprocessing/crop_without_localization.hh> #include <scribo/preprocessing/crop.hh> @@ -79,13 +78,12 @@ int main(int argc, char* argv[]) "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] [language] [find_lines] [find_whitespaces] [K] [debug_dir]", args_desc); - bool debug = false; - // Enable debug output. if (argc == 9 || argc == 13) { + scribo::debug::logger().set_filename_prefix(argv[argc - 1]); + scribo::debug::logger().set_level(scribo::debug::All); scribo::make::internal::debug_filename_prefix = argv[argc - 1]; - debug = true; } trace::entering("main"); @@ -109,7 +107,6 @@ int main(int argc, char* argv[]) std::cout << "Using K = " << K << std::endl; } - image2d<bool> tmp_fg; input_preproc = toolchain::text_in_doc_preprocess(input, false, K); } @@ -130,9 +127,8 @@ int main(int argc, char* argv[]) input_preproc = preprocessing::crop_without_localization(input_preproc, roi); crop_shift = point2d(minr, minc); - if (debug) - mln::io::pbm::save(input_preproc, - scribo::make::debug_filename("input_preproc_cropped.pbm")); + scribo::debug::logger().log_image(scribo::debug::Results, input_preproc, + "input_preproc_cropped.pbm"); } bool denoise = (argc > 3 && atoi(argv[3]) != 0); @@ -159,7 +155,7 @@ int main(int argc, char* argv[]) << " ocr_language = " << language << " | find_lines_seps = " << find_line_seps << " | find_whitespace_seps = " << find_whitespace_seps - << " | debug = " << debug + << " | debug = " << scribo::debug::logger().is_enabled() << std::endl; // Run document toolchain. @@ -167,11 +163,12 @@ int main(int argc, char* argv[]) // Text std::cout << "Analysing document..." << std::endl; document<L> - doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, language, + doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, find_line_seps, find_whitespace_seps, - debug); + !language.empty(), language); // Saving results + std::cout << "Saving results..." << std::endl; scribo::io::xml::save(doc, argv[2], scribo::io::xml::PageExtended); scribo::io::xml::save(doc, "page.xml", scribo::io::xml::Page); scribo::io::xml::save(doc, "full.xml", scribo::io::xml::Full); diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc index 2726ead..42b7d88 100644 --- a/scribo/src/pbm_text_in_doc.cc +++ b/scribo/src/pbm_text_in_doc.cc @@ -45,8 +45,6 @@ #include <scribo/debug/usage.hh> -#include <scribo/make/debug_filename.hh> - #include <scribo/preprocessing/crop_without_localization.hh> #include <scribo/io/text_boxes/save.hh> @@ -83,13 +81,12 @@ int main(int argc, char* argv[]) "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <language> <find_lines> <find_whitespaces> <debug_dir>", args_desc); - bool debug = false; - // Enable debug output. if (argc == 8 || argc == 12) { + scribo::debug::logger().set_filename_prefix(argv[argc - 1]); + scribo::debug::logger().set_level(scribo::debug::All); scribo::make::internal::debug_filename_prefix = argv[argc - 1]; - debug = true; } trace::entering("main"); @@ -116,9 +113,8 @@ int main(int argc, char* argv[]) input = preprocessing::crop_without_localization(input, roi); crop_shift = point2d(minr, minc); - if (debug) - mln::io::pbm::save(input, - scribo::make::debug_filename("input_cropped.pbm")); + scribo::debug::logger().log_image(scribo::debug::Results, input, + "input_cropped.pbm"); } bool denoise = (argc > 3 && atoi(argv[3]) != 0); @@ -146,14 +142,14 @@ int main(int argc, char* argv[]) << " ocr language = " << language << " | find_lines_seps = " << find_line_seps << " | find_whitespace_seps = " << find_whitespace_seps - << " | debug = " << debug + << " | debug = " << scribo::debug::logger().is_enabled() << std::endl; // Run document toolchain. line_set<L> lines = scribo::toolchain::text_in_doc(input, denoise, language, find_line_seps, - find_whitespace_seps, debug); + find_whitespace_seps); scribo::document<L> doc; doc.set_filename(argv[1]); diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc index d50cc73..177047c 100644 --- a/scribo/src/primitive/extract/separators_nonvisible.cc +++ b/scribo/src/primitive/extract/separators_nonvisible.cc @@ -34,6 +34,7 @@ const char *args_desc[][2] = { { "input.pbm", "A binary image." }, { "output.pbm", "Output image." }, + { "enable_debug", "0 or 1 (default 0)" }, {0, 0} }; @@ -43,10 +44,10 @@ int main(int argc, char *argv[]) using namespace mln; using namespace scribo; - if (argc != 3) + if (argc != 3 && argc != 4) return scribo::debug::usage(argv, "Extract non visible separators (whitespaces)", - "input.pbm output.pbm", + "input.pbm output.pbm [enable_debug]", args_desc); trace::entering("main"); @@ -54,6 +55,9 @@ int main(int argc, char *argv[]) image2d<bool> input; io::pbm::load(input, argv[1]); + if (argc > 3 && atoi(argv[3])) + scribo::debug::logger().set_level(scribo::debug::All); + io::pbm::save(primitive::extract::separators_nonvisible(input), argv[2]); trace::exiting("main"); -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-800-g5db5a72 Introduce a logger class.
by Guillaume Lazzara
* scribo/debug/logger.hh: New. * scribo/toolchain/internal/content_in_doc_functor.hh, * scribo/toolchain/internal/text_in_doc_functor.hh, * scribo/toolchain/nepomuk/text_extraction.hh, * scribo/toolchain/text_in_doc.hh, * src/content_in_doc.cc, * src/pbm_text_in_doc.cc, * src/primitive/extract/separators_nonvisible.cc Make use of that class for saving debug images. --- scribo/ChangeLog | 15 ++ scribo/scribo/toolchain/content_in_doc.hh | 10 +- .../toolchain/internal/content_in_doc_functor.hh | 202 ++++++++++++------- .../toolchain/internal/text_in_doc_functor.hh | 107 ++++++----- scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +- scribo/scribo/toolchain/text_in_doc.hh | 11 +- scribo/src/content_in_doc.cc | 21 +-- scribo/src/pbm_text_in_doc.cc | 16 +- .../src/primitive/extract/separators_nonvisible.cc | 8 +- 9 files changed, 234 insertions(+), 165 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 50c49e7..bd7b036 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -4,6 +4,21 @@ * scribo/debug/logger.hh: New. + * scribo/toolchain/internal/content_in_doc_functor.hh, + * scribo/toolchain/internal/text_in_doc_functor.hh, + * scribo/toolchain/nepomuk/text_extraction.hh, + * scribo/toolchain/text_in_doc.hh, + * src/content_in_doc.cc, + * src/pbm_text_in_doc.cc, + * src/primitive/extract/separators_nonvisible.cc Make use of that + class for saving debug images. + +2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr> + + Introduce a logger class. + + * scribo/debug/logger.hh: New. + 2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr> Introduce new anchors. diff --git a/scribo/scribo/toolchain/content_in_doc.hh b/scribo/scribo/toolchain/content_in_doc.hh index f2938d9..4469afa 100644 --- a/scribo/scribo/toolchain/content_in_doc.hh +++ b/scribo/scribo/toolchain/content_in_doc.hh @@ -45,10 +45,10 @@ namespace scribo document<mln_ch_value(I, def::lbl_type)> content_in_doc(const Image<I>& input, const Image<J>& input_preproc, bool denoise, - const std::string& language = std::string("eng"), bool find_line_seps = true, bool find_whitespace_seps = true, - bool debug = false); + bool enable_ocr = true, + const std::string& language = std::string("eng")); # ifndef MLN_INCLUDE_ONLY @@ -58,10 +58,10 @@ namespace scribo document<mln_ch_value(I, def::lbl_type)> content_in_doc(const Image<I>& input, const Image<J>& input_preproc, bool denoise, - const std::string& language = std::string("eng"), bool find_line_seps = true, bool find_whitespace_seps = true, - bool debug = false) + bool enable_ocr = true, + const std::string& language = std::string("eng")) { mln_precondition(input.is_valid()); mln_precondition(input_preproc.is_valid()); @@ -70,8 +70,8 @@ namespace scribo f.enable_denoising = denoise; f.enable_line_seps = find_line_seps; f.enable_whitespace_seps = find_whitespace_seps; - f.enable_debug = debug; f.ocr_language = language; + f.enable_ocr = enable_ocr; document<mln_ch_value(I, def::lbl_type)> doc = f(input, input_preproc); diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh index 3e6668f..624a54e 100644 --- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh @@ -27,8 +27,6 @@ #ifndef SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH # define SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH -# include <mln/io/ppm/save.hh> - # include <scribo/core/def/lbl_type.hh> # include <scribo/core/document.hh> # include <scribo/core/line_set.hh> @@ -37,6 +35,8 @@ # include <scribo/primitive/extract/non_text.hh> # include <scribo/primitive/extract/components.hh> # include <scribo/primitive/extract/separators.hh> +# include <scribo/primitive/extract/vertical_separators.hh> +# include <scribo/primitive/extract/horizontal_separators.hh> # include <scribo/primitive/extract/separators_nonvisible.hh> # include <scribo/primitive/identify.hh> @@ -62,8 +62,9 @@ # include <scribo/make/debug_filename.hh> -# include <scribo/debug/save_bboxes_image.hh> -# include <scribo/debug/save_linked_bboxes_image.hh> +# include <scribo/debug/decision_image.hh> +# include <scribo/debug/bboxes_image.hh> +# include <scribo/debug/linked_bboxes_image.hh> # include <scribo/debug/bboxes_enlarged_image.hh> # include <scribo/debug/mean_and_base_lines_image.hh> # include <scribo/debug/looks_like_a_text_line_image.hh> @@ -87,7 +88,7 @@ namespace scribo struct content_in_doc_functor : public Toolchain_Functor { - typedef value::label<30> V; + typedef scribo::def::lbl_type V; typedef mln_ch_value(I,V) L; content_in_doc_functor(const char *doc_filename); @@ -112,7 +113,6 @@ namespace scribo bool enable_line_seps; bool enable_whitespace_seps; bool enable_ocr; - bool enable_debug; bool save_doc_as_xml; scribo::io::xml::Format xml_format; @@ -138,7 +138,6 @@ namespace scribo enable_line_seps(true), enable_whitespace_seps(true), enable_ocr(true), - enable_debug(false), save_doc_as_xml(false), xml_format(scribo::io::xml::PageExtended), ocr_language("eng"), @@ -209,21 +208,30 @@ namespace scribo on_progress(); } - if (enable_debug) + + // Debug +# ifndef SCRIBO_NDEBUG + if (enable_whitespace_seps) + debug::logger().log_image(debug::AuxiliaryResults, + whitespaces, "whitespaces"); + + // Debug + if (enable_line_seps) { - if (enable_whitespace_seps) - mln::io::pbm::save(whitespaces, - scribo::make::debug_filename("whitespaces.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + doc.vline_seps(), + "vseparators"); - if (enable_line_seps) - { - mln::io::pbm::save(separators, - scribo::make::debug_filename("vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + doc.hline_seps(), + "hseparators"); - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("input_wo_vseparators.pbm")); - } + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, + "input_wo_separators"); } +# endif // ! SCRIBO_NDEBUG + // Denoise if (enable_denoising) @@ -232,9 +240,11 @@ namespace scribo input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); - if (enable_debug) - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("denoised.pbm")); + // Debug +# ifndef SCRIBO_NDEBUG + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "denoised"); +# endif // ! SCRIBO_NDEBUG on_progress(); } @@ -244,7 +254,8 @@ namespace scribo V ncomponents; component_set<L> - components = scribo::primitive::extract::components(input_cleaned, c8(), + components = scribo::primitive::extract::components(input_cleaned, + c8(), ncomponents); on_progress(); @@ -258,9 +269,12 @@ namespace scribo doc.set_whitespace_separators(whitespaces); } - if (enable_debug) - mln::io::pbm::save(components.separators(), - scribo::make::debug_filename("all_separators.pbm")); + // Debug +# ifndef SCRIBO_NDEBUG + debug::logger().log_image(debug::AuxiliaryResults, + components.separators(), + "all_separators"); +# endif // ! SCRIBO_NDEBUG on_new_progress_label("Filtering components"); @@ -274,24 +288,34 @@ namespace scribo on_new_progress_label("Linking objects..."); object_links<L> left_link - = primitive::link::with_single_left_link_dmax_ratio(components, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); - object_links<L> right_link - = primitive::link::with_single_right_link_dmax_ratio(components, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); + = primitive::link::with_single_left_link_dmax_ratio( + components, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); - if (enable_debug) + object_links<L> right_link + = primitive::link::with_single_right_link_dmax_ratio( + components, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); + + // Debug +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - debug::save_linked_bboxes_image(processed_image, left_link, right_link, - literal::blue, - literal::cyan, - literal::yellow, - literal::green, - anchor::MassCenter, - scribo::make::debug_filename("object_links.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + debug::linked_bboxes_image(processed_image, + left_link, + right_link, + literal::blue, + literal::cyan, + literal::yellow, + literal::green, + anchor::MassCenter), + "object_links"); } +# endif // ! SCRIBO_NDEBUG // Validating left and right links. @@ -309,16 +333,20 @@ namespace scribo = filter::object_links_bbox_h_ratio(merged_links, 2.5f); - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { mln_ch_value(I,value::rgb8) hratio_decision_image = scribo::debug::decision_image(processed_image, merged_links, hratio_filtered_links, anchor::MassCenter); - mln::io::ppm::save(hratio_decision_image, - scribo::make::debug_filename("hratio_links_decision_image.ppm")); + // Debug + debug::logger().log_image(debug::AuxiliaryResults, + hratio_decision_image, + "hratio_links_decision_image"); } +# endif // ! SCRIBO_NDEBUG on_progress(); @@ -336,28 +364,35 @@ namespace scribo //===== DEBUG ===== - - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { // Bboxes image. - scribo::debug::save_bboxes_image(processed_image, lines, - scribo::make::debug_filename("step1_bboxes.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_image(processed_image, lines), + "step1_bboxes"); // Bboxes enlarged - mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines), - scribo::make::debug_filename("step1_bboxes_enlarged.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_enlarged_image(processed_image, lines), + "step1_bboxes_enlarged"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines), - scribo::make::debug_filename("step1_looks_like_a_text_line.ppm")); - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(processed_image, lines), + "step1_looks_like_a_text_line"); // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines), - scribo::make::debug_filename("step1_x_height.ppm")); - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(processed_image, lines), + "step1_x_height"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== @@ -366,23 +401,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines), - scribo::make::debug_filename("step2_x_height.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(processed_image, lines), + "step2_x_height"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines), - scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(processed_image, lines), + "step2_looks_like_a_text_line"); // Bboxes image. - scribo::debug::save_bboxes_image(processed_image, lines, - scribo::make::debug_filename("step2_bboxes.ppm")); - - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_image(processed_image, lines), + "step2_bboxes"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -404,20 +445,25 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); + image2d<value::rgb8> + debug = data::convert(value::rgb8(), original_image); for_all_lines(l, lines) { if (! lines(l).is_textline()) continue; mln::draw::box(debug, lines(l).bbox(), literal::blue); - mln::draw::line(debug, lines(l).bbox().pcenter(), lines(llinks(l)).bbox().pcenter(), literal::green); + mln::draw::line(debug, lines(l).bbox().pcenter(), + lines(llinks(l)).bbox().pcenter(), literal::green); } - mln::io::ppm::save(debug, scribo::make::debug_filename("links_raw.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + debug, "links_raw"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -428,22 +474,26 @@ namespace scribo llinks = scribo::filter::line_links_x_height(llinks); //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); + image2d<value::rgb8> + debug = data::convert(value::rgb8(), original_image); for_all_links(i, llinks) if (llinks(i) && llinks(i) != i) mln::draw::line(debug, lines(i).bbox().pcenter(), lines(llinks(i)).bbox().pcenter(), literal::red); - mln::io::ppm::save(debug, scribo::make::debug_filename("links.ppm")); - + debug::logger().log_image(debug::AuxiliaryResults, + debug, "links"); for (unsigned i = 1; i < llinks.nelements(); ++i) llinks(i) = scribo::make::internal::find_root(llinks, i); debug = data::convert(value::rgb8(), original_image); - mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements()); + mln::util::array<accu::shape::bbox<point2d> > + nbbox(llinks.nelements()); + for_all_lines(i, lines) { if (! lines(i).is_textline()) @@ -464,8 +514,10 @@ namespace scribo mln::draw::box(debug, b, literal::green); } - mln::io::ppm::save(debug, scribo::make::debug_filename("par.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + debug, "par"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -482,7 +534,7 @@ namespace scribo // Extract other Elements on_new_progress_label("Extracting Elements"); component_set<L> - elements = scribo::primitive::extract::non_text(doc, original_image); + elements = scribo::primitive::extract::non_text(doc, 3); on_progress(); diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh index 16e981d..62074f0 100644 --- a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh @@ -27,8 +27,6 @@ #ifndef SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH # define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH -# include <mln/io/ppm/save.hh> - # include <scribo/core/def/lbl_type.hh> # include <scribo/primitive/extract/components.hh> @@ -54,8 +52,10 @@ # include <scribo/make/debug_filename.hh> -# include <scribo/debug/save_bboxes_image.hh> -# include <scribo/debug/save_linked_bboxes_image.hh> +# include <scribo/debug/logger.hh> +# include <scribo/debug/decision_image.hh> +# include <scribo/debug/bboxes_image.hh> +# include <scribo/debug/linked_bboxes_image.hh> # include <scribo/debug/bboxes_enlarged_image.hh> # include <scribo/debug/mean_and_base_lines_image.hh> # include <scribo/debug/looks_like_a_text_line_image.hh> @@ -77,7 +77,7 @@ namespace scribo struct text_in_doc_functor : public Toolchain_Functor { - typedef value::label<30> V; + typedef scribo::def::lbl_type V; typedef mln_ch_value(I,V) L; text_in_doc_functor(); @@ -97,7 +97,6 @@ namespace scribo bool enable_denoising; bool enable_line_seps; bool enable_whitespace_seps; - bool enable_debug; //============ // Parameters @@ -118,7 +117,6 @@ namespace scribo : enable_denoising(true), enable_line_seps(true), enable_whitespace_seps(true), - enable_debug(false), ocr_language("eng") { } @@ -164,19 +162,19 @@ namespace scribo on_progress(); } - if (enable_debug) + if (debug::logger().is_enabled()) { if (enable_whitespace_seps) - mln::io::pbm::save(whitespaces, - scribo::make::debug_filename("whitespaces.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + whitespaces, "whitespaces"); if (enable_line_seps) { - mln::io::pbm::save(separators, - scribo::make::debug_filename("vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + separators, "vseparators"); - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("input_wo_vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "input_wo_vseparators"); } } @@ -187,9 +185,9 @@ namespace scribo input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); - if (enable_debug) - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("denoised.pbm")); + if (debug::logger().is_enabled()) + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "denoised"); on_progress(); } @@ -210,9 +208,9 @@ namespace scribo if (enable_whitespace_seps) components.add_separators(whitespaces); - if (enable_debug) - mln::io::pbm::save(components.separators(), - scribo::make::debug_filename("all_separators.pbm")); + if (debug::logger().is_enabled()) + debug::logger().log_image(debug::AuxiliaryResults, + components.separators(), "all_separators"); on_new_progress_label("Filtering components"); @@ -234,15 +232,19 @@ namespace scribo primitive::link::internal::dmax_width_and_height(1), anchor::MassCenter); - if (enable_debug) + if (debug::logger().is_enabled()) { - debug::save_linked_bboxes_image(input, left_link, right_link, - literal::blue, - literal::cyan, - literal::yellow, - literal::green, - anchor::MassCenter, - scribo::make::debug_filename("object_links.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + debug::linked_bboxes_image(input, + left_link, + right_link, + literal::blue, + literal::cyan, + literal::yellow, + literal::green, + anchor::MassCenter), + "object_links"); } @@ -261,15 +263,16 @@ namespace scribo = filter::object_links_bbox_h_ratio(merged_links, 2.5f); - if (enable_debug) + if (debug::logger().is_enabled()) { mln_ch_value(I,value::rgb8) hratio_decision_image = scribo::debug::decision_image(input, merged_links, hratio_filtered_links, anchor::MassCenter); - io::ppm::save(hratio_decision_image, - scribo::make::debug_filename("hratio_links_decision_image.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + hratio_decision_image, + "hratio_links_decision_image"); } on_progress(); @@ -289,25 +292,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) + if (debug::logger().is_enabled()) { // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, - scribo::make::debug_filename("step1_bboxes.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_image(input, lines), + "step1_bboxes"); // Bboxes enlarged - mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines), - scribo::make::debug_filename("step1_bboxes_enlarged.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_enlarged_image(input, lines), + "step1_bboxes_enlarged"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines), - scribo::make::debug_filename("step1_looks_like_a_text_line.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(input, lines), + "step1_looks_like_a_text_line"); // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines), - scribo::make::debug_filename("step1_x_height.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(input, lines), + "step1_x_height"); } //===== END OF DEBUG ===== @@ -320,27 +327,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) + if (debug::logger().is_enabled()) { // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines), - scribo::make::debug_filename("step2_x_height.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(input, lines), + "step2_x_height"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines), - scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(input, lines), + "step2_looks_like_a_text_line"); // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, - scribo::make::debug_filename("step2_bboxes.ppm")); - + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_image(input, lines), + "step2_bboxes"); } - if (enable_debug) + if (debug::logger().is_enabled()) { std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str()); diff --git a/scribo/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/scribo/toolchain/nepomuk/text_extraction.hh index 6def090..51d5ca8 100644 --- a/scribo/scribo/toolchain/nepomuk/text_extraction.hh +++ b/scribo/scribo/toolchain/nepomuk/text_extraction.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -121,8 +122,7 @@ namespace scribo // Run document toolchain. lines_bg = scribo::toolchain::text_in_doc(input_bin, true, - language.toUtf8().data(), - false); + language.toUtf8().data()); // Negate document. logical::not_inplace(input_bin); @@ -130,8 +130,7 @@ namespace scribo // Run document toolchain. lines_fg = scribo::toolchain::text_in_doc(input_bin, true, - language.toUtf8().data(), - false); + language.toUtf8().data()); } diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh index e6ba69e..9f20b39 100644 --- a/scribo/scribo/toolchain/text_in_doc.hh +++ b/scribo/scribo/toolchain/text_in_doc.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -47,8 +47,7 @@ namespace scribo text_in_doc(const Image<I>& input, bool denoise, const std::string& language = std::string("eng"), bool find_line_seps = true, - bool find_whitespace_seps = true, - bool debug = false); + bool find_whitespace_seps = true); # ifndef MLN_INCLUDE_ONLY @@ -59,14 +58,12 @@ namespace scribo text_in_doc(const Image<I>& input, bool denoise, const std::string& language = std::string("eng"), bool find_line_seps = true, - bool find_whitespace_seps = true, - bool debug = false) + bool find_whitespace_seps = true) { internal::text_in_doc_functor<I> f; f.enable_denoising = denoise; f.enable_line_seps = find_line_seps; f.enable_whitespace_seps = find_whitespace_seps; - f.enable_debug = debug; f.ocr_language = language; line_set<mln_ch_value(I, def::lbl_type)> lines = f(input); diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc index d8d4e52..81ec4fb 100644 --- a/scribo/src/content_in_doc.cc +++ b/scribo/src/content_in_doc.cc @@ -40,8 +40,7 @@ #include <scribo/core/document.hh> #include <scribo/debug/usage.hh> - -#include <scribo/make/debug_filename.hh> +#include <scribo/debug/logger.hh> #include <scribo/preprocessing/crop_without_localization.hh> #include <scribo/preprocessing/crop.hh> @@ -79,13 +78,12 @@ int main(int argc, char* argv[]) "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] [language] [find_lines] [find_whitespaces] [K] [debug_dir]", args_desc); - bool debug = false; - // Enable debug output. if (argc == 9 || argc == 13) { + scribo::debug::logger().set_filename_prefix(argv[argc - 1]); + scribo::debug::logger().set_level(scribo::debug::All); scribo::make::internal::debug_filename_prefix = argv[argc - 1]; - debug = true; } trace::entering("main"); @@ -109,7 +107,6 @@ int main(int argc, char* argv[]) std::cout << "Using K = " << K << std::endl; } - image2d<bool> tmp_fg; input_preproc = toolchain::text_in_doc_preprocess(input, false, K); } @@ -130,9 +127,8 @@ int main(int argc, char* argv[]) input_preproc = preprocessing::crop_without_localization(input_preproc, roi); crop_shift = point2d(minr, minc); - if (debug) - mln::io::pbm::save(input_preproc, - scribo::make::debug_filename("input_preproc_cropped.pbm")); + scribo::debug::logger().log_image(scribo::debug::Results, input_preproc, + "input_preproc_cropped.pbm"); } bool denoise = (argc > 3 && atoi(argv[3]) != 0); @@ -159,7 +155,7 @@ int main(int argc, char* argv[]) << " ocr_language = " << language << " | find_lines_seps = " << find_line_seps << " | find_whitespace_seps = " << find_whitespace_seps - << " | debug = " << debug + << " | debug = " << scribo::debug::logger().is_enabled() << std::endl; // Run document toolchain. @@ -167,11 +163,12 @@ int main(int argc, char* argv[]) // Text std::cout << "Analysing document..." << std::endl; document<L> - doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, language, + doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, find_line_seps, find_whitespace_seps, - debug); + !language.empty(), language); // Saving results + std::cout << "Saving results..." << std::endl; scribo::io::xml::save(doc, argv[2], scribo::io::xml::PageExtended); scribo::io::xml::save(doc, "page.xml", scribo::io::xml::Page); scribo::io::xml::save(doc, "full.xml", scribo::io::xml::Full); diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc index 2726ead..42b7d88 100644 --- a/scribo/src/pbm_text_in_doc.cc +++ b/scribo/src/pbm_text_in_doc.cc @@ -45,8 +45,6 @@ #include <scribo/debug/usage.hh> -#include <scribo/make/debug_filename.hh> - #include <scribo/preprocessing/crop_without_localization.hh> #include <scribo/io/text_boxes/save.hh> @@ -83,13 +81,12 @@ int main(int argc, char* argv[]) "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <language> <find_lines> <find_whitespaces> <debug_dir>", args_desc); - bool debug = false; - // Enable debug output. if (argc == 8 || argc == 12) { + scribo::debug::logger().set_filename_prefix(argv[argc - 1]); + scribo::debug::logger().set_level(scribo::debug::All); scribo::make::internal::debug_filename_prefix = argv[argc - 1]; - debug = true; } trace::entering("main"); @@ -116,9 +113,8 @@ int main(int argc, char* argv[]) input = preprocessing::crop_without_localization(input, roi); crop_shift = point2d(minr, minc); - if (debug) - mln::io::pbm::save(input, - scribo::make::debug_filename("input_cropped.pbm")); + scribo::debug::logger().log_image(scribo::debug::Results, input, + "input_cropped.pbm"); } bool denoise = (argc > 3 && atoi(argv[3]) != 0); @@ -146,14 +142,14 @@ int main(int argc, char* argv[]) << " ocr language = " << language << " | find_lines_seps = " << find_line_seps << " | find_whitespace_seps = " << find_whitespace_seps - << " | debug = " << debug + << " | debug = " << scribo::debug::logger().is_enabled() << std::endl; // Run document toolchain. line_set<L> lines = scribo::toolchain::text_in_doc(input, denoise, language, find_line_seps, - find_whitespace_seps, debug); + find_whitespace_seps); scribo::document<L> doc; doc.set_filename(argv[1]); diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc index d50cc73..177047c 100644 --- a/scribo/src/primitive/extract/separators_nonvisible.cc +++ b/scribo/src/primitive/extract/separators_nonvisible.cc @@ -34,6 +34,7 @@ const char *args_desc[][2] = { { "input.pbm", "A binary image." }, { "output.pbm", "Output image." }, + { "enable_debug", "0 or 1 (default 0)" }, {0, 0} }; @@ -43,10 +44,10 @@ int main(int argc, char *argv[]) using namespace mln; using namespace scribo; - if (argc != 3) + if (argc != 3 && argc != 4) return scribo::debug::usage(argv, "Extract non visible separators (whitespaces)", - "input.pbm output.pbm", + "input.pbm output.pbm [enable_debug]", args_desc); trace::entering("main"); @@ -54,6 +55,9 @@ int main(int argc, char *argv[]) image2d<bool> input; io::pbm::load(input, argv[1]); + if (argc > 3 && atoi(argv[3])) + scribo::debug::logger().set_level(scribo::debug::All); + io::pbm::save(primitive::extract::separators_nonvisible(input), argv[2]); trace::exiting("main"); -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-800-g500be97 Introduce a logger class.
by Guillaume Lazzara
* scribo/debug/logger.hh: New. * scribo/toolchain/internal/content_in_doc_functor.hh, * scribo/toolchain/internal/text_in_doc_functor.hh, * scribo/toolchain/nepomuk/text_extraction.hh, * scribo/toolchain/text_in_doc.hh, * src/content_in_doc.cc, * src/pbm_text_in_doc.cc, * src/primitive/extract/separators_nonvisible.cc Make use of that class for saving debug images. --- scribo/ChangeLog | 15 ++ scribo/scribo/toolchain/content_in_doc.hh | 10 +- .../toolchain/internal/content_in_doc_functor.hh | 202 ++++++++++++------- .../toolchain/internal/text_in_doc_functor.hh | 107 ++++++----- scribo/scribo/toolchain/nepomuk/text_extraction.hh | 9 +- scribo/scribo/toolchain/text_in_doc.hh | 11 +- scribo/src/content_in_doc.cc | 21 +-- scribo/src/pbm_text_in_doc.cc | 16 +- .../src/primitive/extract/separators_nonvisible.cc | 8 +- 9 files changed, 234 insertions(+), 165 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 50c49e7..bd7b036 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -4,6 +4,21 @@ * scribo/debug/logger.hh: New. + * scribo/toolchain/internal/content_in_doc_functor.hh, + * scribo/toolchain/internal/text_in_doc_functor.hh, + * scribo/toolchain/nepomuk/text_extraction.hh, + * scribo/toolchain/text_in_doc.hh, + * src/content_in_doc.cc, + * src/pbm_text_in_doc.cc, + * src/primitive/extract/separators_nonvisible.cc Make use of that + class for saving debug images. + +2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr> + + Introduce a logger class. + + * scribo/debug/logger.hh: New. + 2011-03-14 Guillaume Lazzara <z(a)lrde.epita.fr> Introduce new anchors. diff --git a/scribo/scribo/toolchain/content_in_doc.hh b/scribo/scribo/toolchain/content_in_doc.hh index f2938d9..4469afa 100644 --- a/scribo/scribo/toolchain/content_in_doc.hh +++ b/scribo/scribo/toolchain/content_in_doc.hh @@ -45,10 +45,10 @@ namespace scribo document<mln_ch_value(I, def::lbl_type)> content_in_doc(const Image<I>& input, const Image<J>& input_preproc, bool denoise, - const std::string& language = std::string("eng"), bool find_line_seps = true, bool find_whitespace_seps = true, - bool debug = false); + bool enable_ocr = true, + const std::string& language = std::string("eng")); # ifndef MLN_INCLUDE_ONLY @@ -58,10 +58,10 @@ namespace scribo document<mln_ch_value(I, def::lbl_type)> content_in_doc(const Image<I>& input, const Image<J>& input_preproc, bool denoise, - const std::string& language = std::string("eng"), bool find_line_seps = true, bool find_whitespace_seps = true, - bool debug = false) + bool enable_ocr = true, + const std::string& language = std::string("eng")) { mln_precondition(input.is_valid()); mln_precondition(input_preproc.is_valid()); @@ -70,8 +70,8 @@ namespace scribo f.enable_denoising = denoise; f.enable_line_seps = find_line_seps; f.enable_whitespace_seps = find_whitespace_seps; - f.enable_debug = debug; f.ocr_language = language; + f.enable_ocr = enable_ocr; document<mln_ch_value(I, def::lbl_type)> doc = f(input, input_preproc); diff --git a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh index 3e6668f..624a54e 100644 --- a/scribo/scribo/toolchain/internal/content_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/content_in_doc_functor.hh @@ -27,8 +27,6 @@ #ifndef SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH # define SCRIBO_TOOLCHAIN_INTERNAL_CONTENT_IN_DOC_FUNCTOR_HH -# include <mln/io/ppm/save.hh> - # include <scribo/core/def/lbl_type.hh> # include <scribo/core/document.hh> # include <scribo/core/line_set.hh> @@ -37,6 +35,8 @@ # include <scribo/primitive/extract/non_text.hh> # include <scribo/primitive/extract/components.hh> # include <scribo/primitive/extract/separators.hh> +# include <scribo/primitive/extract/vertical_separators.hh> +# include <scribo/primitive/extract/horizontal_separators.hh> # include <scribo/primitive/extract/separators_nonvisible.hh> # include <scribo/primitive/identify.hh> @@ -62,8 +62,9 @@ # include <scribo/make/debug_filename.hh> -# include <scribo/debug/save_bboxes_image.hh> -# include <scribo/debug/save_linked_bboxes_image.hh> +# include <scribo/debug/decision_image.hh> +# include <scribo/debug/bboxes_image.hh> +# include <scribo/debug/linked_bboxes_image.hh> # include <scribo/debug/bboxes_enlarged_image.hh> # include <scribo/debug/mean_and_base_lines_image.hh> # include <scribo/debug/looks_like_a_text_line_image.hh> @@ -87,7 +88,7 @@ namespace scribo struct content_in_doc_functor : public Toolchain_Functor { - typedef value::label<30> V; + typedef scribo::def::lbl_type V; typedef mln_ch_value(I,V) L; content_in_doc_functor(const char *doc_filename); @@ -112,7 +113,6 @@ namespace scribo bool enable_line_seps; bool enable_whitespace_seps; bool enable_ocr; - bool enable_debug; bool save_doc_as_xml; scribo::io::xml::Format xml_format; @@ -138,7 +138,6 @@ namespace scribo enable_line_seps(true), enable_whitespace_seps(true), enable_ocr(true), - enable_debug(false), save_doc_as_xml(false), xml_format(scribo::io::xml::PageExtended), ocr_language("eng"), @@ -209,21 +208,30 @@ namespace scribo on_progress(); } - if (enable_debug) + + // Debug +# ifndef SCRIBO_NDEBUG + if (enable_whitespace_seps) + debug::logger().log_image(debug::AuxiliaryResults, + whitespaces, "whitespaces"); + + // Debug + if (enable_line_seps) { - if (enable_whitespace_seps) - mln::io::pbm::save(whitespaces, - scribo::make::debug_filename("whitespaces.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + doc.vline_seps(), + "vseparators"); - if (enable_line_seps) - { - mln::io::pbm::save(separators, - scribo::make::debug_filename("vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + doc.hline_seps(), + "hseparators"); - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("input_wo_vseparators.pbm")); - } + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, + "input_wo_separators"); } +# endif // ! SCRIBO_NDEBUG + // Denoise if (enable_denoising) @@ -232,9 +240,11 @@ namespace scribo input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); - if (enable_debug) - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("denoised.pbm")); + // Debug +# ifndef SCRIBO_NDEBUG + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "denoised"); +# endif // ! SCRIBO_NDEBUG on_progress(); } @@ -244,7 +254,8 @@ namespace scribo V ncomponents; component_set<L> - components = scribo::primitive::extract::components(input_cleaned, c8(), + components = scribo::primitive::extract::components(input_cleaned, + c8(), ncomponents); on_progress(); @@ -258,9 +269,12 @@ namespace scribo doc.set_whitespace_separators(whitespaces); } - if (enable_debug) - mln::io::pbm::save(components.separators(), - scribo::make::debug_filename("all_separators.pbm")); + // Debug +# ifndef SCRIBO_NDEBUG + debug::logger().log_image(debug::AuxiliaryResults, + components.separators(), + "all_separators"); +# endif // ! SCRIBO_NDEBUG on_new_progress_label("Filtering components"); @@ -274,24 +288,34 @@ namespace scribo on_new_progress_label("Linking objects..."); object_links<L> left_link - = primitive::link::with_single_left_link_dmax_ratio(components, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); - object_links<L> right_link - = primitive::link::with_single_right_link_dmax_ratio(components, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); + = primitive::link::with_single_left_link_dmax_ratio( + components, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); - if (enable_debug) + object_links<L> right_link + = primitive::link::with_single_right_link_dmax_ratio( + components, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); + + // Debug +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - debug::save_linked_bboxes_image(processed_image, left_link, right_link, - literal::blue, - literal::cyan, - literal::yellow, - literal::green, - anchor::MassCenter, - scribo::make::debug_filename("object_links.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + debug::linked_bboxes_image(processed_image, + left_link, + right_link, + literal::blue, + literal::cyan, + literal::yellow, + literal::green, + anchor::MassCenter), + "object_links"); } +# endif // ! SCRIBO_NDEBUG // Validating left and right links. @@ -309,16 +333,20 @@ namespace scribo = filter::object_links_bbox_h_ratio(merged_links, 2.5f); - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { mln_ch_value(I,value::rgb8) hratio_decision_image = scribo::debug::decision_image(processed_image, merged_links, hratio_filtered_links, anchor::MassCenter); - mln::io::ppm::save(hratio_decision_image, - scribo::make::debug_filename("hratio_links_decision_image.ppm")); + // Debug + debug::logger().log_image(debug::AuxiliaryResults, + hratio_decision_image, + "hratio_links_decision_image"); } +# endif // ! SCRIBO_NDEBUG on_progress(); @@ -336,28 +364,35 @@ namespace scribo //===== DEBUG ===== - - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { // Bboxes image. - scribo::debug::save_bboxes_image(processed_image, lines, - scribo::make::debug_filename("step1_bboxes.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_image(processed_image, lines), + "step1_bboxes"); // Bboxes enlarged - mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(processed_image, lines), - scribo::make::debug_filename("step1_bboxes_enlarged.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_enlarged_image(processed_image, lines), + "step1_bboxes_enlarged"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines), - scribo::make::debug_filename("step1_looks_like_a_text_line.ppm")); - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(processed_image, lines), + "step1_looks_like_a_text_line"); // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines), - scribo::make::debug_filename("step1_x_height.ppm")); - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(processed_image, lines), + "step1_x_height"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== @@ -366,23 +401,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(processed_image, lines), - scribo::make::debug_filename("step2_x_height.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(processed_image, lines), + "step2_x_height"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(processed_image, lines), - scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(processed_image, lines), + "step2_looks_like_a_text_line"); // Bboxes image. - scribo::debug::save_bboxes_image(processed_image, lines, - scribo::make::debug_filename("step2_bboxes.ppm")); - - + debug::logger().log_image( + debug::AuxiliaryResults, + scribo::debug::bboxes_image(processed_image, lines), + "step2_bboxes"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -404,20 +445,25 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); + image2d<value::rgb8> + debug = data::convert(value::rgb8(), original_image); for_all_lines(l, lines) { if (! lines(l).is_textline()) continue; mln::draw::box(debug, lines(l).bbox(), literal::blue); - mln::draw::line(debug, lines(l).bbox().pcenter(), lines(llinks(l)).bbox().pcenter(), literal::green); + mln::draw::line(debug, lines(l).bbox().pcenter(), + lines(llinks(l)).bbox().pcenter(), literal::green); } - mln::io::ppm::save(debug, scribo::make::debug_filename("links_raw.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + debug, "links_raw"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -428,22 +474,26 @@ namespace scribo llinks = scribo::filter::line_links_x_height(llinks); //===== DEBUG ===== - if (enable_debug) +# ifndef SCRIBO_NDEBUG + if (debug::logger().is_enabled()) { - image2d<value::rgb8> debug = data::convert(value::rgb8(), original_image); + image2d<value::rgb8> + debug = data::convert(value::rgb8(), original_image); for_all_links(i, llinks) if (llinks(i) && llinks(i) != i) mln::draw::line(debug, lines(i).bbox().pcenter(), lines(llinks(i)).bbox().pcenter(), literal::red); - mln::io::ppm::save(debug, scribo::make::debug_filename("links.ppm")); - + debug::logger().log_image(debug::AuxiliaryResults, + debug, "links"); for (unsigned i = 1; i < llinks.nelements(); ++i) llinks(i) = scribo::make::internal::find_root(llinks, i); debug = data::convert(value::rgb8(), original_image); - mln::util::array<accu::shape::bbox<point2d> > nbbox(llinks.nelements()); + mln::util::array<accu::shape::bbox<point2d> > + nbbox(llinks.nelements()); + for_all_lines(i, lines) { if (! lines(i).is_textline()) @@ -464,8 +514,10 @@ namespace scribo mln::draw::box(debug, b, literal::green); } - mln::io::ppm::save(debug, scribo::make::debug_filename("par.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + debug, "par"); } +# endif // ! SCRIBO_NDEBUG //===== END OF DEBUG ===== on_progress(); @@ -482,7 +534,7 @@ namespace scribo // Extract other Elements on_new_progress_label("Extracting Elements"); component_set<L> - elements = scribo::primitive::extract::non_text(doc, original_image); + elements = scribo::primitive::extract::non_text(doc, 3); on_progress(); diff --git a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh index 16e981d..62074f0 100644 --- a/scribo/scribo/toolchain/internal/text_in_doc_functor.hh +++ b/scribo/scribo/toolchain/internal/text_in_doc_functor.hh @@ -27,8 +27,6 @@ #ifndef SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH # define SCRIBO_TOOLCHAIN_INTERNAL_TEXT_IN_DOC_FUNCTOR_HH -# include <mln/io/ppm/save.hh> - # include <scribo/core/def/lbl_type.hh> # include <scribo/primitive/extract/components.hh> @@ -54,8 +52,10 @@ # include <scribo/make/debug_filename.hh> -# include <scribo/debug/save_bboxes_image.hh> -# include <scribo/debug/save_linked_bboxes_image.hh> +# include <scribo/debug/logger.hh> +# include <scribo/debug/decision_image.hh> +# include <scribo/debug/bboxes_image.hh> +# include <scribo/debug/linked_bboxes_image.hh> # include <scribo/debug/bboxes_enlarged_image.hh> # include <scribo/debug/mean_and_base_lines_image.hh> # include <scribo/debug/looks_like_a_text_line_image.hh> @@ -77,7 +77,7 @@ namespace scribo struct text_in_doc_functor : public Toolchain_Functor { - typedef value::label<30> V; + typedef scribo::def::lbl_type V; typedef mln_ch_value(I,V) L; text_in_doc_functor(); @@ -97,7 +97,6 @@ namespace scribo bool enable_denoising; bool enable_line_seps; bool enable_whitespace_seps; - bool enable_debug; //============ // Parameters @@ -118,7 +117,6 @@ namespace scribo : enable_denoising(true), enable_line_seps(true), enable_whitespace_seps(true), - enable_debug(false), ocr_language("eng") { } @@ -164,19 +162,19 @@ namespace scribo on_progress(); } - if (enable_debug) + if (debug::logger().is_enabled()) { if (enable_whitespace_seps) - mln::io::pbm::save(whitespaces, - scribo::make::debug_filename("whitespaces.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + whitespaces, "whitespaces"); if (enable_line_seps) { - mln::io::pbm::save(separators, - scribo::make::debug_filename("vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + separators, "vseparators"); - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("input_wo_vseparators.pbm")); + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "input_wo_vseparators"); } } @@ -187,9 +185,9 @@ namespace scribo input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); - if (enable_debug) - mln::io::pbm::save(input_cleaned, - scribo::make::debug_filename("denoised.pbm")); + if (debug::logger().is_enabled()) + debug::logger().log_image(debug::AuxiliaryResults, + input_cleaned, "denoised"); on_progress(); } @@ -210,9 +208,9 @@ namespace scribo if (enable_whitespace_seps) components.add_separators(whitespaces); - if (enable_debug) - mln::io::pbm::save(components.separators(), - scribo::make::debug_filename("all_separators.pbm")); + if (debug::logger().is_enabled()) + debug::logger().log_image(debug::AuxiliaryResults, + components.separators(), "all_separators"); on_new_progress_label("Filtering components"); @@ -234,15 +232,19 @@ namespace scribo primitive::link::internal::dmax_width_and_height(1), anchor::MassCenter); - if (enable_debug) + if (debug::logger().is_enabled()) { - debug::save_linked_bboxes_image(input, left_link, right_link, - literal::blue, - literal::cyan, - literal::yellow, - literal::green, - anchor::MassCenter, - scribo::make::debug_filename("object_links.ppm")); + debug::logger().log_image( + debug::AuxiliaryResults, + debug::linked_bboxes_image(input, + left_link, + right_link, + literal::blue, + literal::cyan, + literal::yellow, + literal::green, + anchor::MassCenter), + "object_links"); } @@ -261,15 +263,16 @@ namespace scribo = filter::object_links_bbox_h_ratio(merged_links, 2.5f); - if (enable_debug) + if (debug::logger().is_enabled()) { mln_ch_value(I,value::rgb8) hratio_decision_image = scribo::debug::decision_image(input, merged_links, hratio_filtered_links, anchor::MassCenter); - io::ppm::save(hratio_decision_image, - scribo::make::debug_filename("hratio_links_decision_image.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + hratio_decision_image, + "hratio_links_decision_image"); } on_progress(); @@ -289,25 +292,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) + if (debug::logger().is_enabled()) { // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, - scribo::make::debug_filename("step1_bboxes.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_image(input, lines), + "step1_bboxes"); // Bboxes enlarged - mln::io::ppm::save(scribo::debug::bboxes_enlarged_image(input, lines), - scribo::make::debug_filename("step1_bboxes_enlarged.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_enlarged_image(input, lines), + "step1_bboxes_enlarged"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines), - scribo::make::debug_filename("step1_looks_like_a_text_line.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(input, lines), + "step1_looks_like_a_text_line"); // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines), - scribo::make::debug_filename("step1_x_height.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(input, lines), + "step1_x_height"); } //===== END OF DEBUG ===== @@ -320,27 +327,29 @@ namespace scribo //===== DEBUG ===== - if (enable_debug) + if (debug::logger().is_enabled()) { // mean and base lines. - mln::io::ppm::save(scribo::debug::mean_and_base_lines_image(input, lines), - scribo::make::debug_filename("step2_x_height.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::mean_and_base_lines_image(input, lines), + "step2_x_height"); // Looks like a text line - mln::io::ppm::save(scribo::debug::looks_like_a_text_line_image(input, lines), - scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::looks_like_a_text_line_image(input, lines), + "step2_looks_like_a_text_line"); // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, - scribo::make::debug_filename("step2_bboxes.ppm")); - + debug::logger().log_image(debug::AuxiliaryResults, + scribo::debug::bboxes_image(input, lines), + "step2_bboxes"); } - if (enable_debug) + if (debug::logger().is_enabled()) { std::ofstream file(scribo::make::debug_filename("step2_bboxes_100p.txt").c_str()); diff --git a/scribo/scribo/toolchain/nepomuk/text_extraction.hh b/scribo/scribo/toolchain/nepomuk/text_extraction.hh index 6def090..51d5ca8 100644 --- a/scribo/scribo/toolchain/nepomuk/text_extraction.hh +++ b/scribo/scribo/toolchain/nepomuk/text_extraction.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -121,8 +122,7 @@ namespace scribo // Run document toolchain. lines_bg = scribo::toolchain::text_in_doc(input_bin, true, - language.toUtf8().data(), - false); + language.toUtf8().data()); // Negate document. logical::not_inplace(input_bin); @@ -130,8 +130,7 @@ namespace scribo // Run document toolchain. lines_fg = scribo::toolchain::text_in_doc(input_bin, true, - language.toUtf8().data(), - false); + language.toUtf8().data()); } diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh index e6ba69e..9f20b39 100644 --- a/scribo/scribo/toolchain/text_in_doc.hh +++ b/scribo/scribo/toolchain/text_in_doc.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -47,8 +47,7 @@ namespace scribo text_in_doc(const Image<I>& input, bool denoise, const std::string& language = std::string("eng"), bool find_line_seps = true, - bool find_whitespace_seps = true, - bool debug = false); + bool find_whitespace_seps = true); # ifndef MLN_INCLUDE_ONLY @@ -59,14 +58,12 @@ namespace scribo text_in_doc(const Image<I>& input, bool denoise, const std::string& language = std::string("eng"), bool find_line_seps = true, - bool find_whitespace_seps = true, - bool debug = false) + bool find_whitespace_seps = true) { internal::text_in_doc_functor<I> f; f.enable_denoising = denoise; f.enable_line_seps = find_line_seps; f.enable_whitespace_seps = find_whitespace_seps; - f.enable_debug = debug; f.ocr_language = language; line_set<mln_ch_value(I, def::lbl_type)> lines = f(input); diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc index d8d4e52..81ec4fb 100644 --- a/scribo/src/content_in_doc.cc +++ b/scribo/src/content_in_doc.cc @@ -40,8 +40,7 @@ #include <scribo/core/document.hh> #include <scribo/debug/usage.hh> - -#include <scribo/make/debug_filename.hh> +#include <scribo/debug/logger.hh> #include <scribo/preprocessing/crop_without_localization.hh> #include <scribo/preprocessing/crop.hh> @@ -79,13 +78,12 @@ int main(int argc, char* argv[]) "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] [language] [find_lines] [find_whitespaces] [K] [debug_dir]", args_desc); - bool debug = false; - // Enable debug output. if (argc == 9 || argc == 13) { + scribo::debug::logger().set_filename_prefix(argv[argc - 1]); + scribo::debug::logger().set_level(scribo::debug::All); scribo::make::internal::debug_filename_prefix = argv[argc - 1]; - debug = true; } trace::entering("main"); @@ -109,7 +107,6 @@ int main(int argc, char* argv[]) std::cout << "Using K = " << K << std::endl; } - image2d<bool> tmp_fg; input_preproc = toolchain::text_in_doc_preprocess(input, false, K); } @@ -130,9 +127,8 @@ int main(int argc, char* argv[]) input_preproc = preprocessing::crop_without_localization(input_preproc, roi); crop_shift = point2d(minr, minc); - if (debug) - mln::io::pbm::save(input_preproc, - scribo::make::debug_filename("input_preproc_cropped.pbm")); + scribo::debug::logger().log_image(scribo::debug::Results, input_preproc, + "input_preproc_cropped.pbm"); } bool denoise = (argc > 3 && atoi(argv[3]) != 0); @@ -159,7 +155,7 @@ int main(int argc, char* argv[]) << " ocr_language = " << language << " | find_lines_seps = " << find_line_seps << " | find_whitespace_seps = " << find_whitespace_seps - << " | debug = " << debug + << " | debug = " << scribo::debug::logger().is_enabled() << std::endl; // Run document toolchain. @@ -167,11 +163,12 @@ int main(int argc, char* argv[]) // Text std::cout << "Analysing document..." << std::endl; document<L> - doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, language, + doc = scribo::toolchain::content_in_doc(input, input_preproc, denoise, find_line_seps, find_whitespace_seps, - debug); + !language.empty(), language); // Saving results + std::cout << "Saving results..." << std::endl; scribo::io::xml::save(doc, argv[2], scribo::io::xml::PageExtended); scribo::io::xml::save(doc, "page.xml", scribo::io::xml::Page); scribo::io::xml::save(doc, "full.xml", scribo::io::xml::Full); diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc index 2726ead..42b7d88 100644 --- a/scribo/src/pbm_text_in_doc.cc +++ b/scribo/src/pbm_text_in_doc.cc @@ -45,8 +45,6 @@ #include <scribo/debug/usage.hh> -#include <scribo/make/debug_filename.hh> - #include <scribo/preprocessing/crop_without_localization.hh> #include <scribo/io/text_boxes/save.hh> @@ -83,13 +81,12 @@ int main(int argc, char* argv[]) "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <language> <find_lines> <find_whitespaces> <debug_dir>", args_desc); - bool debug = false; - // Enable debug output. if (argc == 8 || argc == 12) { + scribo::debug::logger().set_filename_prefix(argv[argc - 1]); + scribo::debug::logger().set_level(scribo::debug::All); scribo::make::internal::debug_filename_prefix = argv[argc - 1]; - debug = true; } trace::entering("main"); @@ -116,9 +113,8 @@ int main(int argc, char* argv[]) input = preprocessing::crop_without_localization(input, roi); crop_shift = point2d(minr, minc); - if (debug) - mln::io::pbm::save(input, - scribo::make::debug_filename("input_cropped.pbm")); + scribo::debug::logger().log_image(scribo::debug::Results, input, + "input_cropped.pbm"); } bool denoise = (argc > 3 && atoi(argv[3]) != 0); @@ -146,14 +142,14 @@ int main(int argc, char* argv[]) << " ocr language = " << language << " | find_lines_seps = " << find_line_seps << " | find_whitespace_seps = " << find_whitespace_seps - << " | debug = " << debug + << " | debug = " << scribo::debug::logger().is_enabled() << std::endl; // Run document toolchain. line_set<L> lines = scribo::toolchain::text_in_doc(input, denoise, language, find_line_seps, - find_whitespace_seps, debug); + find_whitespace_seps); scribo::document<L> doc; doc.set_filename(argv[1]); diff --git a/scribo/src/primitive/extract/separators_nonvisible.cc b/scribo/src/primitive/extract/separators_nonvisible.cc index d50cc73..177047c 100644 --- a/scribo/src/primitive/extract/separators_nonvisible.cc +++ b/scribo/src/primitive/extract/separators_nonvisible.cc @@ -34,6 +34,7 @@ const char *args_desc[][2] = { { "input.pbm", "A binary image." }, { "output.pbm", "Output image." }, + { "enable_debug", "0 or 1 (default 0)" }, {0, 0} }; @@ -43,10 +44,10 @@ int main(int argc, char *argv[]) using namespace mln; using namespace scribo; - if (argc != 3) + if (argc != 3 && argc != 4) return scribo::debug::usage(argv, "Extract non visible separators (whitespaces)", - "input.pbm output.pbm", + "input.pbm output.pbm [enable_debug]", args_desc); trace::entering("main"); @@ -54,6 +55,9 @@ int main(int argc, char *argv[]) image2d<bool> input; io::pbm::load(input, argv[1]); + if (argc > 3 && atoi(argv[3])) + scribo::debug::logger().set_level(scribo::debug::All); + io::pbm::save(primitive::extract::separators_nonvisible(input), argv[2]); trace::exiting("main"); -- 1.5.6.5
13 years, 9 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
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