This page describes the setup of a Google Cloud based OCR setup for use with the Extended DMS environment. DMS will issue commands so that documents to be OCR'ed are uploaded to Google Cloud, OCR is performed there, and the result is returned. The advantage is that the DMS appliance's CPU is not consumed by the OCR processing and that the OCR process takes advantage of the high accuracy and potential speed of the Google Cloud Vision technology.
Note that the Google Cloud service is not free of charge an requires an active Google Cloud account. See: https://cloud.google.com/vision/pricing
Also note that the performance of this OCR method is largely determined by your internet connection speed as all pdf documents must be uploaded to your Google Storage bucket. In addition to this, depending on setup, this OCR method may consume significant RAM if multiple parallel OCR processes are configured.
The below instructions describe the setup of the DMS host machine. Using this OCR method will not affect performance of the DMS service in a significant way; the scripts involved are only making calls to the Google Cloud API and relay documents/return information, however, they do not perform any processing of the documents.
Create 2 permanent environment variables. For example, add the following 2 lines to /etc/environment
:
GCLOUD_OCR_BUCKET=<$gcloud_storage_bucket_name> GOOGLE_APPLICATION_CREDENTIALS=<$path_to_json> |
replace <$gcloud_storage_bucket_name> and <$path_to_json> with their resective values
Install Java Development Kit in the DMS VM by running
yum install java-1.8.0-openjdk |
/opt/pi-gcloud-ocr.jar
of the DMS VM host machine/usr/bin/
of the DMS VM host machine and make it executable (chmod +x). This script contains the commands to drive the OCR process for each file/<storagepath>/nuxeo/scripts/
and make it executable (chmod +x). This script contains the commands to access pi-google-ocr script from inside the DMS<<adminuserhome>>/.ssh/authorized_keys
file of DMS VM host machine (i.e. the same box)/<storagepath>/nuxeo/data mounted to /var/lib/nuxeo/data
and /<storagepath>/nuxeo/tmp
mounted to /opt/nuxeo/server/tmp
(see below section "Deploy Script changes")~/.ssh/
to /<storagepath>/nuxeo/ssh/
~/deploy/config/
)#!/usr/bin/env bash gsutil cp "$2" gs://${GCLOUD_OCR_BUCKET} input_filename=$(basename $2) output_filename=$(basename $1) json=$(java -jar /opt/pi-google-ocr.jar gs://${GCLOUD_OCR_BUCKET}/${input_filename} gs://${GCLOUD_OCR_BUCKET}/${output_filename}) echo "$json" > "$1" gsutil rm "gs://${GCLOUD_OCR_BUCKET}/${input_filename}" gsutil rm "gs://${GCLOUD_OCR_BUCKET}/${output_filename}*" |
#!/bin/bash echo "variables $1 $2" touch ~/.ssh_config && ssh -F ~/.ssh_config <<adminuser>>@<<dms.host.name>> "pi-google-ocr $1 $2" |
Make sure you replace <<adminuser>>
with the correct user name of an administrative user of the DMS host VM, and <<dms.host.name>>
with the FQDN or IP address of the DMS host VM.
"elif [${1} = "NUXEO"] then"
) so as to be added the container run command:add_volume "/<storage_path>/nuxeo/ssh" "/home/nuxeo/.ssh" add_volume "/<storage_path>/nuxeo/scripts/piocr" "/usr/local/bin/piocr" |