Giter Club home page Giter Club logo

sleepy_driver's Introduction

Sleepy Driver Finder

Quick hack to find out if a driver is sleepy or not.

Software contained within has only been tested on the Mac OS X operating system. Theoretically, it could work on Linux and other UNIX based systems.

All scripts and software for this system are written in Ruby.

Contents

There are a few scripts that are useful in the ./scripts folder. The application that actually performs the sleepy eye detection is in the base directory and the ./lib folder.

  • ./scripts
    • eye_spy.rb – GUI for locating the eyes in a set of images to be used as input to the application. For each image of the video sequence, the pupils of the individuals eyes are marked using this program. These locations are stored in the yaml file : ./data/eyes_raw.
    • image_del.rb – removes images from the broken down video sequence. For the first video clip, this removed duplications, for the second, it just makes it so the algorithm doesn’t look at all the frames in the sequence.
    • yaml_fixer.rb – no longer useful.
    • eye_cutter.rb – no longer useful.
  • sleepy_driver_finder.rb – Main application that takes the sequence of images and the yaml file locating the eye positions, determines if the individual is asleep, and then outputs this decision to a modified version of the image. This application would be called using: ruby sleepy_driver_finder.rb
  • ./lib – classes used by the sleepy driver finder application
    • eye_grabber.rb – For each image, the yaml eye file is queried to determine the locations of the eyes, and then these eyes are extracted.
    • eye_diagnoser.rb – for an eye image, determines if it is open or closed. Uses the moment of the eye after normalization and thresholding.
    • eye_drawer.rb – adds the icon to the output images indicating if the person is awake or asleep.

Requirements

  • Ruby v1.8.6 tested
  • Shoes – used for the GUI for locating eyes in scripts/eye_spy.rb
  • mPlayer to extract images from video
  • ffmpeg or mencoder or both to create a video out of the images
  • rmagick – used for all the image processing

Normal workflow

  • Split up video into a series of images.
    • See the example command below
  • Delete extra frames if necessary
    • Use the image_del script in the scripts folder
  • Pick out the eyes in the images and save them to yaml
    • Use the eye_spy script
    • This this a shoes app.
  • Make sure the paths in sleepy_driver_finder.rb are correct
    • Most assume that everything is stored in the ./data directory
  • Run the sleepy driver finder
    • ruby ./sleepy_driver_finder.rb
  • Stitch resulting images back together
    • See example command below

Example commands

Example command to split up video into images:

mPlayer -vo jpeg:quality=100:outdir=./images/ ./kaiduan.mpg

h3. Example command to rejoin all images back to a video:

ffmpeg -r 3 -i result-%01d.jpg test18002.mp4

Example command to rejoin all images — works if the file names are not sequential

mencoder "mf://*.jpg" -mf fps=5 -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800

sleepy_driver's People

Contributors

vlandham avatar

Stargazers

Angus H. avatar  avatar Lourens Naudé avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

cider-load-test

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.