Product Recognition
Learn how to build a product recognition system using vfrog.ai.
Use Case
Automatically identify and classify products in images for:
- Retail inventory management
- E-commerce product cataloging
- Point-of-sale systems
- Smart shopping carts
Implementation
import requests
import os
API_KEY = os.environ.get('VFROG_API_KEY')
def recognize_product(image_url, product_id):
"""Recognize product in an image"""
response = requests.post(
"https://api.vfrog.ai/v1/cv/requests/sync",
headers={
"x-api-key": API_KEY,
"Content-Type": "application/json"
},
json={
"external_id": f"product-{product_id}",
"image_url": image_url
},
timeout=30
)
if response.status_code == 200:
result = response.json()
if result['status'] == 'DONE':
return result['results']
return None
# Usage
products = recognize_product(
"https://example.com/shelf-photo.jpg",
"shelf-001"
)
for product in products:
print(f"Product: {product['class_name']}")
print(f"Confidence: {product['confidence']:.2%}")
print(f"Location: {product['bounding_box']}")