* 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