Giter Club home page Giter Club logo

pupil-detection's Introduction

Pupil Detection


Functionality

  • Detects the pupil of an eye based on largest contour technique.
  • Each frame/image is processed in grayscale format and then converted to binary image.
  • Detects the maximum contour (i.e the pupil area) and creates a circle bounding box around it.

Packages used

  1. OpenCV v3.4
  2. Numpy v1.15
  3. os
  4. shutil

Steps involved for detecting pupil from images

  1. Loop through all the images from the input folder
  2. Convert the images from BGR colorspace to grayscale
  3. Use cv2.GaussianBlur with kernel size (9, 9) to remove noise to an extent
  4. Use cv2.medianBlur to reduce the noise further
  5. Threshold the image to get the contours
  6. Use cv2.findContours to find all the contours visible after thresholding and select the largest contour out of them only, as it is the pupil.
  7. Get the x,y,w,h from the cv2.boundingRect.
  8. Draw a circle using cv2.circle
  9. Save the results in the output folder

Steps involved for detecting pupil from a video of an eye

  1. Capture the video file using cv2.VideoCapture
  2. Loop the video continuously and save the frames of the video using read()
  3. Get the exact area of the eye (ROI) from the whole frame.
  4. Convert the ROI region into Grayscale then use GaussianBlur as well as medianBlur to reduce the noise.
  5. Threshold the ROI region to get the contours and select only the largest contour as it will be pupil.
  6. Once, contour is detected using cv2.findContours, get the x,y,w,h from the cv2.boundingRect
  7. Draw a circle using cv2.circle

NOTE: use cap.set(cv2.CAP_PROP_POS_FRAMES, 0) to loop back the video from beginning otherwise, it will throw error as there is no frame to capture.

NOTE: At the end release() the video file.

pupil-detection's People

Contributors

arnavdutta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.