Tesseract OCR: ParamsModel::Incomplete line

Using Tesseract OCR for some automation tasks, I stumbled upon the following issue:

Creating OCR Image #1/4 with maximally 97 lines from line 1 to 97
ParamsModel::Incomplete line
ParamsModel::Incomplete line
ParamsModel::Incomplete line
ParamsModel::Incomplete line
ParamsModel::Incomplete line ConvNL

As it turns out, this is caused by using a wrong version of tesseract models / „Tessdata“. You can find the official „Tessdata“ files on GitHub. As I installed Tesseract on macOS via Homebrew, I ended up with version 3.05.01 of Tesseract. Therefore I had to use an older version of the trained models. As stated in the project’s README, you can find those via the 3.04.00 tag (README says branch, but that is wrong):

Get language data files for Tesseract 3.04 or 3.05 from the 3.04 tree.

E.g. for the german model, you would end up with the following download link:

https://github.com/tesseract-ocr/tessdata/raw/3.04.00/deu.traineddata

CocoaPods can’t reach GitHub

Running CocoaPods on “old” versions of OS X / macOS might lead to some weird behaviour – namely CocoaPods telling you that GitHub might be down:

$ pod repo update --verbose

Updating spec repo `master`
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-1.3.1/lib/cocoapods-core/github.rb:105:in `rescue in modified_since_commit'
[...]

The error message does not only sound insane, it is actually completely misleading. The issue seems to be caused by a failing request to GitHub. Originating from a failed TLS handshake (as it happens quite often with the older Ruby 2.0.0 version). More recent versions of Ruby don’t have a problem with communicating via SSL. Using a more recent Ruby version does in fact circumvent the issue:

brew install ruby
sudo gem install cocoapods

Depending on your system, you might need to forcefully “overwrite” the Ruby installation using brew link:

brew link --overwrite ruby

Further references

Building OpenCL on macOS: CL/cl.h not found

Compiling a third party project on macOS, I stumbled upon the following compilation error after running make:

Scanning dependencies of target[...]
[ 33%] Building CXX object CMakeFiles/[...].dir/main.cpp.o
In file included from /Users/[...]/main.cpp:11:
/Users/[...]/CLCalculator.h:14:10: fatal error: 'CL/cl.h' file not found
#include <CL/cl.h>
         ^
1 error generated.
make[2]: *** [CMakeFiles/[...].dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/[...].dir/all] Error 2
make: *** [all] Error 2

Unfortunately the application was originally not intended for macOS / OS X platforms. There are quite some examples of similar encounters in the vastness of the internet. But… there is a simple way to make your the respective code cross-plattform and compatible with macOS / OS X:

#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

Just replace the #include <CL/cl.h> statement with the snippet above and run make again – great…

Python Pillow 3 with Alpine Linux

Using Alpine Linux as a base for Docker images does have some implications and odd bugs. Trying to get Taiga (Backend) running with Alpine Linux I stumbled upon the following error log:

ValueError: --enable-zlib requested but zlib not found, aborting.

Even explicitly installing zlib (as required) does not help getting rid of the issue:

apk add --no-cache zlib zlib-dev

To get it working / recognizing the system’s zlib you need to

  • extend the CFLAGS environmental variable
CFLAGS="$CFLAGS -L/lib"
  • or create a softlink for the zlib library before executing the Pillow installation:
ln -s /lib/libz.so /usr/lib/

Further References:

Git: Create an unrelated / orphan / disconnected branch

git checkout [-q] [-f] [-m] --orphan  []

Create a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.

[…]

This can be useful when you want to publish the tree from a commit without exposing its full history. […]

If you want to start a disconnected history that records a set of paths that is totally different from the one of <start_point>, then you should clear the index and the working tree right after creating the orphan branch by running git rm -rf . from the top level of the working tree. […]

Source: http://git-scm.com/docs/git-checkout/

git checkout --orphan newbranch  
git rm -rf .  
[...]
git add files  
git commit -m 'Initial commit'  

Source: http://stackoverflow.com/a/4288660