vision/detect_faces.rb
def detect_faces_gcs project_id:, image_path:
  # [START vision_face_detection_gcs]
  # project_id = "Your Google Cloud project ID"
  # image_path = "Google Cloud Storage URI, eg. 'gs://my-bucket/image.png'"

  require "google/cloud/vision"

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

  image.faces.each do |face|
    puts "Joy:      #{face.likelihood.joy?}"
    puts "Anger:    #{face.likelihood.anger?}"
    puts "Sorrow:   #{face.likelihood.sorrow?}"
    puts "Surprise: #{face.likelihood.surprise?}"
  end
  # [END vision_face_detection_gcs]
end
# This method is a duplicate of the above method, but with a different
# description of the 'image_path' variable, demonstrating the gs://bucket/file
# GCS storage URI format.
This method is a duplicate of the above method, but with a different
description of the 'image_path' variable, demonstrating the gs://bucket/file
GCS storage URI format.
This method is a duplicate of the above method but with a different description of the ' image_path ' variable demonstrating the gs : // bucket / file GCS storage URI format .
def detect_faces_gcs project_id:, image_path:
  require "google/cloud/vision"
  vision = Google::Cloud::Vision.new project: project_id
  image  = vision.image image_path
  image.faces.each do |face|
    puts "Joy:      #{face.likelihood.joy?}"
    puts "Anger:    #{face.likelihood.anger?}"
    puts "Sorrow:   #{face.likelihood.sorrow?}"
    puts "Surprise: #{face.likelihood.surprise?}"
  end
end
def detect_faces_gcs project_id : , image_path : require "google/cloud/vision" vision = Google :: Cloud :: Vision . new project : project_id image = vision . image image_path image . faces . each do | face | puts "Joy:      #{face.likelihood.joy?}" puts "Anger:    #{face.likelihood.anger?}" puts "Sorrow:   #{face.likelihood.sorrow?}" puts "Surprise: #{face.likelihood.surprise?}" end end
This method is a duplicate of the above method, but with a different
description of the 'image_path' variable, demonstrating the gs://bucket/file
GCS storage URI format.
This method is a duplicate of the above method but with a different description of the ' image_path ' variable demonstrating the gs : // bucket / file GCS storage URI format .
# [START vision_face_detection_gcs] # project_id = "Your Google Cloud project ID" # image_path = "Google Cloud Storage URI, eg. 'gs://my-bucket/image.png'" # [END vision_face_detection_gcs]
project_id
image_path