The Google OCR tool adds a Page-namespace toolbar button that will derive text from the current page's image, via Google's Cloud Vision API OCR service.
It is used on Wikisources in languages with scripts that are not supported by the standard Tesseract OCR system. It should not be used where that system can be used instead, as there is a limit to the number of requests we can make against Google's services.
Note that only some languages are supported. Currently, this tool does not support the following Wikisource languages: Malayalam, Oriya, or Gujrati. Sorry.
The tool can be used on its own to OCR any image that is hosted on Commons.
To do this, just go to the tool's web interface at https://tools.wmflabs.org/ws-google-ocr/ and paste in any image's full URL (i.e. after right clicking on an image and choosing 'copy image location'). This can be of use when processing images in the needing transcription category, for example.
Images with substantial amounts of text should be included in Wikisource instead, and proofread in the normal fashion.
Setting up as a user script or global script
Individual users can load Google OCR for themselves by adding the following to their common.js:
Wikis that want to make the OCR tool available by default for everyone can add the line above to their MediaWiki:Common.js.
You will also need to create the system messages mentioned below if they don't already exist on your wiki.
Setting up as a gadget
To use Google OCR on any Wikisource, you should set it up as a Gadget (only administrators can do this).
MediaWiki:Gadget-GoogleOCR.jsand add the following:
- Add the following to
- Create the following system messages:
MediaWiki:google-ocr-button-label— tooltip text for the buttons, e.g.: "Get text via Google OCR".
MediaWiki:google-ocr-request-in-progress— 'loading' text displayed while the OCR request is being carried out; e.g.: "Loading text from Google OCR".
MediaWiki:google-ocr-no-text— message displayed when the OCR tool didn't fail but also didn't return an error; e.g.: "No text retrieved from Google OCR"
MediaWiki:google-ocr-image-not-found— the image is expected to be in an element with class
prp-page-image; if it can't be found, this message is displayed in a bubble notification; e.g.: "No image found on this page"
- Enable the gadget for yourself, and test its operation. Bugs should be reported via Phabricator.
For more information about gadget configuration, see mw:Extension:Gadgets.
Sites using this
If your Wikisource is loading the Google OCR script as a gadget or a site script please list it here so we can keep you up to date with developments.
The struck-out languages above are not yet supported.
- The tool's web interface is fully translatable; see en.json for a current list of messages.
- Script: MediaWiki:GoogleOCR.js
- Tool source code: https://phabricator.wikimedia.org/diffusion/1966/
- Tool deployment: https://tools.wmflabs.org/ws-google-ocr/
- Cloud Vision API library: https://github.com/wikisource/google-cloud-vision-php/
- Toolbar icons: File:GoogleOcr WikiEditor button.png and File:GoogleOcr toolbar button.png