GithubHelp home page GithubHelp logo

led-timeline's Introduction

LED Timeline

Track LED on and off states with OpenCV.

A small personal project to see what's possible with Python + OpenCV.

⚠ WARNING ⚠

This code is awful. The whole thing is a hack. Use at your discretion.

Requirements

  1. Python 3.7+
  2. OpenCV
    I built my libraries from source (specifically, commit c722625f28). Pre-built binaries should work, but your milage may vary.

Steps

  1. Extract valid frames.
    Ran into an issue where trimming the video with the Android camera app resulted in a frame count larger than the number of readable frames. This is mitigated by extracting all readable frames from the given video.
  2. Denoising via the non-local means algorithm.
    The goal here is to smooth digital sensor noise in order to reduce its impact on changes in pixel value over time. This is extremely CPU intensive and will take a while to complete. While offloading this process to the GPU is an option, it makes the code (even) less portable since the CUDA SDK is required.
  3. Convert the video to grayscale.
  4. Calculate the change in pixel intensity over time.
    This causes each LED appear as though it only turns on for a single frame.
  5. Using Canny edge detection and contour tracing, search each frame and attempt to resolve a bounding rectangle. Once all bounding rectangles have been identified, the grayscale video is replayed and each area is analyzed. If the average pixel value of an area defined by a bounding rectange reaches a certain threshold, then that LED is considered "on".

License

MIT License

Copyright (c) 2020 Evan Hall

See the LICENSE file for more details.

led-timeline's People

Contributors

ethall avatar

Stargazers

esarver avatar

Watchers

James Cloos 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.