Recursively perform OCR on all images contained in a directory shared with the container.
214
TL;DR Make images searchable WITHOUT using a cloud-service. Fully offline, extract text from images and make it searchable and cataloged.
A directory full of images will be walked recursively and OCR'd converting any text within the image to actual text. The text contained within the image, some metadata about the image, and the image digest hash are saved within a single JSON file (which is of course text searchable).
The ocrdocker tool will avoid cataloging files with identical contents.
To download and run this image from dockerhub you just:
docker run -v ~/Desktop/ocr_test:/ocrshare sa7ori/ocrdocker
The Docker container needs a shared directory passed into it. This shared directory is where the OCR code will immediately recursively perform OCR on all images.
In the example above:
~/Desktop/ocr_test needs to be changed to the directory containing the images you want to OCR on your Host OS:/ocrshare must remain the same because this is the mountpoint expected by the code WITHIN the VM for the shared directory.s7:~/Desktop/ocr_test$ ls
MindsTweetsZuckerbergOnJoeRogan.png TalibanIsDiverse.jpeg TwitterTrendingTopics2pm16Aug2021.png whiteness2.jpg
s7:~/Desktop/ocr_test$ sudo docker run -v ~/Desktop/ocr_test:/ocrshare sa7ori/ocrdocker
Unable to find image 'sa7ori/ocrdocker:latest' locally
latest: Pulling from sa7ori/ocrdocker
7b1a6ab2e44d: Already exists
66097b8dfdea: Already exists
c94b6e8ebf72: Already exists
9992a5b45b8e: Already exists
e13a1f71a1fe: Already exists
847d70aff6b5: Already exists
c4c4d4570803: Already exists
c0e71f60f11f: Already exists
13ef3012ef1e: Pull complete
8e2fed491c4e: Pull complete
a29c27d769a6: Pull complete
Digest: sha256:84eef081cded2be6b5d9b864f6cfb07445949a48aaf826bc264a05f07ea95426
Status: Downloaded newer image for sa7ori/ocrdocker:latest
Detected 6 diacritics
Warning: Invalid resolution 0 dpi. Using 70 instead.
Estimating resolution as 141
Warning: Invalid resolution 0 dpi. Using 70 instead.
Estimating resolution as 189
Warning: Invalid resolution 0 dpi. Using 70 instead.
Estimating resolution as 517
****** STARTING OCR run in: '/ocrshare' ******
[+] EXECUTING: 'tesseract 'whiteness2.jpg' stdout '
[+] EXECUTING: 'tesseract 'TwitterTrendingTopics2pm16Aug2021.png' stdout '
[+] EXECUTING: 'tesseract 'MindsTweetsZuckerbergOnJoeRogan.png' stdout '
[+] EXECUTING: 'tesseract 'TalibanIsDiverse.jpeg' stdout '
[+] OCR metadata for 4 files saved to 'image_metadata_2022_08_26_06_21_29.json'
s7:~/Desktop/ocr_test$ ls
image_metadata_2022_08_26_06_21_29.json MindsTweetsZuckerbergOnJoeRogan.png TalibanIsDiverse.jpeg TwitterTrendingTopics2pm16Aug2021.png whiteness2.jpg
s7:~/Desktop/ocr_test$ grep -rnioE '.{0,21}Zuckerberg.{0,21}' *
image_metadata_2022_08_26_06_21_29.json:1:" \n\nBREAKING: Mark Zuckerberg tells Joe Rogan that
image_metadata_2022_08_26_06_21_29.json:1:lename": "MindsTweetsZuckerbergOnJoeRogan.png"}, "d3
s7:~/Desktop/ocr_test$ curl --upload-file ./MindsTweetsZuckerbergOnJoeRogan.png https://transfer.sh/MindsTweetsZuckerbergOnJoeRogan.png
https://transfer.sh/8Xkomh/MindsTweetsZuckerbergOnJoeRogan.png
s7:~/Desktop/ocr_test$
To view an example source image that was OCR'd in this example view: https://transfer.sh/8Xkomh/MindsTweetsZuckerbergOnJoeRogan.png
Content type
Image
Digest
sha256:84eef081c…
Size
353.6 MB
Last updated
about 4 years ago
docker pull sa7ori/ocrdocker