I was presented with a task to quickly prepare a bare-metal Linux machine to run Tesseract OCR for optical character recognition task. The criterion was to to the recognition as fast as possible. In my tests, the Tesseract 5 was far more precise than Tesseract 4, no matter what options, configurations and pre-processing I tried (and I tried a lot of them!). The other requirement was to use Ubuntu 18.04. LTS. It is not the latest, but still pretty support-ready (Apr 2028). I have gathered some notes from the process, so I thought I share them. Maybe they can help someone.
HP 290 G4 manual
For the task I obtained the HP 290 G4 station in the midi-tower, as the off-the-shelf part, and little bit in a hurry. Tesseract needs mostly CPU and this came with a relatively recent multi-threading Intel i3 processor, which later proved a good investment.
However, I had problems to get Ubuntu there. Relevant excerpts from the HP 290 G4 manual:
- Turn on or restart the computer or tablet, quickly press
Esc
, and then pressF9
for boot options. - Turn on or restart the computer, and when the HP logo appears, press
F10
to enter Computer Setup (UEFI BIOS).
The keys are not too common based on my previous experience - I was
expecting F12
and F2
respectively.
Install OpenSSH
Ubuntu apparently came without SSH enabled by default source:
sudo apt install openssh-server
sudo systemctl enable ssh.service --now
Node 16 LTS
The node
in the repository was version 8. Version 16 LTS was needed
source:
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt -y install nodejs
Node-red
To install node-red [source](sudo npm install -g --unsafe-perm node-red):
sudo npm install -g --unsafe-perm node-red
PM2 process manager for node-red
To make node-red start on boot on Ubuntu (unlike in Raspbian) a custom solution is needed. PM2 was used source:
sudo npm install -g pm2
pm2 start $(which node-red) -- -v
pm2 save
pm2 startup
# Now run the command displayed on the screen
PM2 autostart on boot
Important note on error PID file not readable
source:
pm2 kill
sudo systemctl start pm2-USERNAME.service
Tesseract 5.1
Install Tesseract OCR 5.1 on Ubuntu 18.04 source:
sudo apt update
sudo add-apt-repository ppa:alex-p/tesseract-ocr-devel
sudo apt install -y tesseract-ocr
tessdata_ocrb
The data trained specifically for the font used in the ID and Passports. This is the same font that was used in this product as well. The speedup was very noticeable!
https://github.com/Shreeshrii/tessdata_ocrb
Use like this:
TESSDATA_PREFIX=/home/peterbabic/tessdata_ocrb tesseract /home/peterbabic/PHOTO.jpg - -l ocrb_int
PC speaker clicking sounds
After Ubuntu was started the PC speaker was making a very annoying periodic "click" sound. The problem went away for a moment when the volume was adjusted or when some some music was started. The problem did not go away when PC speaker was disabled in BIOS, which was very surprising. The problem was also not present when in BIOS, GRUB or in pre-installed FreeDOS environment (which I found is probably built on top of Debian). The problem was in the power saving options source:
echo 'options snd-hda-intel power_save=0' | sudo tee /etc/modprobe.d/alsa-info.conf