Face Detector API - Ruby Gem
Face Detector API analyzes images to detect human faces and returns bounding box coordinates for each detected face.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_facedetect'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_facedetect
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_facedetect'
# Initialize the client
client = APIVerve::Facedetect::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
url: "https://example.com/group-photo.jpg",
confidence: 0.5
})
# Print the response
puts response
File Upload
# Upload a file
response = client.execute_with_file("/path/to/file.jpg")
# Or use a URL
response = client.execute_with_url("https://example.com/image.jpg")
Error Handling
begin
response = client.execute({ url: "https://example.com/group-photo.jpg", confidence: 0.5 })
puts response["data"]
rescue APIVerve::Facedetect::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Facedetect::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Facedetect::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"faces": [
{
"x": 142,
"y": 85,
"width": 98,
"height": 112,
"confidence": 0.9847
},
{
"x": 312,
"y": 92,
"width": 87,
"height": 103,
"confidence": 0.9623
},
{
"x": 478,
"y": 78,
"width": 95,
"height": 118,
"confidence": 0.9412
}
],
"faceCount": 3,
"hasFaces": true,
"imageWidth": 640,
"imageHeight": 480,
"averageConfidence": 0.9627,
"imageCoverage": 10.23
},
"code": 200
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.