AI Smart Billing System Using Computer Vision
by pavanhl in Circuits > Computers
19 Views, 0 Favorites, 0 Comments
AI Smart Billing System Using Computer Vision
Imagine a supermarket checkout that can recognize products automatically without manually entering them. This project demonstrates an AI-powered smart billing system built using PictoBlox, Python, and Computer Vision. The system uses a webcam to detect everyday objects, identifies them with an AI object detection model, calculates the total bill based on predefined prices, and announces the result using text-to-speech.
This project is beginner-friendly and is a great introduction to AI, computer vision, and automation.
Features
- Real-time object detection using a webcam
- Automatic billing based on detected items
- Voice feedback using Text-to-Speech
- Displays detected objects on the screen
- Easy-to-modify product price list
- Simple and low-cost implementation
Supplies
Hardware
- Computer or Laptop
- Webcam (built-in or external)
Software
- PictoBlox
- Python
- Object Detection Extension (PictoBlox)
- Text-to-Speech Extension (PictoBlox)
How It Works
- The webcam captures a live image.
- When the Space key is pressed, the system analyzes the current frame.
- The AI model detects objects in the image.
- Only detections with a confidence above 65% are considered.
- Each detected object is matched with a predefined price.
- The total bill is calculated automatically.
- The detected items and total amount are displayed and spoken aloud.
Price List Used
ItemPrice
Apple
₹20
Banana
₹15
Orange
₹25
Cup
₹50
Book
₹120
Cell Phone
₹500
Bottle
₹30
Laptop
₹45,000
How to Use
- Open the project in PictoBlox.
- Connect a webcam.
- Run the program.
- Place one or more supported objects in front of the camera.
- Press the Space key.
- The system detects the items, calculates the total bill, and announces the result.
- Press Space again to scan the next customer.
Code Highlights
- Webcam initialization
- AI object detection
- Confidence filtering (65%)
- Automatic bill calculation
- Voice announcements
- Continuous scanning loop
Applications
Smart supermarket checkout
Retail automation
Educational AI demonstrations
Computer vision learning
STEM and robotics projects
School and college exhibitions
Program
sprite = Sprite("Tobi")
import time
# Initialize the globally exposed PictoBlox extension classes
obj_detect = ObjectDetection()
ts = TexttoSpeech()
# Clear video states and cleanly initialize the webcam view
obj_detect.video("OFF")
time.sleep(0.5)
obj_detect.video("ON", 100)
obj_detect.setthreshold(0.65) # Bumped up to 65% confidence to reduce false "kite" guesses
# Define our verified master inventory
price_list = {
"apple": 20,
"banana": 15,
"orange": 25,
"cup": 50,
"book": 120,
"cell phone": 500,
"bottle": 30,
"laptop": 45000
}
obj_detect.disablebox()
sprite.say("Welcome! Press SPACE to scan your cart.")
ts.speak("Welcome. Press space to scan your items.")
while True:
if sprite.iskeypressed("space"):
sprite.say("Refreshing frame and scanning...")
ts.speak("Scanning items.")
# Force the backend to capture the true live stage frame
obj_detect.analysestage()
total_items = obj_detect.count()
bill_amount = 0
scanned_items = []
if total_items > 0:
obj_detect.enablebox()
for i in range(1, total_items + 1):
item_name = obj_detect.classname(i)
# Check the confidence value of this specific detection item (index i)
# If the camera is covered, confidence drops near 0, bypassing the error
# Convert the confidence string to a float so Python can compare it
try:
item_confidence = float(obj_detect.confidence(i))
except (ValueError, TypeError):
item_confidence = 0.0
if item_confidence > 0.65:
scanned_items.append(item_name)
if item_name in price_list:
bill_amount += price_list[item_name]
else:
bill_amount += 10
# Only output bill metrics if items passed our confidence filter
if len(scanned_items) > 0:
summary_text = f"Scanned: {', '.join(scanned_items)}. Total bill is {bill_amount}."
sprite.say(summary_text)
ts.speak(summary_text)
else:
sprite.say("No clear items detected in the frame.")
ts.speak("No clear items detected.")
time.sleep(3)
obj_detect.disablebox()
sprite.say("Press SPACE to scan next customer.")
else:
sprite.say("No items detected.")
ts.speak("No items detected.")
time.sleep(0.1)