Armageddon421's Hackingblog

ResCan – scan resistor values!

by on Feb.15, 2014, under quickhack

Well, this one was unexpected. I went to visit ST from project-insanity and he wanted to have a huge pile of unsorted resistors… sorted. Measuring with a Multimeter is unpractical and slow and reading the color codes gets tiring very quickly.

“A machine could do this!” -me

So I started writing an android app using opencv to detect the color codes. Although the camera outputs a fullHD-Stream, it has trouble focusing at low distances. Moving the phone further away results in the color rings being only 2 pixels wide, what makes it quite hard to safely detect.

I decided to use a cheap USB-Webcam with manual focus to overcome the problem. Luckily the webcam has six cold white LEDs around the lens, providing a nice constant light source. Only the automatic adjustment of exposure time sometimes causes trouble. I used java on the desktop-PC so I could reuse parts of the code from the android app.

Although I’m using opencv to grab the video stream and its tools to crop images and draw on them, the algorithm itself is a bunch of for loops. I couldn’t bother to find out how to train any classifiers. Basically all I do is separating the resistor from the white background and then detecting the “thicker thing” between the two leads. This works pretty stable, even for extremely bent leads.

The thick red line shows where the algorithm thinks the center of the resistor is, the blue lines show where the color is grabbed. Because of the specular reflections from the LEDs, there is no grabbing happening at the center line.


Finally, I decided that it would be nice if the tool reads out the values loudly, just the way we worked in tandem when we tried to sort them manually. I used FreeTTS, an open source pure-java text to speech implementation to achieve this.

Watch the video to see it in action!

Update: I put the project on GitHub! There is also a jar to try out!

Article Name
ResCan - scan resistor values!
Let your camera read the color codes on resistors!

15 Comments for this entry

  • Tomas

    Like Android application it should be very useful!

  • Todd

    THANK YOU for this. As a Maker who is color blind, sorting and identifying resistors has always taken up way too much of my time. I started a project like this, but I can see I was going the wrong direction and your code looks so much neater than mine. Thank you again for the work on this!


    • Not colorblind

      I know this is a common term, but it is wrong. Color vision deficiency is the right term, color blind suggest you are blind to colors, while in most cases it means only certain shades are hard to distinguish.

  • lokito

    Great work
    I hope you put the source code on github.

  • Igor

    It would be nice if the program to recognize the specified element to good photography board and highlights the desired areas.

  • Pieter

    This is a great project. I (and a lot of others) would love to use it because I am a little bit colorblind and resistor are the worst thing in my life…

    Great job! Can’t wait for the software release ;-)


  • philip

    can i ask for a copy? of the android app as-well i’ll try it on my phone GSIII it can focus quite well closeup thanks in advance

  • Matt

    So, quick question, I have a LOT of older and newer resistors that need to be sorted, and I saw this post on hackaday and thought… PERFECT!

    I was wondering though, I haven’t really looked at your code yet, but I use a DSLR camera, and I have windows, mac, and linux available. Could something be written to look at areas of the computer screen? The Canon software I use in “live view” mode does a great job of quick updates to the screen, and I have software like manycam(for windows) and camtwist(for mac) that basically fake out skype and other clients to use an area of the screen as a “webcam”.

    I was wondering if something like this could be easily adapted to do exactly what you have already done?


  • Richard Waterman

    Neat project. I have many unsorted resistors from prototying and something like this would help me get them back to my drawers. Can you post what camera you used?

  • Not colorblind

    Your project looks really useful. I am looking forward to use it with a phone!

  • Joe

    I have seen a similar program for the iPhone, but I’ve been looking for an android version.

    And while it is nice to see it working on a PC, the nice thing about a phone is that it is always handy. Consider just using a magnifying glass to try it with your own phone.

    A final suggestion is to increase the size of the image of the resistor as much as you can, even if it becomes pixelated. This is so that you can visually compare the color with the color output. It is easier to see colors if they are larger.

  • dario

    Hi, it’s a really usefull app. Is it posible to get a copy of it’s android version?

  • Mike Wiltrout

    Unfortunately, I’m not a Java programmer. I’m colorblind and I work with electronics everyday. I need an app such as yours to identify resistors and colored wires that are in existing electronics. Especially since I cannot measure the resistors in circuit and get accurate values without isolating them by removing a single leg. Do you have a means of supplying an executable for this program that will run a PC and work with a generic USB camera/microscope? Please contact me.

  • Ace

    hello guys can i use this code with raspberry pie and a camera..I am a new bie to programming and working on my final year project

1 Trackback or Pingback for this entry

Leave a Reply