* demo/viewer/main.cc: Move call to setLocale...
* scribo/text/recognition.hh: ... Here.
---
scribo/ChangeLog | 7 +++++++
scribo/demo/viewer/main.cc | 14 --------------
scribo/scribo/text/recognition.hh | 14 ++++++++++++++
3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 48c1b84..a3e6e7e 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-06 Guillaume Lazzara <z(a)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(a)lrde.epita.fr>
* scribo/text/recognition.hh: Fix code for Tesseract 3.01
diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc
index 704dfe7..0c50c7b 100644
--- a/scribo/demo/viewer/main.cc
+++ b/scribo/demo/viewer/main.cc
@@ -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();
}
diff --git a/scribo/scribo/text/recognition.hh b/scribo/scribo/text/recognition.hh
index fe2c94a..22d31f6 100644
--- a/scribo/scribo/text/recognition.hh
+++ b/scribo/scribo/text/recognition.hh
@@ -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);
--
1.7.2.5