Giter Club home page Giter Club logo

eye_blink_detection's Introduction

Eye Blink Detection ๐Ÿ‘€๐Ÿ’ก

image

Overview ๐ŸŒŸ

Welcome to the Eye Blink Detection repository! This project utilizes OpenCV and MediaPipe to detect eye blinks in real-time using a webcam. It calculates the Eye Aspect Ratio (EAR) to determine whether the eyes are open or closed, and displays the last blink time on the screen.

Features ๐Ÿš€

  • Real-Time Eye Blink Detection: Detects blinks in real-time using webcam input.
  • Eye Aspect Ratio Calculation: Uses EAR to determine eye state.
  • Blink Timestamp: Displays the last blink time on the screen.
  • Simple and Intuitive Interface: Easy-to-understand visual cues for eye state.

Installation and Setup ๐Ÿ› ๏ธ

  1. Clone the Repository:

    git clone https://github.com/fastuptime/Eye_Blink_Detection.git
    cd Eye_Blink_Detection
  2. Install Dependencies:

    • Ensure you have Python installed.
    • Install required packages:
      pip install opencv-python mediapipe numpy
  3. Run the Program:

    • Execute the Python script:
      python eye_blink_detection.py

Usage ๐Ÿ’ป

  1. Launch the Program:

    • Run the script. The webcam will start, and the program will begin detecting blinks.
  2. Eye Blink Detection:

    • The program displays the current state of the eyes (open or closed) on the screen.
    • It also shows the last blink time.
  3. Exit the Program:

    • Press the 'q' key to quit the program.

Code Explanation ๐Ÿ“

eye_blink_detection.py

  • Import Libraries:

    import cv2
    import mediapipe as mp
    import numpy as np
    import time
  • Initialize MediaPipe and OpenCV:

    mp_face_mesh = mp.solutions.face_mesh
    mp_drawing = mp.solutions.drawing_utils
    face_mesh = mp_face_mesh.FaceMesh(min_detection_confidence=0.5, min_tracking_confidence=0.5)
  • Calculate Eye Aspect Ratio (EAR):

    def eye_aspect_ratio(landmarks, eye_indices):
        # Implementation to calculate EAR
  • Threshold for Eye Aspect Ratio:

    EYE_AR_THRESH = 0.3
  • Capture Video from Webcam:

    cap = cv2.VideoCapture(0)
    lastTime = 'Bilinmiyor'
  • Main Loop for Eye Blink Detection:

    while cap.isOpened():
        ret, frame = cap.read()
        if not ret:
            break
        # Implementation for processing frame and detecting blinks
  • Display Results and Handle Exit:

    cv2.imshow('Goz Kirpma Tespiti', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    
    cap.release()
    cv2.destroyAllWindows()

Contributing ๐Ÿค

Contributions are welcome! Feel free to open issues or submit pull requests.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

eye_blink_detection's People

Contributors

fastuptime avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.