Smart Scan Pro (QR/Barcode) (Laptop Version) A real-time, AI-powered barcode and QR code scanner that identifies products using your laptop's webcam. This version is designed to be lightweight, silent, and easy to run on any computer.
🌟 Overview This project combines Computer Vision and Deep Learning to create a smart scanner. It doesn't just read barcodes; it uses an AI "brain" to find them in the video feed, decodes them, and then searches global databases to tell you exactly what product you are holding.
🚀 Key Features AI Detection: Uses a custom-trained YOLOv8 model to pinpoint barcodes even in messy backgrounds.
High-Speed Decoding: Powered by ZXing-CPP for near-instant reading of barcodes and QR codes.
Global Database Search: Connects to Open Food Facts and Open Beauty Facts to identify products from Egypt and around the world.
Laptop Ready: No external hardware required—works directly with your built-in webcam.
Silent Mode: Clean interface with no audio interruptions.
🛠️ Requirements To run this project, you need to have the following installed in your Python environment:
Python 3.8+
OpenCV (cv2) - For video processing.
Ultralytics - To run the YOLOv8 AI model.
ZXing-CPP - For barcode decoding.
Requests - To talk to the product databases.
Installation Command: Bash
pip install opencv-python ultralytics zxing-cpp requests numpy 📂 Project Structure scanner.py: The main Python script.
best.pt: Your custom-trained YOLOv8 weights (stored in your Downloads folder).
README.md: This documentation file.
🚦 How to Use Set your Model Path: Open scanner.py and ensure the MODEL_PATH points to your .pt file:
Python
MODEL_PATH = 'C:/Users/malak/Downloads/uni vision/Dataset/runs/detect/barcode_qr_model_robust/weights/best.pt' Run the script:
Bash
python scanner.py Scan: Place a barcode or QR code inside the gray box on your screen.
Green Box: Product found in the database.
Orange Box: Code read, but product not found.
Red Box: Barcode detected but needs to be clearer to read.
Quit: Press the 'q' key to close the scanner.
🌐 Databases Used This project retrieves data from the following open-source APIs:
Open Food Facts
Open Beauty Facts
Open Products Facts
🛠️ Troubleshooting (The First-Aid Kit) If the scanner isn't working quite right, try these simple fixes:
- ❌ Error: "Could not open webcam" The Fix: Make sure no other app (like Zoom, Teams, or your Camera app) is using your webcam.
The Fix: If you have an external webcam plugged in, try changing WEBCAM_ID = 0 to WEBCAM_ID = 1.
- ❌ Error: "File not found" (The Model) The Fix: This usually means the computer can't find your best.pt file. Double-check the path.
Pro Tip: In Windows, use double backslashes like this: C:\Users\Name\Downloads\best.pt or use a single forward slash like this: C:/Users/Name/Downloads/best.pt.
- 🔍 It sees the box, but won't show the Product Name The Fix: Check your internet! The scanner needs to talk to the web to find the names.
The Fix: Not every product in the world is in the database yet. Try scanning a famous snack or a shampoo bottle—those usually work best!
💡 Tips for a Perfect Scan Lighting: Make sure the room isn't too dark. If there is a bright light reflecting off the barcode (glare), tilt the product slightly.
Distance: Hold the product about 15–20 cm away from the camera. Don't hold it too close, or it will look blurry!