Skip to content

Latest commit

 

History

History
277 lines (204 loc) · 6.45 KB

File metadata and controls

277 lines (204 loc) · 6.45 KB

Contributing to Driver Monitoring System

First off, thank you for considering contributing to the Driver Monitoring System! It's people like you that make this project such a great tool.

Code of Conduct

This project and everyone participating in it is governed by our commitment to providing a welcoming and inspiring community for all. Please be respectful and constructive in your communications.

How Can I Contribute?

Reporting Bugs

Before creating bug reports, please check the existing issues to avoid duplicates. When you create a bug report, include as many details as possible:

Bug Report Template:

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment:**
 - OS: [e.g. Windows 10, macOS 13.0]
 - Python Version: [e.g. 3.9.7]
 - Browser: [e.g. Chrome 120]

**Additional context**
Add any other context about the problem here.

Suggesting Enhancements

Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:

  • Clear title and description of the suggested enhancement
  • Use cases - Why would this be useful?
  • Possible implementation - How could this be implemented?
  • Alternatives considered - What other solutions have you thought about?

Pull Requests

  1. Fork the Repository

    git clone https://github.com/yourusername/Driver_Monitoring_System.git
    cd Driver_Monitoring_System
  2. Create a Branch

    git checkout -b feature/your-feature-name

    Branch naming conventions:

    • feature/ for new features
    • bugfix/ for bug fixes
    • docs/ for documentation updates
    • refactor/ for code refactoring
  3. Make Your Changes

    • Write clear, commented code
    • Follow PEP 8 style guidelines for Python
    • Add docstrings to functions and classes
    • Update documentation as needed
  4. Test Your Changes

    • Ensure all existing tests pass
    • Add new tests for new features
    • Test manually with both live camera and image upload modes
  5. Commit Your Changes

    git add .
    git commit -m "feat: add amazing new feature"

    Commit message format:

    • feat: for new features
    • fix: for bug fixes
    • docs: for documentation changes
    • style: for formatting changes
    • refactor: for code refactoring
    • test: for adding tests
    • chore: for maintenance tasks
  6. Push to Your Fork

    git push origin feature/your-feature-name
  7. Open a Pull Request

    • Provide a clear description of the changes
    • Reference any related issues
    • Include screenshots/videos if applicable

Development Setup

Prerequisites

python --version  # Should be 3.8+

Installation

# Clone your fork
git clone https://github.com/yourusername/Driver_Monitoring_System.git
cd Driver_Monitoring_System

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install development dependencies
pip install pytest black flake8 mypy

Running Tests

# Run all tests
pytest

# Run specific test file
pytest tests/test_detection.py

# Run with coverage
pytest --cov=.

Code Style

We follow PEP 8 with some modifications:

# Format code with black
black .

# Check style with flake8
flake8 .

# Type checking with mypy
mypy .

Key guidelines:

  • Maximum line length: 100 characters
  • Use 4 spaces for indentation (no tabs)
  • Use descriptive variable names
  • Add type hints where possible
  • Write docstrings for all public functions/classes

Docstring Format

Use Google-style docstrings:

def process_frame(frame, model, threshold=0.5):
    """Process a video frame for object detection.
    
    Args:
        frame (np.ndarray): Input image frame in BGR format.
        model (YOLO): YOLO model instance.
        threshold (float, optional): Confidence threshold. Defaults to 0.5.
    
    Returns:
        list: List of detected objects with bounding boxes.
        
    Raises:
        ValueError: If frame is None or empty.
    """
    pass

Project Structure Guidelines

Adding New Detection Modules

When adding a new detection module:

  1. Create a new file: new_detection.py
  2. Follow this template:
"""Module for [detection type] detection.

This module implements [brief description].
"""

from utils import extract_boxes

def process_[detection_type](frame, model, **kwargs):
    """Process frame for [detection type] detection.
    
    Args:
        frame: Input image frame
        model: YOLO model instance
        **kwargs: Additional parameters
        
    Returns:
        list: Detection results
    """
    # Implementation
    pass
  1. Import in app.py:
from new_detection import process_[detection_type]
  1. Add to processing pipeline in /process_image route

Adding Configuration Options

Add configuration to the top of app.py:

# New feature config
NEW_FEATURE_ENABLED = True
NEW_FEATURE_THRESHOLD = 0.6

Areas We'd Love Help With

High Priority

  • 🧪 Unit Tests - Improve test coverage
  • 📊 Performance Optimization - Reduce latency
  • 🎯 Detection Accuracy - Improve model performance
  • 📱 Mobile Responsiveness - Better UI on mobile devices

Medium Priority

  • 🌍 Internationalization - Add multi-language support
  • 📈 Analytics Dashboard - Add statistics and charts
  • 🐳 Dockerization - Create Docker setup
  • 📚 Documentation - More examples and tutorials

Enhancement Ideas

  • Multi-person detection support
  • Head pose estimation for attention detection
  • Fatigue score calculation
  • Historical data logging
  • REST API for integrations
  • Voice alerts
  • Dashboard for fleet monitoring

Recognition

Contributors will be:

  • Listed in the README.md
  • Mentioned in release notes
  • Given credit in documentation

Questions?

Feel free to:

  • Open an issue with the question label
  • Reach out via email: your.email@example.com
  • Start a discussion in GitHub Discussions

License

By contributing, you agree that your contributions will be licensed under the MIT License.


Thank you for contributing! 🎉