Commit 26c8584d authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Fix many tests in Scribo.

	* all.hh,
	* binarization/all.hh,
	* binarization/internal/first_pass_functor.hh,
	* convert/from_qimage.hh,
	* core/tag/component.hh,
	* core/tag/line.hh,
	* debug/links_decision_image.hh,
	* debug/mean_and_base_lines_image.hh,
	* filter/object_groups_with_holes.hh,
	* io/xml/save.hh,
	* make/all.hh,
	* postprocessing/all.hh,
	* postprocessing/fill_object_holes.hh,
	* preprocessing/all.hh,
	* preprocessing/crop_without_localization.hh,
	* preprocessing/denoise_bg.hh,
	* preprocessing/denoise_fg.hh,
	* preprocessing/deskew.hh,
	* preprocessing/deskew_crop.hh,
	* preprocessing/split_bg_fg.hh,
	* primitive/extract/all.hh,
	* primitive/extract/lines_h_single.hh,
	* primitive/extract/lines_pattern.hh,
	* primitive/extract/lines_v_single.hh,
	* primitive/group/all.hh,
	* primitive/internal/all.hh,
	* primitive/internal/is_link_valid.hh,
	* primitive/link/all.hh,
	* primitive/link/internal/compute_anchor.hh,
	* primitive/link/internal/dmax_functor_base.hh,
	* primitive/regroup/from_single_left_link.hh,
	* primitive/remove/separators.hh,
	* subsampling/bilinear.hh,
	* text/merging.hh,
	* toolchain/nepomuk/text_extraction.hh,
	* upsampling/eagle.hh: Add missing headers in order to fix
	unit-tests.

	* tests/Makefile.am: Disable "table" directory's tests.

	* tests/core/Makefile.am: Remove object_image test.

	* tests/core/object_image.cc: Remove. Deprecated.

	* tests/filter/objects_with_holes.cc,
	* tests/filter/small_and_large_bboxes.cc: Write a real test.

	* tests/unit_test/Makefile.am: Add specific flags for unit-tests
	using tesseract and image magick.
