Home Creators Posts Import Register Favorites Logout

Content

There’s a famous anecdote about a professor back in the 60s giving a student researcher the task of getting computer vision "working" as a summer project. That was a bit of an underestimation of the problem as to this day thousands of researchers are still working on computer vision.

I hope I’m not still working on this puzzle robot when I'm 80, but boy do I feel their hubris. You see the reason I wanted to do the puzzle robot was that I knew it was a hard and interesting software problem, but also something thought I should be able to knock out in a few weeks...

Before starting the project I roughed out what I thought was a viable jigsaw solving algorithm. It was designed to deal with what I predicted would be the fundamental challenge: ambiguous piece fitting. Puzzles have many pieces that are a near perfect fit, but don't actually work when you try to assemble the rest of the puzzle. This means you can't just look at two pieces and determine if they fit - you have to consider the entire puzzle. 

These pieces don't actually fit...

The simple algorithmic way to solve this would be to figure out all possible connections between every piece and try every possible combination of all the puzzle pieces until you get one that works. The slight issue with this approach is that the number of possible combinations is a good practical approximation of infinity. You could do it, but it would take a computer thousands of years.

Knowing this, my algorithmic strategy centered around several strategies to narrow down the possible solutions and hopefully solving the puzzle in a reasonable time. What I didn't anticipate was the difficulty of getting accurate (enough) physical measurements of each piece. 

Measuring a puzzle piece with a camera will always have some amount of error. This error will make the computer think the pieces are a slightly different shape than they are in reality. If you are too strict when you compare pieces, you might conclude pieces that actually fit, don't. To account for this there needs to be some wiggle room in your comparisons. The downside of wiggle room is that it usually results in a bunch of pieces that might fit. 

Is this a bad fit, or is it a good fit with a bad camera measurement???

If you have a lot of error in your camera measurements, you will need a wide tolerance which will make it look like a metric-heck-ton of pieces potentially fit together. Unfortunately for me, there's a lot of error in my measurements. When I feed all the camera images into my algorithm it does the computer equivalent of making the skull with crossed eyes emoji followed by the tombstone emoji and then pinwheeling indefinitely.

You may recall that I used high quality telecentric lenses specifically to get accurate measurements of the pieces. Unfortunately a high quality lens doesn't really help if you're using a low quality puzzle. The puzzle I'm using has many incomplete cuts which gives the pieces fuzzy edges which makes the actual shape of the piece ambiguous. The other challenge is self inflicted: to get an all white puzzle I had to buy a not-white puzzle and paint it. Painting the puzzle resulted in many pieces with small droplets of white paint stuck to the edges which thoroughly mucks up my algorithm. 

I would love to just buy my way out of this problem with a higher quality puzzle but I can’t find another puzzle with similar piece count and dimensions to fit on my robot table, nor can I find any big all-white puzzles.

I spent much longer than I should have trying to fix these issues in software. It was a protracted cat and mouse game of implementing heuristics that would get the solver working better, but then running into a new issue. I kept saying “one more day and it should work” for 3 weeks before my card tower of software heuristics became too unwieldly ridiculous even for me and I decided to rethink my life choices. 

My tack now has been to de-garbagify the input by physically fixing the puzzle pieces. I started by manually cleaning up the edge with a razor blade, but after timing myself doing 50 pieces I had a projected completion time of 63 hours. I’d be willing to do that if I had to, but it motivated me to think harder and I came up with the idea of vibratory tumbling all of the pieces for several hours to remove any burrs, fuzzies, bits of paint, etc.

I ran the pieces in the tumbler and it is a MASSIVE improvement to the piece images. False matches are way down and I think it took the project from intractable to “I think there’s a chance.” Territory.

I’m still not out of the woods. I spent the past week trying to get my ‘solution-space-reduction’ algorithm working. It keeps telling me that it solved the puzzle, but when I look at the results it is telling me the correct solution is to randomly stack all the pieces in an overlapping pile. It also doesn’t help that my puzzle is missing several pieces...

So that’s where I’m at and hopefully explains why this one is taking me a long while to complete. I say this every time, but I’m definitely going to try to do something easier for the next project ;)

Thank you all so much for the support! You enable hard long projects like this to be done.

- Shane

Files

Comments

OpenSourcES

We appreciate your hard work and wish you the best to achieve it but I'm pretty sure you do 😊

Caleb Johnson

Welcome to integration hell. 😜 I would love to see multipart video on the problem solving and failures.

Joseph Catrambone

Any chance you'd be willing to share the raw image dataset from the pieces somewhere? I don't imagine I have any kind of solution, but it feels like it might be fun to fiddle with it. Perhaps it would give us a chance to throw our code at the problem, too?

Xelgium

Tl dr; pain and suffering, and lots of it... 😂 but in all seriousness, you sir are a man of commitment, focus, and sheer will. I don't think anybody would have committed this much time and effort into such a difficult project. This is truly inspiring and I hope it all comes together soon! Stay strong! 😁

Kevin Moore

Every time I think "this puzzle robot problem couldn't get any more complicated," you swoop in and prove me wrong. But if anyone can figure it out, it's you.

Thomas Maufer

I'm clearly not giving you enough support. ❤️😂 Thanks for the work you do, and for explaining why it's (1) difficult, and (2) fun.

mohammad shobaki

This is a genuine Herculean task, but I wish you all the luck in the world in solving it. You are without a doubt the YouTuber who most floors me with the difficulty of your undertakings. Keep it up! I’m a proud supporter

Deejay Riley

Did you consider another way to "image" or measure the pieces? The first thing that comes to mind is a line laser scanner. They are pretty accurate at measuring and the color or texture of the piece shouldn't matter as much. Regardless, I applaud your efforts thus far!!!!

Oleksiy Pikalo

Im sure you have considered context based image search problem, ie. finding the placement based on the camera input on top of the piece. Last time i tried, it worked pretty well with out of the box opencv. Will not work with the hardest puzzles that offer no clue though.

Evan

Are you doing the image matching step locally? Have you considered just throwing a couple instance-years of cloud compute at it?

Evan

Time is money, and it works both ways

Jeff Geerling

"This video was sponsored by NVIDIA, who just so happened to donate this set of 6 racks full of A100 GPUs along with this 1 megawatt generator..."

Evan

I've definitely seen videos sponsored by both Azure and AWS so not out of the question

Barry

Of course the answer will be obvious, once you find it. Until then, you must plow through all of the other 'obvious' answers. But you'll be so much wiser by the time you get there! Thank you for sharing the journey with us...

Chris B

New video idea, proving that P=NP

NotMyRealName

Hahaha. I can almost imagine the algorithm being sentient and having some malicious compliance: you never explicitly defined the coordinate plane in which the pieces must fit together so I chose to fit them together along Z axis.

Andrew K Dickey

Robotic Parking - a suggestion for your next project. Problem: automated parking garage where people drive up and leave their car. It is parked for them and then retrieved when they come back. Like valet parking, but no valet drivers, much denser parking, and, hopefully, no dings and scratches. Assume a parking garage with a flat concrete floor. You could have an XY coordinate system on the floor for accurate location. You would have a bunch of little independent robots (start with four). Each robot would have the ability to lift one tire and then, in coordination with three other robots, move the car to a parking location. Later, when the patron returned, four robots would go retrieve the car, At some point it would be turned to face outward. There would be close to zero clearance between the parked cars. Cars would be moved around as necessary to be moved out of the way if a blocked car needed to be retrieved. The robots would low enough to move under the cars. The robots would automatically park at a charging station for recharging as necessary. Any robot could work with any three other robots. Have fun!

Estelle Comment

Why yes of course, throw it in the vibratory tumbler that I happen to have. After that slap it on the plasma emulsifier, and through the spaghetti tangler, and bam! Puzzle done!

Dovydas Norkūnas

I cought myself thinking of some mechanical scanning, but that's probably too wild idea:Dd Best of luck, so lovely to get some insides of the process.

Ben Pearson

I almost wonder if it'd be easier to manufacture a puzzle with the required precision to make the problem easier. Hmmm...

Justin C

Thanks for the update. It is a really interesting project!

John Long

Thanks for the detailed update!

YJ Choi

I’m sure the irony isn’t lost on you that solving the problem of making a puzzle-solving robot is in itself quite puzzling. Keep up the great work, and I can’t wait to see the next video!

James Hancock

These guys are in a workshop next to my office. Super high-quality wooden jigsaws that can all be custom-made (with any shapes/colours you want). https://www.wentworthpuzzles.com/ You would have to order from the UK, but may be worth the effort. For a puzzle lover, it is worth going on their site anyway, they do beautiful things.

Kevin McClaning

Interesting update! Thanks. You continue to astound me! Maybe, just maybe, you might want to begin to consider simplifying the problem a little. Maybe drop the idea of an all white puzzle and make use of the image information on each piece to help seed the which-piece-goes-where algorithm? When you solve that problem (as I have every confidence you will), you could use the insight develped to find a way ahead for the uni-color puzzle (if you haven't run out of steam by that time).

Christopher Preston

How about using a document scanner some how to get better images of the peices?

Zach Brown

Shane is quickly learning that cardboard not only doesn't taste good, but is also pretty hard to chew.

Jiawei Zhang

I use vision machine in my work to detect burr of extrution parts so I know why it's so hard. Really looking forward to see how your project goes.

Brian Reczek

Do you think the off shapes could be from a slight shadow from the angle of the light source? It might not be too noticable but maybe just enough to throw it off? Idk just a thought

EEE

False matches makes this so interesting and hard. At first I was trying to think of how you could index piece shapes to make looking up matches faster (hole/tab size, side length), curious if that gets you to 5 potential matches or like 500. If smaller side, some algo techniques (hashing,memoizing) could help a lot. Also very parralelizable especially when branching on possible matches. I'm also really curious about other techniques to reduce the number of pieces you need to compare... Especially how humans solve puzzles i.e. do the edges first and work in. Any matched pair means 2 sides you never need to check again so the complexity gets smaller at least. It feels like the wrong answer from an algorithm sense (that's why indexing/hashing hit me first), but maybe with the false-match branching factor it's necessary.

EEE

Probably all things you've thought about and tried just found this blend of practical system and algorithm fascinating!