Rails app generated with lewagon/rails-templates, created by the Le Wagon coding bootcamp team.
set the following environment variables
# /.env
CLOUDINARY_URL=cloudinary://12***********89:***************************@********
SEARCH_ENGINE_ID
GOOGLE_CUSTOM_SEARCH_KEY
GOOGLE_CLOUD_PROJECT
GOOGLE_APPLICATION_CREDENTIALS
where to find...
- cloudinary key: cloudinary console
- SEARCH_ENGINE_ID: open custom search, select your search engine and see 'Search engine ID'
- about google custom search, you need several settings => see this
- GOOGLE_CLOUD_PROJECT: open Google Cloud Platform and select your project, in the dashboard select 'Project Info' -> see 'Project ID'
- GOOGLE_CUSTOM_SEARCH_KEY: open Google Cloud Platform and select your project, beneath the dashboard select 'Project Info' -> 'credentials' tab -> 'API keys' 'Key'
- Set up: follow Cloud Vision API documents
- create service account (no coding)
- IMPORTANT: you'll download a json file when create a service key. Note the path of that json file as you'll use it to set credential.(No need for contributers)
- set credential in terminal,
export GOOGLE_CLOUD_PROJECT="[PROJECT NAME]"
export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
- Usage: method library for image
- Add gem 'google-cloud-vision' in Gemfile
bundle install
- check the methods library and conceive what you can do
- create vision instance, then call a
.image
method - call whatever method you want
# in this application
# you can see the project name in your api console
vision = Google::Cloud::Vision.new project: "PROJECT_ID"
text = vision.image(image_path).text
puts text.text # -> return an array
use partial response to improve the performance