[36920] | 1 |
|
---|
| 2 | #---
|
---|
| 3 | # Setup
|
---|
| 4 | #---
|
---|
| 5 |
|
---|
| 6 | Assuming you have been through setting up:
|
---|
| 7 |
|
---|
| 8 | cd ext-cli/
|
---|
| 9 | ./get-selfcontained-python3.sh
|
---|
| 10 |
|
---|
| 11 | Then to setup this extension then all you need to do is:
|
---|
| 12 |
|
---|
| 13 | pip install --upgrade google-cloud-vision
|
---|
| 14 |
|
---|
| 15 | To enable the Google Vision API, set up a key etc, see:
|
---|
| 16 |
|
---|
| 17 | https://cloud.google.com/vision/docs/setup
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | When you create a key, your browsesr downloads a JSON version of the key.
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | #---
|
---|
| 24 | # Using the Extension
|
---|
| 25 | #---
|
---|
| 26 |
|
---|
| 27 | The extension provides the GoogleVisionImagePlugin, for use in collections.
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | Small workaround needed if checked out in the GS3 extension area:
|
---|
| 31 |
|
---|
| 32 | export GSDL3EXTS=$GSDL3EXTS:structured-image
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | Example use of the plugin:
|
---|
| 36 |
|
---|
| 37 | <plugin name="GoogleVisionImagePlugin">
|
---|
| 38 | <option name="-enable_document_ocr"/>
|
---|
| 39 | <option name="-enable_image_labelling"/>
|
---|
| 40 | </plugin>
|
---|
| 41 |
|
---|
| 42 | The plugin currently has a hard-wired filename for the Google
|
---|
| 43 | service key. This need's to be in the collection's 'etc'
|
---|
| 44 | directory as follows:
|
---|
| 45 |
|
---|
| 46 | etc/my-google-service-account-key.json
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | For the 'atea-storage' Google Cloud Project, for example, a redacted version of
|
---|
| 50 | the JSON key file looks like:
|
---|
| 51 |
|
---|
| 52 | {
|
---|
| 53 | "type": "service_account",
|
---|
| 54 | "project_id": "atea-storage",
|
---|
| 55 | "private_key_id": "7bc843de4257da515193eaa5b60468fcab5b3948",
|
---|
| 56 | "private_key": "-----BEGIN PRIVATE KEY-----\n???????.........??????=\n-----END PRIVATE KEY-----\n",
|
---|
| 57 | "client_email": "[email protected]",
|
---|
| 58 | "client_id": "123???...????",
|
---|
| 59 | "auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
---|
| 60 | "token_uri": "https://oauth2.googleapis.com/token",
|
---|
| 61 | "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
---|
| 62 | "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account%40atea-storage.iam.gserviceaccount.com"
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 | =========
|
---|
| 68 |
|
---|
| 69 | Deprecated
|
---|
| 70 |
|
---|
[36247] | 71 | #====
|
---|
| 72 | # Getting the extension
|
---|
| 73 | #====
|
---|
| 74 |
|
---|
| 75 | Assuming you are in the Greenstone3 top-level (i.e. GSDL3SRCHOME) directory,
|
---|
| 76 | (if not already done so) this extension can be checked out as follows:
|
---|
| 77 |
|
---|
| 78 | svn co https://svn.greenstone.org/gs3-extensions/structured-image/trunk ext/structured-image
|
---|
| 79 |
|
---|
| 80 | Note that the plugin this extension introduces makes use of a Google Service Account and requires credentials. For more details, visit: https://cloud.google.com/vision/docs/setup.
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | #====
|
---|
| 84 | # Compiling the extension
|
---|
| 85 | #====
|
---|
| 86 |
|
---|
| 87 | #-<>
|
---|
| 88 | # <One-time-only>
|
---|
| 89 | #--
|
---|
| 90 |
|
---|
| 91 | cd ext/structured-image
|
---|
| 92 | ./CREATE-VENV-PYTHON3.sh
|
---|
| 93 | cd ../..
|
---|
| 94 |
|
---|
| 95 | ln -s ext/structured-image/SETUP-TOP-LEVEL.sh SETUP.sh
|
---|
| 96 | ln -s ext/structured-image/DEVEL-TOP-LEVEL.sh DEVEL.sh
|
---|
| 97 |
|
---|
| 98 | # If your python does not already have Google Cloud Vision
|
---|
| 99 | source ./SETUP.sh
|
---|
| 100 | pip install --upgrade google-cloud-vision
|
---|
| 101 |
|
---|
| 102 | #--
|
---|
| 103 | # </One-time-only>
|
---|
[36920] | 104 | #</>
|
---|