You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
If you are still having issues, please be sure to include as much information as possible:
Environment details
OS: MacOS
Ruby version: 3.3.6
Gem name and version: google-cloud-vision (1.5.1)
Steps to reproduce
Call the API and pass an image
The API call works and I get the response, but the response time is huge (approx 77 seconds). If I use the Rest API, I get very quick response for the same image.
Code example
require "google/cloud/vision"
require "time"
require "base64"
# Initialize the Vision API client
vision = Google::Cloud::Vision.image_annotator
image_path = Rails.root.join("app", "assets", "images", "cookie.png")
image = File.open(image_path, "rb")
# Cloudinary URL of the image
# image_url = "https://res.cloudinary.com/dqstmox0s/image/upload/v1736173018/cookie_zqljqk.png"
# Start measuring time
start_time = Time.now
# Perform text detection (OCR) on the image from the Cloudinary URL
begin
puts "Calling Vision API..."
# Sending image URL for OCR
response = vision.text_detection image: image
# End measuring time
end_time = Time.now
duration = end_time - start_time
# Print the time it took
puts "OCR request took #{duration} seconds."
# The response contains multiple results in 'text_annotations'
if response.responses.any?
# Get the text annotations from the first response
annotations = response.responses.first.text_annotations
# Print the detected text
raw_text = annotations.first.description
split_text = raw_text.split("\n")
text_to_match = split_text[0]
puts "Detected text:"
p text_to_match
else
puts "No text annotations found."
end
rescue StandardError => e
puts "An error occurred: #{e.message}"
end
Could there be some kind of configuration issue? I was thinking which endpoint it's calling (Europe or US), but this seems to work properly with the generic endpoint when using the REST API.
Thanks for your help!
The text was updated successfully, but these errors were encountered:
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
If you are still having issues, please be sure to include as much information as possible:
Environment details
Steps to reproduce
Code example
Full backtrace
Calling Vision API... OCR request took 76.694712 seconds. Detected text: "Image text"
Could there be some kind of configuration issue? I was thinking which endpoint it's calling (Europe or US), but this seems to work properly with the generic endpoint when using the REST API.
Thanks for your help!
The text was updated successfully, but these errors were encountered: