Skip to content

Instantly share code, notes, and snippets.

View UBISOFT-1's full-sized avatar
🇵🇰
I've grown up. Logged in after a Year!

_ UBISOFT-1

🇵🇰
I've grown up. Logged in after a Year!
View GitHub Profile
@UBISOFT-1
UBISOFT-1 / gcvocr.sh
Created December 18, 2021 16:36
Google Cloud Vision OCR JSON Response Converter
# this script is updated in order to support for multi-threaded applications.
# $3 is a random md5 hash or a uuid.uuid4() object that enables gcvocr.sh to be used without having two overlapping files named temp.json
#!/bin/bash
#cd ~
echo '{"requests":[{"image":{"content":"' > ./$3.json
openssl base64 -in $1 | cat >> ./$3.json
echo '"},
"features":{"type":"TEXT_DETECTION","maxResults":2048}}]}' >> ./$3.json
curl -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=$2 --data-binary @./$3.json > "$1.json"