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

innovativeproject.png

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

  1. Real-time object detection using a webcam
  2. Automatic billing based on detected items
  3. Voice feedback using Text-to-Speech
  4. Displays detected objects on the screen
  5. Easy-to-modify product price list
  6. Simple and low-cost implementation


Supplies

Hardware

  1. Computer or Laptop
  2. Webcam (built-in or external)

Software

  1. PictoBlox
  2. Python
  3. Object Detection Extension (PictoBlox)
  4. Text-to-Speech Extension (PictoBlox)


How It Works

  1. The webcam captures a live image.
  2. When the Space key is pressed, the system analyzes the current frame.
  3. The AI model detects objects in the image.
  4. Only detections with a confidence above 65% are considered.
  5. Each detected object is matched with a predefined price.
  6. The total bill is calculated automatically.
  7. 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

  1. Open the project in PictoBlox.
  2. Connect a webcam.
  3. Run the program.
  4. Place one or more supported objects in front of the camera.
  5. Press the Space key.
  6. The system detects the items, calculates the total bill, and announces the result.
  7. Press Space again to scan the next customer.


Code Highlights

  1. Webcam initialization
  2. AI object detection
  3. Confidence filtering (65%)
  4. Automatic bill calculation
  5. Voice announcements
  6. 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)