Nextcloud: Install OCR
The OCR app for Nextcloud 12 comes with a Docker container which has any prerequisites installed. The communication between the Docker container and the host goes over Redis.
Install the OCR app of the Nextcloud app store
The minimum required Nextcloud version is 12, as well as Docker and Redis are mandatory.
After installing the app of the Nextcloud app store, goto the redis folder within the app folder
cd /var/www/nextcloud/apps/ocr/redis
and
Edit redis.conf
port 6380
Install the Docker container with the Redis instance
docker build --build-arg PASSWORD="secretpassword" -t username/redis .
Replace username
with your real username.
Sending build context to Docker daemon 45.06kB Step 1/6 : FROM redis latest: Pulling from library/redis b0568b191983: Pull complete 6637dc5b29fe: Pull complete 7b4314315f15: Pull complete 2fd86759b5ff: Pull complete 0f04862b5a3b: Pull complete 2db0056aa977: Pull complete Digest: sha256:2feb46bc240662176a27fd62dd1718522dd386ab7bf84276bb1e3140f9d4baaa Status: Downloaded newer image for redis:latest ---> c5355f8853e4 Step 2/6 : LABEL maintainer "[email protected]" description "This image serves the redis instance for the ocr worker and the nextcloud ocr app." vendor "Janis Koehr" ---> Running in 5c89b99bfcce ---> 8038c0d70f13 Removing intermediate container 5c89b99bfcce Step 3/6 : ARG PASSWORD="OCR" ---> Running in cbc6b660c018 ---> d807564bb364 Removing intermediate container cbc6b660c018 Step 4/6 : COPY redis.conf /usr/local/etc/redis/redis.conf ---> 172b616ed583 Removing intermediate container 620b7227747e Step 5/6 : RUN if [ -n "$PASSWORD" ]; then echo "requirepass $PASSWORD" >> /usr/local/etc/redis/redis.conf; fi ---> Running in 445d973832e1 ---> bf9cf41a4ffa Removing intermediate container 445d973832e1 Step 6/6 : CMD redis-server /usr/local/etc/redis/redis.conf ---> Running in 86d3fda8d40e ---> 0f86b1ed94fb Removing intermediate container 86d3fda8d40e Successfully built 0f86b1ed94fb Successfully tagged username/redis:latest
Then go to the worker directory within the app folder
cd ../worker
and
Install the Tesseract Docker Container
docker build --build-arg LANGUAGES="tesseract-ocr-deu tesseract-ocr-deu-frak tesseract-ocr-osd tesseract-ocr-equ" -t username/ocr .
Replace username
with your real username. Add as many languages as needed to the command line.
Setup a Custom Docker Network
docker network create --driver bridge isolated_ocr
Redis
docker run --name redis --network=isolated_ocr -p 6380:6380 -d username/redis
Replace username
with your real username.
OCR
Setup a tempdirectory where the webserver can write temporarely
vi /var/www/nextcloud/config/config.php
'tempdirectory' => '/tmp/nextcloudtemp',
Don’t forget to add the path to open_basedir.
Run the Docker container
docker run --name ocr --network=isolated_ocr -e "NODE_ENV=production" -e "REDIS_HOST=redis" -e "REDIS_PORT=6380" -e "REDIS_DB=0" -e "REDIS_PASSWORD=secretpassword" -v /path/to/data/directory/of/nextcloud:/home/node/data:ro -v /path/to/tmp:/home/node/output -d username/ocr
Adjust the secretpassword
(which you have created before), /path/to/data/directory/of/nextcloud
, /path/to/tmp
, username
.
Configure the OCR App
Start OCR
Go to the files section, select OCR of a file
Choose OCR language
and select Process.