-1

Running this example https://cloud.google.com/vision/docs/face-tutorial?hl=zh-tw

by rails on 'google-cloud-vision', '~> 0.31.0'

got the error

uninitialized constant Google::Cloud::Vision::ImageAnnotator

here's the code

require "google/cloud/vision"


project_id = 'xxxxxx'


vision = Google::Cloud::Vision.new project: project_id


image_annotator = Google::Cloud::Vision::ImageAnnotator.new
S.cll
  • 123
  • 1
  • 1
  • 6
  • don't know why I got this error 'uninitialized constant Google::Cloud::Vision::ImageAnnotator' – S.cll Dec 25 '18 at 10:03

2 Answers2

0

Did you added google-cloud-ruby gem in your Gemfile and other google related authentication details into your ruby project.

0

It turns out that the error was caused because I haven't use the latest version of gcloud-vision(0.32.x)

the way to do what I wanna do in gcloud-vision(0.31.0) is

image = vision.image "path/to/face.jpg"

face = image.face

instead of using class

Google::Cloud::Vision::ImageAnnotator

S.cll
  • 123
  • 1
  • 1
  • 6