Coder Social home page Coder Social logo

rotan96 / rif Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jvanburen/rif

0.0 2.0 0.0 45.87 MB

Resistance is Futile 2: Colorblind Boogaloo

Home Page: https://devpost.com/software/resistance-is-futile/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

rif's Introduction

Resistance Is Futile

See our devpost at https://devpost.com/software/resistance-is-futile/

Inspiration

Resistors have coded colored bands that you can use to tell their resistance values. We have a friend in ECE who is red-green colorblind, so he can't read resistor color bands, because he can't distinguish them.

What it does

You put a resistor onto the green plate and its camera reads the color bands, and tells you the decoded value.

How we built it

We designed a housing for the pi and the camera that would ensure even lighting for the video. We took training images of resistors and trained our computer vision algorithms to recognize the resistors and their colors. Then we designed a display to show the decoded values.

Challenges we ran into

Our original computer vision algorithm was too slow for the raspberry pi.

Accomplishments that we're proud of

We're proud it works at all!

What we learned

We learned about the importance of good training data and the importance of starting early.

What's next for Resistance Is Futile

Adjust the housing: Make it more robust. Improve the CV algorithms to both run faster and give better results. Maybe add a sorting feature in a future iteration.

Specifics of the implementation

Don't judge us too much, this was a hackathon, not a Computer Vision homework!

Training:

  1. We take training images and manually pick out the resistor color bands and the background.
  2. We train a NormalBayesClassifier (bg_classifier) to recognize the background vs the resistor.
  3. We train a NormalBayesClassifier (color_classifier) to distinguish the different resistor colors.

Running:

  1. capture an input image I and convert it to the CIE Lab* color space
  2. Down-sample I to 256x256
  3. Apply bg_classifier to each pixel to get a rough estimate of foreground vs background
  4. Apply the morphological opening operator with a 5x5 box kernel (5 iterations)
  5. Find the largest contour C in the resulting image, check its area is in the range [800, 2300] pixels.
  6. Scale up C and pick the corresponding pixels from the original (not down-sampled) image I
  7. Apply color_classifier to each pixel in the contour.
  8. Find the 3 most commonly occurring colors. (We're not looking for the gold/silver bands!)
  9. Find the centroid of the contour C
  10. Find the centroid of the pixels in each of the most commonly occurring colors
  11. Determine which color r has the centroid furthest from the centroid of C. This is the color band on the edge.
  12. Sort the other 2 colors by the distance from their centroids to the centroid of r. This should give us the correct ordering of color bands.
  13. Look up the color bands in a table and display the result.

rif's People

Watchers

James Cloos avatar Robin Tan 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.