Real-time gold/jewellery detection system using YOLO models with person segmentation to suppress false positives, OCR weight reading, auto-recording, and a SQLite database for logging every detection event.
- Gold Detection — Custom YOLO11n model detects gold objects in a defined ROI
- Person Segmentation — YOLO26-seg masks out people so gold worn by a person is ignored
- Weight Reading — EasyOCR reads the weight from the scale display
- Auto Recording — Video is recorded automatically when gold is detected, stops 10s after last detection
- Database Logging — Every detection is logged to SQLite with video path, weight, timestamp, and extracted image
# 1. Install Python dependencies
pip install -r requirements.txt
# 2. Run the detection system
python3 GoldNormal.pyPress Q to quit.
pip install customtkinter pillow
python3 viewer/app.pyThe viewer reads from the database and auto-refreshes every 5 seconds. It can run alongside the detection system.
pip install ultralytics opencv-python easyocr numpyOr use the requirements file:
pip install -r requirements.txtTo visually browse the detection database:
sudo apt install sqlitebrowser
sqlitebrowser runs/jewellery_detections.dbGolddetection/
├── GoldNormal.py ← Main script (run this)
├── database/ ← Database management package
│ ├── __init__.py
│ ├── db_manager.py ← SQLite DB with deduplication
│ ├── image_extractor.py ← Extracts best gold frame from videos
│ └── post_processor.py ← Background thread for image extraction
├── viewer/ ← GUI viewer application
│ ├── app.py ← Run this to launch viewer
│ ├── db_reader.py ← Read-only DB queries
│ ├── file_opener.py ← Cross-platform file opener
│ └── widgets/ ← UI components
│ ├── sidebar.py
│ ├── topbar.py
│ ├── table_view.py
│ └── detail_panel.py
├── weights/ ← All YOLO model files
│ ├── Yolo11n.engine ← Gold detection (TensorRT)
│ ├── yolo26n-seg.onnx ← Person segmentation (ONNX)
│ └── ... ← Other model formats (.pt, .onnx)
├── runs/
│ ├── recordings/ ← Auto-saved .mp4 clips
│ ├── images/ ← Snapshots and extracted gold frames
│ ├── jewellery_detections.db ← SQLite database (auto-created)
│ └── detection.log ← Event log
├── test_db.py ← Database test suite
├── data.yaml ← Dataset config (Roboflow)
├── requirements.txt
└── ReadME.md
| Model | Format | Purpose |
|---|---|---|
Yolo11n.engine |
TensorRT | Gold/jewellery detection (primary) |
yolo26n-seg.onnx |
ONNX | Person segmentation |
All models are stored in the weights/ directory.
Bangles · Chain · Earrings · Gold Bar · Gold Coin · Ring
Detection events are stored in runs/jewellery_detections.db (SQLite, auto-created on first run).
Command line:
sqlite3 -header -column runs/jewellery_detections.db "SELECT * FROM gold_detections;"GUI viewer:
sudo apt install sqlitebrowser
sqlitebrowser runs/jewellery_detections.dbPython:
from database.db_manager import JewelleryDBManager
db = JewelleryDBManager()
for row in db.get_all_detections():
print(row)python3 test_db.py
# Expected output: ALL TESTS PASSED- PyTorch
- Ultralytics YOLO
- OpenCV
- EasyOCR
- NumPy
- CustomTkinter (viewer GUI)
- Pillow (image thumbnails in viewer)
- SQLite3 (built-in with Python)