* 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 d14af81..a9b71f0 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-21 Guillaume Lazzara <z(a)lrde.epita.fr>
* README: update requirements information.
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 b7e5c91..e116d58 100644
--- a/scribo/scribo/text/recognition.hh
+++ b/scribo/scribo/text/recognition.hh
@@ -35,6 +35,7 @@
/// \todo Do not store the result in an image?
# include <ostream>
+# include <clocale>
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -106,6 +107,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.
# ifdef HAVE_TESSERACT_2
@@ -215,6 +222,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.
# ifdef HAVE_TESSERACT_2
TessBaseAPI::InitWithLanguage(NULL, NULL, language, NULL, false, 0, NULL);
--
1.7.2.5