parent 332c9acf
2010-08-09 Guillaume Lazzara <z@lrde.epita.fr>
Fix many tests in Scribo.
* all.hh,
* binarization/all.hh,
* binarization/internal/first_pass_functor.hh,
* convert/from_qimage.hh,
* core/tag/component.hh,
* core/tag/line.hh,
* debug/links_decision_image.hh,
* debug/mean_and_base_lines_image.hh,
* filter/object_groups_with_holes.hh,
* io/xml/save.hh,
* make/all.hh,
* postprocessing/all.hh,
* postprocessing/fill_object_holes.hh,
* preprocessing/all.hh,
* preprocessing/crop_without_localization.hh,
* preprocessing/denoise_bg.hh,
* preprocessing/denoise_fg.hh,
* preprocessing/deskew.hh,
* preprocessing/deskew_crop.hh,
* preprocessing/split_bg_fg.hh,
* primitive/extract/all.hh,
* primitive/extract/lines_h_single.hh,
* primitive/extract/lines_pattern.hh,
* primitive/extract/lines_v_single.hh,
* primitive/group/all.hh,
* primitive/internal/all.hh,
* primitive/internal/is_link_valid.hh,
* primitive/link/all.hh,
* primitive/link/internal/compute_anchor.hh,
* primitive/link/internal/dmax_functor_base.hh,
* primitive/regroup/from_single_left_link.hh,
* primitive/remove/separators.hh,
* subsampling/bilinear.hh,
* text/merging.hh,
* toolchain/nepomuk/text_extraction.hh,
* upsampling/eagle.hh: Add missing headers in order to fix
unit-tests.
* tests/Makefile.am: Disable "table" directory's tests.
* tests/core/Makefile.am: Remove object_image test.
* tests/core/object_image.cc: Remove. Deprecated.
* tests/filter/objects_with_holes.cc,
* tests/filter/small_and_large_bboxes.cc: Write a real test.
* tests/unit_test/Makefile.am: Add specific flags for unit-tests
using tesseract and image magick.
2010-07-21 Roland Levillain <roland@lrde.epita.fr>
Have Tesseract-related parts of Scribo compile again.
......
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
......@@ -37,15 +38,16 @@ namespace scribo
} // end of namespace scribo
# include <scribo/binarization/all.hh>
# include <scribo/core/all.hh>
# include <scribo/debug/all.hh>
# include <scribo/draw/all.hh>
# include <scribo/filter/all.hh>
# include <scribo/make/all.hh>
# include <scribo/postprocessing/all.hh>
# include <scribo/preprocessing/all.hh>
# include <scribo/primitive/all.hh>
# include <scribo/table/all.hh>
//# include <scribo/table/all.hh>
# include <scribo/text/all.hh>
# include <scribo/util/all.hh>
#endif // ! SCRIBO_ALL_HH
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -23,50 +23,33 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#ifndef SCRIBO_BINARIZATION_ALL_HH
# define SCRIBO_BINARIZATION_ALL_HH
#include <mln/core/image/image2d.hh>
#include <mln/make/image.hh>
#include <mln/fun/i2v/array.hh>
/// \file
///
/// Include all headers located in scribo/binarization.
#include <scribo/core/object_image.hh>
#include <mln/debug/println.hh>
int main(int argc, char* argv[])
namespace scribo
{
using namespace mln;
unsigned data[4][4] = { {1, 0, 0, 0},
{0, 0, 2, 0},
{3, 0, 0, 0},
{0, 0, 4, 0} };
typedef image2d<unsigned> I;
I ima = make::image(data);
/// Namespace of binarization routines.
namespace binarization
{
object_image(I) lbl(ima, 4);
} // end of namespace scribo::binarization
fun::i2v::array<unsigned> f(5);
f(0) = 0;
f(1) = 1;
f(2) = 4;
f(3) = 3;
f(4) = 4;
} // end of namespace scribo
// { {1, 0, 0, 0},
// {0, 0, 2, 0},
// {3, 0, 0, 0},
// {0, 0, 2, 0} };
lbl.relabel(f);
# include <scribo/binarization/global_threshold.hh>
# include <scribo/binarization/global_threshold_auto.hh>
mln_assertion(lbl.bbox(1) == make::box2d(0, 0, 0,0));
mln_assertion(lbl.mass_center(1) == point2d(0,0));
# include <scribo/binarization/local_threshold.hh>
mln_assertion(lbl.bbox(2) == make::box2d(1, 2, 3,2));
mln_assertion(lbl.mass_center(2) == point2d(2,2));
# include <scribo/binarization/sauvola.hh>
# include <scribo/binarization/sauvola_ms.hh>
# include <scribo/binarization/sauvola_ms_split.hh>
# include <scribo/binarization/sauvola_threshold_image.hh>
mln_assertion(lbl.bbox(3) == make::box2d(2, 0, 2,0));
mln_assertion(lbl.mass_center(3) == point2d(2,0));
}
#endif // ! SCRIBO_BINARIZATION_ALL_HH
......@@ -26,7 +26,11 @@
#ifndef SCRIBO_BINARIZATION_INTERNAL_FIRST_PASS_FUNCTOR_HH
# define SCRIBO_BINARIZATION_INTERNAL_FIRST_PASS_FUNCTOR_HH
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/extension/fill.hh>
# include <mln/value/int_u8.hh>
# include <mln/data/fill.hh>
# include <scribo/binarization/sauvola_threshold_image.hh>
......@@ -95,7 +99,7 @@ namespace scribo
initialize(debug_k_l, input);
# endif // ! SCRIBO_SAUVOLA_DEBUG
extension::fill(msk, false);
mln::extension::fill(msk, false);
initialize(card, input);
data::fill(card, 1);
......@@ -153,8 +157,6 @@ namespace scribo
void finalize()
{
mln_assertion(! pxl.is_valid());
// std::cout << std::endl << " ------- " << std::endl;
}
};
......
......@@ -35,6 +35,7 @@
# include <QtGui/QImage>
# include <mln/core/image/image2d.hh>
# include <mln/value/qt/rgb32.hh>
# if QT_VERSION < 0x040000
......
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
......@@ -26,6 +27,8 @@
#ifndef SCRIBO_CORE_TAG_COMPONENT_HH
# define SCRIBO_CORE_TAG_COMPONENT_HH
# include <iostream>
/// \file
///
/// \brief Component tags.
......
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
......@@ -26,6 +27,8 @@
#ifndef SCRIBO_CORE_TAG_LINE_HH
# define SCRIBO_CORE_TAG_LINE_HH
# include <iostream>
/// \file
///
/// \brief Line tags.
......
......@@ -35,6 +35,8 @@
# include <mln/data/convert.hh>
# include <mln/value/rgb8.hh>
# include <mln/literal/colors.hh>
# include <mln/draw/box.hh>
# include <mln/draw/line.hh>
# include <scribo/core/object_links.hh>
......
......@@ -37,6 +37,7 @@
# include <mln/literal/colors.hh>
# include <mln/draw/box.hh>
# include <mln/draw/line.hh>
# include <mln/draw/dashed_line.hh>
# include <scribo/core/line_set.hh>
......@@ -96,7 +97,8 @@ namespace scribo
trace::entering("scribo::debug::mean_and_base_lines_image");
mln_precondition(exact(input).is_valid());
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
mln_ch_value(I, value::rgb8)
output = data::convert(value::rgb8(), input);
for_all_lines(l, lines)
{
......
......@@ -33,6 +33,7 @@
# include <sstream>
# include <mln/core/image/image2d.hh>
# include <mln/core/concept/image.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/extend.hh>
......@@ -42,6 +43,7 @@
# include <mln/geom/nrows.hh>
# include <mln/extension/duplicate.hh>
# include <mln/extension/adjust_fill.hh>
# include <mln/draw/box_plain.hh>
# include <mln/util/array.hh>
......@@ -50,8 +52,12 @@
# include <mln/fun/i2v/array.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/component_set.hh>
# include <scribo/core/object_groups.hh>
# include <scribo/primitive/group/apply.hh>
namespace scribo
......@@ -98,7 +104,7 @@ namespace scribo
typedef mln_dpsite(P) D;
const L& lbl = components.labeled_image();
extension::adjust_fill(lbl, 1, 0);
mln::extension::adjust_fill(lbl, 1, 0);
mln_concrete(L) output;
initialize(output, lbl);
......@@ -160,7 +166,7 @@ namespace scribo
neighb2d nbh = c8();
image2d<unsigned> parent, card;
mln_ch_value(L,unsigned) parent, card;
L bboxes_ima;
// Will store the first background component id associated
......
......@@ -30,8 +30,12 @@
///
/// \brief Save text line information as XML.
#include <fstream>
#include <sstream>
# include <fstream>
# include <sstream>
# include <map>
# include <scribo/core/line_set.hh>
namespace scribo
{
......@@ -66,8 +70,8 @@ namespace scribo
namespace internal
{
std::string&
html_markups_replace(std::string& input,
std::string&
html_markups_replace(std::string& input,
std::map<char, std::string>& map)
{
for (unsigned i = 0; i < input.size(); ++i)
......@@ -83,7 +87,7 @@ namespace scribo
}
} // end of namespace scribo::io::xml::internal
template <typename L>
void
save(const std::string& input_name,
......@@ -114,7 +118,7 @@ namespace scribo
{
file << "<pcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16 http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent.xsd\" pcGtsId=\"" << input_name << "\">" << std::endl;
}
file << " <PcMetadata>" << std::endl;
file << " <PcCreator>LRDE</PcCreator>" << std::endl;
file << " <PcCreated/>" << std::endl;
......@@ -190,20 +194,20 @@ namespace scribo
<< " <point x=\"" << lines(l).bbox().pmin().col()
<< "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
<< std::endl
<< " </coords>" << std::endl;
<< " </coords>" << std::endl;
if (lines(l).has_text())
{
std::string tmp = lines(l).text();
tmp = internal::html_markups_replace(tmp, html_map);
file << " <line text=\""
<< tmp
<< "\">" << std::endl;
}
else
file << " <line>" << std::endl;
file << " <coords>" << std::endl
<< " <point x=\"" << lines(l).bbox().pmin().col()
<< "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
......@@ -218,12 +222,12 @@ namespace scribo
<< "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
<< std::endl
<< " </coords>" << std::endl;
file << " </line>" << std::endl;
file << " </paragraph>" << std::endl;
file << " </paragraph>" << std::endl;
}
file << " </text_region>" << std::endl;
}
}
......
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
......@@ -42,7 +43,6 @@ namespace scribo
} // end of namespace scribo
# include <scribo/make/influence_zone_graph.hh>
# include <scribo/make/text.hh>
# include <scribo/make/debug_filename.hh>
......
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef SCRIBO_POSTPROCESSING_ALL_HH
# define SCRIBO_POSTPROCESSING_ALL_HH
/// \file
///
/// Include all headers located in scribo/postprocessing.
namespace scribo
{
/// Namespace of postprocessing routines.
namespace postprocessing
{
} // end of namespace scribo::postprocessing
} // end of namespace scribo
# include <scribo/postprocessing/fill_object_holes.hh>
#endif // ! SCRIBO_POSTPROCESSING_ALL_HH
......@@ -36,7 +36,7 @@
# include <sstream>
# include <mln/core/concept/image.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/extend.hh>
# include <mln/core/image/dmorph/extended.hh>
......@@ -160,7 +160,7 @@ namespace scribo
inline
object_groups<L>
fill_object_holes(const object_groups<L>& groups,
unsigned min_size)
unsigned min_size)
{
trace::entering("scribo::postprocessing::impl::generic::fill_object_holes");
......@@ -178,7 +178,7 @@ namespace scribo
util::array<bool> bg_comps_done(
static_cast<unsigned>(components.nelements()) + 1, false);
fun::i2v::array<bool>
mln::fun::i2v::array<bool>
to_keep(static_cast<unsigned>(components.nelements()) + 1,
false);
......@@ -328,10 +328,11 @@ namespace scribo
{
trace::entering("scribo::postprocessing::fill_object_holes");
const I& input = exact(input_);
mln_precondition(input.is_valid());
mlc_is(mln_value(I), bool)::check();
const I& input = exact(input_);
mln_concrete(I) output = duplicate(input);
typedef value::int_u16 L;
......
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
......@@ -41,6 +42,22 @@ namespace scribo
} // end of namespace scribo
# include <scribo/preprocessing/unskew.hh>
# include <scribo/preprocessing/crop.hh>
# include <scribo/preprocessing/crop_without_localization.hh>
# include <scribo/preprocessing/denoise.hh>
# include <scribo/preprocessing/denoise_fg.hh>
# include <scribo/preprocessing/denoise_bg.hh>
# include <scribo/preprocessing/homogeneous_contrast.hh>
# include <scribo/preprocessing/rotate_90.hh>
# include <scribo/preprocessing/split_bg_fg.hh>
# include <scribo/preprocessing/deskew.hh>
# include <scribo/preprocessing/deskew_crop.hh>
#endif // ! SCRIBO_PREPROCESSING_ALL_HH
......@@ -55,7 +55,8 @@ namespace scribo
*/
template <typename I>
mln_concrete(I)
crop_without_localization(const Image<I>& input, const mln_box(I)& domain);
crop_without_localization(const Image<I>& input,
const mln_box(I)& domain);
# ifndef MLN_INCLUDE_ONLY
......@@ -63,7 +64,8 @@ namespace scribo
template <typename I>
mln_concrete(I)
crop_without_localization(const Image<I>& input, const mln_box(I)& domain)
crop_without_localization(const Image<I>& input,
const mln_box(I)& domain)
{
trace::entering("scribo::preprocessing::crop_without_localization");
mln_assertion(exact(input).is_valid());
......
......@@ -30,7 +30,7 @@
///
/// Denoise image background.
# include <mln/core/concept/image.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/concept/function.hh>
# include <mln/data/transform.hh>
......@@ -113,6 +113,9 @@ namespace scribo
namespace preprocessing
{
using namespace mln;
template <typename I, typename N>
mln_concrete(I)
denoise_bg(const Image<I>& input_, const Neighborhood<N>& nbh_,
......
......@@ -30,10 +30,9 @@
///
/// Denoise image foreground.
# include <mln/core/concept/image.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/concept/function.hh>
# include <mln/data/transform.hh>
# include <mln/accu/math/count.hh>
......@@ -42,8 +41,10 @@
# include <mln/util/array.hh>
# include <mln/fun/i2v/array.hh>
# include <mln/labeling/foreground.hh>
# include <mln/data/transform.hh>
# include <mln/labeling/compute.hh>
# include <mln/labeling/foreground.hh>
# include <scribo/fun/v2b/label_to_bool.hh>
......@@ -73,20 +74,9 @@ namespace scribo
unsigned min_card);
} // end of namespace scribo::preprocessing
} // end of namespace mln
# ifndef MLN_INCLUDE_ONLY
namespace scribo
{
namespace preprocessing
{
template <typename I, typename N>
mln_concrete(I)
denoise_fg(const Image<I>& input_, const Neighborhood<N>& nbh_,
......@@ -99,7 +89,6 @@ namespace scribo
mlc_equal(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
// FIXME:
unsigned nlabels;
image2d<unsigned> lbl = labeling::foreground(input, nbh, nlabels);
......@@ -120,12 +109,10 @@ namespace scribo
return output;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::preprocessing
} // end of namespace mln
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo
# endif // SCRIBO_PREPROCESSING_DENOISE_FG_HH
......@@ -34,9 +34,11 @@
# include <queue>
# include <mln/core/image/image2d.hh>