Commit 853ed715 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add new sample programs.

	* src/debug/Makefile.am: New targets.

	* src/debug/show_groups_bboxes_filtered.cc,
	* src/debug/show_text_lines_wo_seps.cc: New.
parent e94251a9
2011-05-17 Guillaume Lazzara <z@lrde.epita.fr>
Add new sample programs.
* src/debug/Makefile.am: New targets.
* src/debug/show_groups_bboxes_filtered.cc,
* src/debug/show_text_lines_wo_seps.cc: New.
2011-05-17 Guillaume Lazzara <z@lrde.epita.fr>
 
Fix precision issue with algebra::vec conversion.
......@@ -20,6 +20,7 @@ include $(top_srcdir)/scribo/scribo.mk
noinst_PROGRAMS = \
show_components_bboxes \
show_groups_bboxes \
show_groups_bboxes_filtered \
show_info_x_height \
show_info_median_inter_characters \
show_lines_boldness \
......@@ -53,6 +54,7 @@ noinst_PROGRAMS = \
show_components_bboxes_SOURCES = show_components_bboxes.cc
show_groups_bboxes_SOURCES = show_groups_bboxes.cc
show_groups_bboxes_filtered_SOURCES = show_groups_bboxes_filtered.cc
show_info_x_height_SOURCES = show_info_x_height.cc
show_info_median_inter_characters_SOURCES = show_info_median_inter_characters.cc
show_lines_boldness_SOURCES = show_lines_boldness.cc
......@@ -127,6 +129,20 @@ if HAVE_QT
show_text_lines_LDADD = $(LDADD) \
$(QT_LIBS)
noinst_PROGRAMS += show_text_lines_wo_seps
show_text_lines_wo_seps_SOURCES = show_text_lines_wo_seps.cc
show_text_lines_wo_seps_CPPFLAGS = $(AM_CPPFLAGS) \
$(MAGICKXX_CPPFLAGS) \
$(QT_CPPFLAGS) -DHAVE_QT
show_text_lines_wo_seps_CXXFLAGS = $(AM_CXXFLAGS) \
$(QT_CXXFLAGS)
show_text_lines_wo_seps_LDFLAGS = $(AM_LDFLAGS) \
$(MAGICKXX_LDFLAGS) \
$(QT_LDFLAGS)
show_text_lines_wo_seps_LDADD = $(LDADD) \
$(QT_LIBS)
noinst_PROGRAMS += show_stoppers
show_stoppers_SOURCES = show_stoppers.cc
......
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/io/pbm/all.hh>
#include <mln/value/int_u.hh>
#include <mln/literal/colors.hh>
#include <mln/draw/box.hh>
#include <scribo/core/component_set.hh>
#include <scribo/core/line_set.hh>
#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/group/from_single_link.hh>
#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
#include <scribo/primitive/link/merge_double_link.hh>
#include <scribo/primitive/link/internal/dmax_width_and_height.hh>
#include <scribo/filter/object_links_bbox_h_ratio.hh>
#include <scribo/filter/objects_v_thick.hh>
#include <scribo/filter/objects_small.hh>
int main(int argc, char *argv[])
{
using namespace mln;
using namespace scribo;
using namespace scribo::primitive;
if (argc != 3 && argc != 4 && argc != 5 && argc != 6)
{
std::cerr << "Usage : " << argv[0] << " input.pbm out.pbm [hratio = 2.5] [min_comp_area = 3] [max_comp_height = 300]" << std::endl;
std::cerr << "Remove small and large components. Group components and makes sure "
<< " size ratio is correct." << std::endl;
return 1;
}
typedef mln::value::int_u<30> V;
typedef image2d<V> L;
image2d<bool> input;
io::pbm::load(input, argv[1]);
V ncomponents;
component_set<L>
components = scribo::primitive::extract::components(input, c8(),
ncomponents);
int
min_comp_area = 3,
max_comp_height = 300;
if (argc >= 5)
min_comp_area = atoi(argv[4]);
if (argc >= 6)
max_comp_height = atoi(argv[5]);
components = scribo::filter::components_small(components, min_comp_area);
components = scribo::filter::objects_v_thick(components, max_comp_height);
object_links<L>
left_link = primitive::link::with_single_left_link_dmax_ratio(
components,
// primitive::link::internal::dmax_width_and_height(1),
primitive::link::internal::dmax_default(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),
primitive::link::internal::dmax_default(1),
anchor::MassCenter);
// Validating left and right links.
object_links<L>
merged_links = primitive::link::merge_double_link(left_link,
right_link);
float hratio = 2.5f;
if (argc == 4)
hratio = atof(argv[3]);
object_links<L> hratio_filtered_links
= filter::object_links_bbox_h_ratio(merged_links, hratio);
object_groups<L>
groups = group::from_single_link(hratio_filtered_links);
line_set<L> lines(groups);
{
image2d<bool> output;
initialize(output, input);
data::fill(output, false);
for_all_lines(l, lines)
if (lines(l).is_valid())
mln::draw::box(output, lines(l).bbox(), true);
io::pbm::save(output, argv[2]);
}
}
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/io/pbm/load.hh>
#include <mln/value/int_u16.hh>
#include <mln/draw/box_plain.hh>
#include <mln/pw/all.hh>
#include <mln/core/image/dmorph/image_if.hh>
#include <mln/data/convert.hh>
#include <mln/literal/colors.hh>
#include <scribo/text/recognition.hh>
#include <scribo/debug/usage.hh>
#include <scribo/core/document.hh>
#include <scribo/core/component_set.hh>
#include <scribo/core/object_links.hh>
#include <scribo/core/object_groups.hh>
#include <scribo/text/extract_lines.hh>
#include <scribo/io/xml/save.hh>
const char *args_desc[][2] =
{
{0, 0}
};
int main(int argc, char* argv[])
{
using namespace scribo;
using namespace mln;
if (argc != 3)
return scribo::debug::usage(argv,
"Show text lines",
"input.pbm output.ppm",
args_desc);
trace::entering("main");
image2d<bool> input;
mln::io::pbm::load(input, argv[1]);
typedef image2d<scribo::def::lbl_type> L;
line_set<L> lines = text::extract_lines(input, c8());
// Color image with line bboxes.
{
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
for_all_lines(l, lines)
if (lines(l).is_textline())
mln::draw::box(output, lines(l).bbox(), literal::red);
mln::io::ppm::save(output, argv[2]);
}
trace::exiting("main");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment