Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integrated Parking Lot System

A comprehensive dual-authentication parking lot access control system combining AI-powered license plate detection with face recognition for maximum security and convenience.

🎯 System Overview

This integrated system provides dual-layer authentication requiring both:

  1. Face Recognition - Verify authorized personnel
  2. License Plate Detection - Confirm authorized vehicle

Both checks must pass for system authorization, providing enhanced security for sensitive parking facilities.

🏗️ Architecture

parkingLotSystem/
├── README.md                    # This file - Integration guide
├── main.py                      # Main integration controller
├── requirements.txt             # All system dependencies
├── utils.py                     # Shared utilities
├── face_recognition/            # Independent face recognition system
│   ├── README.md               # Face system documentation
│   ├── main_face_recognition.py
│   ├── People/                 # Known faces directory
│   └── *.wav                   # Audio notifications
└── plate_detection/            # Independent plate detection system
    ├── README.md              # Plate system documentation
    ├── yolo_detect.py
    ├── authorized_plates.xlsx
    └── model/                 # YOLO models directory

🚀 Quick Start

1. Install All Dependencies

pip install -r requirements.txt

Core Dependencies:

  • opencv-python - Camera and image processing
  • face-recognition - Face detection and recognition
  • ultralytics - YOLO v11 models
  • easyocr - License plate text recognition
  • pandas - Excel file management
  • pygame - Audio notifications
  • numpy - Numerical operations

2. Setup Face Recognition

Add authorized personnel photos to face_recognition/People/:

face_recognition/People/
├── john_doe.jpg
├── jane_smith.jpg
└── security_guard.jpg

3. Setup License Plate Authorization

Edit plate_detection/authorized_plates.xlsx:

Plate Number Owner Name Vehicle Type Status
ABC123 John Doe Car Active
XYZ789 Jane Smith SUV Active

4. Run the Integrated System

# Standard mode (single frame detection)
python main.py

# Continuous monitoring mode (constant face detection with no delays)
python main.py --continuous

# Individual system testing
cd face_recognition && python main_face_recognition.py  # Face recognition only
cd plate_detection && python yolo_detect.py            # Plate detection only

New Constant Detection Mode:

  • Processes every frame with no delays
  • Real-time face recognition on every camera frame
  • Instant detection and authorization
  • Visual overlay showing detection status

🎮 System Operation

Authentication Flow

  1. Camera Activation - System captures live video feed
  2. Face Detection - Scans for known faces in the frame
  3. Plate Detection - Simultaneously detects license plates
  4. Dual Verification - Both face AND plate must be authorized
  5. Access Decision - Grant/deny access based on dual authentication
  6. Logging - Record all authentication attempts

Real-time Display

  • Live camera feed with overlay information
  • Face detection boxes with names
  • License plate detection boxes with text
  • Authorization status indicators
  • Confidence scores for both systems

Control Keys

  • 'q' - Quit the system
  • 's' - Save current frame
  • 'f' - Force face recognition check
  • 'p' - Force plate detection check
  • 'r' - Generate activity report
  • 'c' - Clear detection cache

⚙️ Configuration

System Settings in main.py

# Authentication Requirements
REQUIRE_BOTH_FACE_AND_PLATE = True    # Dual authentication mode
FACE_CONFIDENCE_THRESHOLD = 0.6       # Face recognition sensitivity
PLATE_CONFIDENCE_THRESHOLD = 0.5      # Plate detection sensitivity

# Timing Configuration
DETECTION_INTERVAL = 1.0               # Seconds between checks
CACHE_DURATION = 30                    # Seconds to cache detections
AUTHORIZATION_TIMEOUT = 10             # Seconds for full authorization

# Camera Settings
CAMERA_INDEX = 0                       # Camera device index
FRAME_WIDTH = 1280                     # Camera resolution width
FRAME_HEIGHT = 720                     # Camera resolution height

Integration Modes

Mode 1: Dual Authentication (Default)

REQUIRE_BOTH_FACE_AND_PLATE = True

Both face and plate must be authorized for access.

Mode 2: Either Authentication

REQUIRE_BOTH_FACE_AND_PLATE = False

Either valid face OR valid plate grants access.

Mode 3: Face Priority

FACE_PRIORITY_MODE = True

Check face first, only check plate if face fails.

🔧 Advanced Features

Smart Detection Caching

def smart_cache_detection(face_result, plate_result):
    """Cache results to avoid redundant processing"""
    cache_key = f"{face_result}_{plate_result}_{timestamp}"
    return authorization_cache.get(cache_key)

Progressive Authentication

  • Stage 1: Detect presence (any face or plate)
  • Stage 2: Identify specific face and plate
  • Stage 3: Cross-verify authorization match
  • Stage 4: Grant access with full logging

Multi-Camera Support

# Configure multiple camera feeds
CAMERA_CONFIGS = [
    {"index": 0, "role": "entry", "position": "front"},
    {"index": 1, "role": "exit", "position": "rear"},
    {"index": 2, "role": "overview", "position": "top"}
]

📊 System Integration API

Core Integration Functions

from main import capture_camera_frame
from face_recognition.main_face_recognition import recognize_face_id
from plate_detection.yolo_detect import detect_plate_text

def authorize_access():
    """Main authorization function"""
    frame = capture_camera_frame()

    # Parallel detection
    face_name = recognize_face_id(frame)
    plate_text = detect_plate_text(frame)

    # Authorization logic
    face_authorized = face_name is not None
    plate_authorized = is_plate_authorized(plate_text)

    return face_authorized and plate_authorized, {
        'face': face_name,
        'plate': plate_text,
        'timestamp': time.time()
    }

Event-Driven Integration

def on_authorization_success(auth_data):
    """Callback for successful authorization"""
    print(f"Access granted to {auth_data['face']} with vehicle {auth_data['plate']}")
    # Trigger gate opening, lighting, etc.

def on_authorization_failure(auth_data):
    """Callback for failed authorization"""
    print(f"Access denied - Face: {auth_data['face']}, Plate: {auth_data['plate']}")
    # Trigger security alerts, logging, etc.

📱 Usage Examples

Basic Integration

import cv2
from main import authorize_access

# Simple authorization check
authorized, details = authorize_access()

if authorized:
    print(f"Welcome {details['face']}! Vehicle {details['plate']} authorized.")
else:
    print("Access denied. Please ensure both face and vehicle are registered.")

Continuous Monitoring

def parking_lot_monitor():
    while True:
        authorized, details = authorize_access()

        if authorized:
            open_gate()
            log_entry(details)
            send_notification(f"Entry: {details['face']}")

        time.sleep(1)  # Check every second

Integration with Hardware

import RPi.GPIO as GPIO  # For Raspberry Pi

def hardware_integration():
    # GPIO setup for gate control
    GPIO.setup(18, GPIO.OUT)  # Gate relay
    GPIO.setup(24, GPIO.OUT)  # Status LED

    authorized, details = authorize_access()

    if authorized:
        GPIO.output(18, GPIO.HIGH)  # Open gate
        GPIO.output(24, GPIO.HIGH)  # Green light
        time.sleep(5)               # Keep open 5 seconds
        GPIO.output(18, GPIO.LOW)   # Close gate
        GPIO.output(24, GPIO.LOW)   # Turn off light

🚨 Troubleshooting

Common Issues

No Face Detection

  • Check face_recognition/People/ directory has photos
  • Verify camera permissions and lighting
  • Test face recognition independently: cd face_recognition && python main_face_recognition.py

No Plate Detection

  • Verify YOLO models exist in plate_detection/model/
  • Check authorized_plates.xlsx format
  • Test plate detection independently: cd plate_detection && python yolo_detect.py

Integration Failures

  • Check import paths in main.py
  • Verify both subsystems work independently
  • Review error logs in terminal output

Performance Issues

  • Slow Detection: Reduce camera resolution or enable GPU
  • Memory Issues: Close other applications, monitor RAM usage
  • CPU Usage: Consider frame skipping or detection intervals

Debugging Tools

# Enable debug mode in main.py
DEBUG_MODE = True
VERBOSE_LOGGING = True

# Individual system testing
python face_recognition/main_face_recognition.py  # Test face system
python plate_detection/yolo_detect.py            # Test plate system
python main.py --debug                           # Debug integration

📈 Performance Optimization

Hardware Recommendations

Minimum Setup

  • CPU: Quad-core 2.5GHz
  • RAM: 8GB
  • Storage: 2GB free space
  • Camera: 720p USB webcam

Recommended Setup

  • GPU: NVIDIA RTX 3060 or better
  • CPU: 8-core 3.0GHz+
  • RAM: 16GB
  • Storage: SSD with 5GB free space
  • Camera: 1080p with good low-light performance

Professional Setup

  • GPU: RTX 4080+ or Tesla series
  • CPU: 16-core 3.5GHz+
  • RAM: 32GB+
  • Storage: NVMe SSD
  • Camera: 4K with multiple angles
  • Network: Gigabit connection for cloud features

Performance Tuning

# Optimize for speed
FRAME_SKIP = 2                    # Process every 2nd frame
FACE_DETECTION_INTERVAL = 2.0     # Face check every 2 seconds
PLATE_DETECTION_INTERVAL = 1.5    # Plate check every 1.5 seconds
PARALLEL_PROCESSING = True        # Enable concurrent detection

🔐 Security Features

Multi-Layer Protection

  • Biometric Authentication (face recognition)
  • Vehicle Authentication (license plate)
  • Temporal Validation (time-based access rules)
  • Behavioral Analysis (unusual pattern detection)

Audit and Compliance

  • Complete Activity Logs - Every detection attempt recorded
  • Image Evidence - Auto-captured photos for security review
  • Access Reports - Detailed analytics and reporting
  • Compliance Export - Data export for security audits

Anti-Spoofing Measures

  • Liveness Detection - Prevents photo-based spoofing
  • Plate Validation - Format and region verification
  • Confidence Thresholding - Reject low-confidence detections
  • Pattern Analysis - Detect suspicious behavior patterns

📱 Deployment Options

Local Deployment

# Standard local deployment
python main.py

# Background service (Linux)
nohup python main.py > parking_system.log 2>&1 &

# Windows service
python main.py --service

Docker Deployment

FROM python:3.9
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 8080
CMD ["python", "main.py", "--web-interface"]

Cloud Deployment

  • Google Colab: GPU acceleration for development
  • AWS EC2: Scalable cloud hosting
  • Azure IoT: Edge device deployment
  • Google Cloud: AI/ML optimized instances

🌟 Integration Possibilities

IoT Integration

  • Smart Gates: Automatic barrier control
  • LED Indicators: Visual status feedback
  • Sensors: Motion detection, vehicle presence
  • Alarms: Security breach notifications

Software Integration

  • Web Dashboard: Remote monitoring and control
  • Mobile Apps: Staff notifications and management
  • Payment Systems: Automatic billing integration
  • Building Management: HVAC, lighting control

Enterprise Integration

  • Active Directory: User authentication
  • SIEM Systems: Security event logging
  • HR Systems: Employee database sync
  • Visitor Management: Temporary access control

📝 API Documentation

REST API Endpoints (Future)

GET  /api/status          # System health check
POST /api/authorize       # Manual authorization check
GET  /api/logs           # Access activity logs
POST /api/users          # Add authorized users
GET  /api/stats          # System statistics

Webhook Integration

# Configure webhooks for real-time notifications
WEBHOOK_CONFIG = {
    "url": "https://your-system.com/parking-events",
    "events": ["access_granted", "access_denied", "system_error"],
    "authentication": "Bearer your-token"
}

🎯 Getting Started Checklist

  • Install dependencies: pip install -r requirements.txt
  • Add face photos to face_recognition/People/
  • Configure authorized plates in plate_detection/authorized_plates.xlsx
  • Test face recognition: cd face_recognition && python main_face_recognition.py
  • Test plate detection: cd plate_detection && python yolo_detect.py
  • Run integrated system: python main.py
  • Configure authentication mode in main.py
  • Test with real users and vehicles
  • Set up logging and monitoring
  • Deploy to production environment

Ready for Production! This integrated parking lot system provides enterprise-grade security with dual authentication and comprehensive logging.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages