Robot Sorts Beads By Color

If you know anyone who does crafts, they probably have a drawer with a  few million beads loose and mixed together. You’ll sort them out one day, right? Probably not. Unless, of course, you build a robot to do the dirty work for you. That’s what [Kalfalfa] did, using some Phidgets boards, a camera and Open CV. You can see a video of the cardboard machine doing its thing below.

Maybe it is because we are more electronics-minded, but we were impressed with the mechanism to grab just one bead at a time from the hopper. If you watch the video, you’ll see what we mean. However, sometimes a bead jams and a magnetic sensor figures that out so the controller can reverse a bit and try again.

You’d think the color detection would be tough. There was a time when this would involve filters and light sensors and all manner of crazy gyrations. Now it just takes a cheap camera and OpenCV. Of course, RGB LEDs can get rid of filters, too.

The code is, in fact, surprisingly simple, so if you ever wanted to dip your toe into Open CV, this might be a good one to study even if you don’t need to chromotize (yes, we just made that word up) beads.

Oddly, we’ve seen a similar mechanism before made mostly with Lego, but — alas — the link from 2014 is dead although the YouTube video survives.

29 thoughts on “Robot Sorts Beads By Color

    1. Sorting 500 beads at a rate of 3s/bead would take 25 hours. This seems very reasonable- a lot of projects take longer, especially if 3D printing is involved. If I were building this, I wouldn’t be worried about optimization for speed.

      1. After getting it working, you can optimize for speed. With most of the hardware done, that shouldn’t take too long.
        With 25h for 5000 beads, it is just like a few projects that I did: ETA of “letting it run” is further away than the project of getting it faster and running the optimized program.
        There are three projects that I remember. First was the DOS sort program. It was terribly slow and could not handle big files. My version did do big files. The seconds was to rotate an image by 90 degrees on a computer that didn’t have enough memory. It was “pnmflip” IIRC that had an ETA of days or weeks. The last one was much more recent. e2fsck was expected to finish in about a month. Fixing the code in e2fsck to get it done in a few hours was about the same in programming time as the actual runtime of the program in the end. (You have e2fsck on your computer? You have more than a million files? You didn’t wait a month for fsck to finish? You’re welcome!)

        1. Those sound like great projects! Perhaps my previous comment wasn’t as nuanced as it should have been- optimization can be quite useful, as shown by the code you have described.

          A lot of my programming has been in areas where optimization isn’t always required, as long as the code runs (and finishes running in ~1 week). I have seen some awful code (including, unfortunately, some of my own code) achieve its purpose and be considered acceptable despite having serious inefficiencies. I try not to become complacent about inefficiency, but the temptation to do so exists. This isn’t representative of most coding situations, where efficiency is of vital importance.

          I still don’t wish to criticize the efficiency of the bead sorter- the picture of the sorted beads shows that it was able to accomplish its task. Perhaps the creator would have saved time by increasing efficiency, but I don’t know either way. If running the bead sorter is unpleasant (ex. if it requires lots of human intervention, or it is loud, or causes EMI issues), or if the beads are urgently needed, then I would consider optimization to be critically important. If the machine is able to run unobtrusively, and the beads aren’t needed for a while, then I wouldn’t think optimization is necessary.

          tl;dr: maybe optimization would have been useful; maybe not. Either way, optimization is usually a good idea. Either way, this is a great project.

    2. ~3 seconds per bead that actually happens ends sooner than “there has to be something faster” that doesn’t.

      Never underestimate the bandwidth of a station wagon full of tapes, or the throughput of a machine that can chug away in the background with minimal supervision.

      1. But what about those circuits that call for an original 1964 27/64 of a Watt non E series value, 16.5% tolerance part in ceramic, shaped like a coke bottle, that you might otherwise just have up and thrown away.

        1. I know I’m going off-topic here, but this reminds me of articles I remember seeing in hobby electronics magazines in the 1960s and 70s. It seemed like every project had at least one part that was somehow special, that there was no way you were going to have one on hand. What I didn’t realize until much later, was that these articles were written by lazy authors, who were just taking schematics from the application notes of component manufacturers, showing off their proprietary parts. Unijunction transistors, tunnel diodes, dual-gate MOSFETs, whatever. And later on it just got worse, with circuits built around proprietary integrated circuits you couldn’t buy in unit quantities anyway.

          But to answer your question directly, if you come across a circuit calling for a super-specific part, just be glad you dodged a bullet by NOT having that part on hand!

    1. You’re not seeing things. But I would wonder whether they’re -mis-classified or -un-classified – I would want a bin for those beads whose colours could not be classified on the first pass, if only to allow the process to continue with the remaining beads.

    2. Bin 17 clearly contains beads that don’t have a bucket, such as yellow or black. I’d be more worried about bin 8—it’s supposed to be white but has several cyan, peach, and yellow beads as well.

    1. I want to see a hexapod scout that can successfully retrieve lost stuff like SMD components and tiny springs and screws from the carpet and other nooks and crannies of the room, autonomously. Well, and somehow avoid getting stepped on. What…? No, it doesn’t need magic, I’m telling you, just sufficiently advanced technology…!

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.