Commit 6412c07f authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Ensure current locale is C while calling Tesseract.

	* demo/viewer/main.cc: Move call to setLocale...
	* scribo/text/recognition.hh: ... Here.
parent ba481b8a
2011-12-06 Guillaume Lazzara <z@lrde.epita.fr>
Ensure current locale is C while calling Tesseract.
* demo/viewer/main.cc: Move call to setLocale...
* scribo/text/recognition.hh: ... Here.
2011-11-16 Guillaume Lazzara <z@lrde.epita.fr>
* scribo/text/recognition.hh: Fix code for Tesseract 3.01
......
......@@ -18,10 +18,6 @@
#include <QtGui>
#include <iostream>
# ifdef HAVE_TESSERACT_2
#include <clocale>
# endif // ! HAVE_TESSERACT_2
#undef MLN_WO_GLOBAL_VARS
#include "viewer.hh"
#include <mln/labeling/colorize.hh>
......@@ -49,15 +45,5 @@ int main(int argc, char** argv)
if (!viewer)
return -1;
# ifdef HAVE_TESSERACT_2
// Tesseract 2.x is known to have issues while reading training data
// depending on the current locales in use. Training data files use
// float data and the decimal separator can be either '.' or ','
// causing errors.
// Setting locale to "C" fix that issue.
setlocale(LC_ALL, "C");
# endif // ! HAVE_TESSERACT_2
return viewer->exec();
}
......@@ -40,6 +40,7 @@
# include <ostream>
# include <clocale>
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/core/concept/neighborhood.hh>
......@@ -113,6 +114,12 @@ namespace scribo
{
trace::entering("scribo::text::recognition");
// Tesseract is known to have issues while reading training data
// depending on the current locales in use. Training data files use
// float data and the decimal separator can be either '.' or ','
// causing errors.
// Setting locale to "C" fix that issue.
setlocale(LC_ALL, "C");
// Initialize Tesseract.
TessBaseAPI::InitWithLanguage(NULL, NULL, language, NULL, false, 0, NULL);
......@@ -201,6 +208,13 @@ namespace scribo
const I& line = exact(line_);
mln_precondition(line.is_valid());
// Tesseract is known to have issues while reading training data
// depending on the current locales in use. Training data files use
// float data and the decimal separator can be either '.' or ','
// causing errors.
// Setting locale to "C" fix that issue.
setlocale(LC_ALL, "C");
// Initialize Tesseract.
TessBaseAPI::InitWithLanguage(NULL, NULL, language, NULL, false, 0, NULL);
......
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