Skip to content

Commit

Permalink
make Font creation works on Ubuntu 18.04
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisMansencal committed Jan 21, 2020
1 parent 06ac1f2 commit 2a5059d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmake/Modules/FindTesseract.cmake
Expand Up @@ -39,13 +39,14 @@ find_path(Tesseract_TESSDATA_PARENT_DIR
PATHS ${Tesseract_PKGCONF_DATAROOTDIR}
/usr/share/tesseract
/usr/share/tesseract-ocr
/usr/share/tesseract-ocr/4.00
)

INCLUDE(FindPackageHandleStandardArgs)

# handle the QUIETLY and REQUIRED arguments and set GIRL_FOUND to TRUE if
# handle the QUIETLY and REQUIRED arguments and set Tesseract_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tesseract DEFAULT_MSG Tesseract_LIBRARY Tesseract_INCLUDE_DIR Lept_FOUND)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tesseract DEFAULT_MSG Tesseract_LIBRARY Tesseract_INCLUDE_DIR Lept_FOUND Tesseract_TESSDATA_PARENT_DIR)

IF(TESSERACT_FOUND)
SET(Tesseract_FOUND TRUE)
Expand Down
12 changes: 12 additions & 0 deletions software/DocCreator/src/FontGenerator/OCRDialog.cpp
Expand Up @@ -215,6 +215,12 @@ OCRDialog::process()
tess.SetVariable("tessedit_char_whitelist",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");

#if TESSERACT_VERSION == 262144
//On Ubuntu 18.04, it seems that tesseract 4.0 needs "tessdata" in path to find languages
// and thus to initialize correctly.
m_tessdataParentDir += "tessdata";
#endif

const QByteArray tessdataParentDirBA = m_tessdataParentDir.toLatin1();
const char *tessdataParentDir = tessdataParentDirBA.constData();
//B:Warning: tessdataParentDir must end with "/"
Expand Down Expand Up @@ -250,6 +256,7 @@ OCRDialog::process()
#endif //TESSERACT_VERSION

const int tessInitFailed =
//tess.Init("/usr/share/tesseract-ocr/4.00/tessdata/", language, tesseract::OEM_DEFAULT);
tess.Init(tessdataParentDir, language, tesseract::OEM_DEFAULT);

if (tessInitFailed == 0) {
Expand Down Expand Up @@ -353,6 +360,11 @@ OCRDialog::process()

updateView();
}
else {

std::cerr<<"ERROR: tesseract initialization failed\n";
std::cerr <<" TESSERACT_VERSION="<<TESSERACT_VERSION<<"\n";
}
}

void
Expand Down

0 comments on commit 2a5059d

Please sign in to comment.