Skip to content

Latest commit

 

History

History
250 lines (185 loc) · 7.37 KB

File metadata and controls

250 lines (185 loc) · 7.37 KB

Hybrid Euro Coin Detection System

Python License YOLO OpenCV

A real-time Euro coin detection and classification system using a Hybrid Pipeline Architecture that combines YOLO11s deep learning with classical computer vision techniques for high accuracy and stability.

🎯 Overview

This system detects and classifies all 8 types of Euro coins (1c, 2c, 5c, 10c, 20c, 50c, 1€, 2€) in real-time using a custom-trained YOLO11s model combined with size refinement, color classification, and consensus voting.

✨ Key Features

  • 🚀 Real-time Detection: Optimized for 20+ FPS with frame skipping
  • 🎯 High Accuracy: Custom-trained YOLO11s model (99.1% mAP50)
  • 🔬 Multi-method Classification: YOLO + Size + Color with consensus voting
  • 📊 Temporal Smoothing: Reduces flickering with frame history tracking
  • 🎨 Color Classification: Robust HSV-based color analysis
  • 📏 Size-based Classification: Calibrated pixel-to-millimeter conversion
  • 🖥️ Side-by-Side GUI: Camera feed + Statistics panel
  • ⚙️ Calibration System: Coin-based calibration for accurate sizing

🏗️ Architecture

The system uses a Hybrid Pipeline that combines multiple detection methods:

Camera Frame
    ↓
YOLO11s Detection (Primary)
    ↓
Hybrid Pipeline Processing
    ├─► Size Refinement (Hough Circles - Optional)
    ├─► Color Classification (HSV Analysis)
    ├─► Size Classification (Calibrated)
    └─► Consensus Voting (Weighted Combination)
    ↓
Temporal Smoothing (Frame History)
    ↓
Display (Camera + GUI Panel)

Component Overview

  • CoinDetectionApp (main.py): Main application coordinator
  • CoinDetector (detector.py): YOLO11s model wrapper
  • HybridPipeline (hybrid.py): Multi-method classification
  • Calibrator (calibration.py): Pixel-to-mm calibration
  • Utils (utils.py): Utility functions

For detailed architecture, see Report/Report.md.

📸 Screenshots

Screenshots will be added to assets/screenshots/

🚀 Quick Start

Installation

  1. Clone the repository:

    git clone https://github.com/xampos101/Hybrid-Euro-Detection-System.git
    cd Hybrid-Euro-Detection-System
  2. Install dependencies:

    pip install -r requirements.txt
  3. Verify model file:

    • Ensure V2/model/best.pt exists (YOLO11s trained model)

Basic Usage

python new_pipeline/main.py

Calibration (Recommended)

For best accuracy, calibrate the system first:

  1. Press '2' for 2€ coin calibration
  2. Place ONLY the selected coin in frame
  3. Wait for green circle
  4. Press SPACE to confirm

📁 Project Structure

Hybrid-Euro-Detection-System/
├── new_pipeline/          # Main pipeline code
│   ├── main.py           # Application entry point
│   ├── detector.py       # YOLO detection wrapper
│   ├── hybrid.py         # Hybrid classification pipeline
│   ├── calibration.py   # Calibration system
│   ├── utils.py          # Utility functions
│   └── config.py         # Configuration settings
│
├── V2/                   # Models
│   └── model/
│       └── best.pt       # YOLO11s trained model
│
├── Report/               # Documentation
│   ├── Report.md        # Technical report
│   └── FlowDiagrams.md  # Mermaid flow diagrams
│
├── docs/                 # Additional documentation
│   └── training/        # Training results and plots
│
├── records/              # Demo videos
│   └── *.mp4           # Video demonstrations
│
└── assets/              # Images and screenshots
    ├── screenshots/     # Application screenshots
    └── diagrams/        # Exported diagrams

🎓 YOLO11s Model

Training Details

  • Architecture: YOLO11s (small variant)
  • Base Model: Pretrained yolo11s.pt
  • Epochs: 20
  • Dataset: Custom Euro coins dataset
  • Final Performance:
    • Precision: 97.7%
    • Recall: 97.0%
    • mAP50: 99.1%
    • mAP50-95: 90.7%

Training Results

Training Results

Confusion Matrix

For detailed training information, see docs/training/training_results.md.

🎥 Demo Videos

Demo videos are available in the records/ folder:

  • FINAL_RECORD.mp4 - Final demonstration
  • Recording 2026-01-15 160914.mp4 - Latest recording
  • Additional recordings available

See records/README.md for detailed descriptions.

📚 Documentation

  • Report/Report.md: Comprehensive technical report

    • Architecture overview
    • Component descriptions
    • Algorithms and logic
    • Configuration guide
  • Report/FlowDiagrams.md: Mermaid flow diagrams

    • Main application flow
    • Detection pipeline
    • Consensus voting
    • Temporal smoothing
    • Color classification
  • docs/training/training_results.md: Training documentation

    • Training configuration
    • Results and metrics
    • Performance analysis

⚙️ Configuration

All settings are in new_pipeline/config.py:

  • YOLO Settings: Confidence threshold, IOU threshold, image size
  • Hybrid Pipeline: Hough refinement, color thresholds
  • Temporal Smoothing: History size, matching thresholds
  • Performance: Frame skipping, optimization settings

🎮 Controls

  • 'q': Quit application
  • 'd': Toggle debug mode
  • '2': Calibrate with 2€ coin
  • '1': Calibrate with 1€ coin
  • '5': Calibrate with 50c coin
  • SPACE: Confirm calibration
  • ESC: Cancel calibration

🔧 Requirements

  • Python 3.8+
  • OpenCV (cv2)
  • NumPy
  • Ultralytics YOLO
  • PyTorch (CPU or CUDA)

Install all dependencies:

pip install -r requirements.txt

🏆 Performance

  • Detection Speed: 20+ FPS (with optimizations)
  • Accuracy: 99.1% mAP50 (YOLO11s model)
  • Classification: Multi-method consensus voting
  • Stability: Temporal smoothing reduces flickering

🛠️ Technologies Used

  • YOLO11s: Custom-trained deep learning model
  • OpenCV: Image processing, Hough circles, camera capture
  • NumPy: Array operations and mathematical calculations
  • Ultralytics: YOLO framework
  • PyTorch: Deep learning backend

📊 System Architecture

The system combines:

  • Deep Learning (YOLO11s): Fast and accurate detection
  • Classical CV (Hough, Color): Robust classification
  • Temporal Smoothing: Stability across frames
  • Consensus Voting: Weighted combination for accuracy

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📝 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🙏 Acknowledgments

  • Ultralytics for the YOLO framework
  • OpenCV community for excellent computer vision tools
  • Euro coin specifications from official sources

📧 Contact

For questions or issues, please open an issue on GitHub.


Built with ❤️ using YOLO11s and OpenCV