Webcam Jigsaw Solver in 200 Lines of Python 199
leighklotz writes "Jeff Breidenbach and 200 lines of Python code have brought us the Glyphsaw Puzzle solver. Hold a puzzle piece up to a webcam, and the display sgiws exactly where in the puzzle the piece belongs. The solver uses the Python Imaging Library (PIL), Numerical Python, and the PARC DataGlyph Toolkit. By the way, you can make your own DataGlyphs."
First (Score:5, Funny)
Re:First (Score:2, Funny)
from puzzlesolver.puzzlepiece import puzzlepiece
from puzzlesolver.placepiece import placepiece
Yes, my python skills are quite good.
Re:First (Score:2)
Re:First (Score:2)
sgiws? (Score:5, Funny)
Re:sgiws? (Score:5, Funny)
Re:sgiws? (Score:2)
Re:sgiws? (Score:2)
Re:sgiws? (Score:2)
Are you trying to embiggen our language?
Re:sgiws? (Score:3, Funny)
English, please?
It's a welsh word, you insensitive clod!
Google knows all (Score:5, Funny)
Did you mean: shows
Re:Google knows all (Score:3, Informative)
Re:Google knows all (Score:2)
Yes, I typed it on my hiptop [danger.com].
Full disclosure: Danger is located in Palo Alto. I don't work for them. They're near Fry's though and I do sometimes go to Fry's.
Re:Google knows all (Score:2)
Re:Google knows all (Score:3, Interesting)
Re:Google knows all (Score:2)
Re:Google knows all (Score:2)
Re:sgiws? (Score:5, Funny)
r;r,rmystu.
Re:sgiws? (Score:3, Funny)
Re:sgiws? (Score:1)
Re:sgiws? (Score:2)
Re:sgiws? (Score:2)
Re:sgiws? (Score:3, Funny)
Re:sgiws? (Score:2)
Re:sgiws? (Score:2)
(Please, no Spanish Inquisitions over my seeming ignorance of the etymology of Python.)
Re:sgiws? (Score:2)
(His left hand was in the right place, but the right hand was shifted left by one key).
Re:sgiws? (Score:2)
Re:sgiws? (Score:2)
Re:sgiws? (Score:2)
its (Score:1, Insightful)
Re:its (Score:3, Insightful)
at first glance I thought it was a program that could solve jigsaw puzzles by analyzing each piece, its shape, the image on it and figure out where it goes in realtime. that would be really interesting as it would probably have to employ some crazy neural net algo to avoid exponential time.
ahh yes... (Score:2)
Looks pretty good right? I just have to fill in a few unimplemented functions.
Re:its (Score:2)
Other applications? (Score:3, Interesting)
Not really, sadly. (Score:5, Informative)
If you have a jigsaw made using this technology where the embedded data indicates the location within the original image, you can use this software to decode that data and display where the piece should go. It doesn't look at the actual image at all, and thus wouldn't help you solve any 'normal' jigsaws, or do any sort of general image recognition.
It does use some similar techniques to facial recognition to identify the intersection points and enable the glyph decoding, but that's all.
Re:Not really, sadly. (Score:2)
If you would just step into your federally approved tattoo parlour please, it will just take a minute...
Re:Other applications? (Score:2)
Needs DataGlyphs (Score:5, Informative)
Re:Needs DataGlyphs (Score:1)
That's pretty damn impressive.
Re:Needs DataGlyphs (Score:3, Informative)
"PARC DataGlyphs are a robust and unobtrusive method of embedding computer-readable data on surfaces such as paper, labels, plastic, glass, or metal.
Basic DataGlyphs are a pattern of forward and backward slashes representing ones and zeroes. This pattern forms an evenly textured field.
Unlike most barcodes, DataGlyphs are flexible in shape and size. Their structure and robust error correction also make them suitable for curved surfaces and other situations where
closed source, proprietary, and astroturf (Score:5, Interesting)
Yep, and it's not only closed source, it's proprietary; to develop for it, you need to buy the eval kit and license the technology.
Furthermore, not a single slashdot reader seems to have noticed that the article is one giant piece of astroturf. The submitter's website plainly lists his address in Palo Alto, which just happens to be the site of PARC, the Xerox research center that developed the technology. Coincidence? I seriously doubt it.
Oh, and this technology is mostly used in color copiers for printing out the machine's serial number in pure yellow so you can't see it..but the document can be traced back to you (this is supposedly for the Secret Service to chase down people making color copies of US currency and whatnot, but that's a bullshit excuse now that these copiers all have currency detectors and refuse to copy currency). They don't point it out specifically, but there are various hints dropped in the FAQ about it.
Re:closed source, proprietary, and astroturf (Score:3, Informative)
>plainly lists his address in Palo Alto, which just happens to be
>the site of PARC, the Xerox research center that developed the
>technology. Coincidence? I seriously doubt it.
Except I don't work for PARC. I do work for Xerox, and Xerox is the sole stockholder in PARC, though PARC is a separate company with its own business deals. I happen to have the privilege of wandering around and finding neat stuff (under non-disclosure)
Somone should sgiw them (Score:5, Funny)
Wrong section? (Score:5, Insightful)
Since it can use anything it wants (Score:3, Funny)
[user@localhost] perl -e '`python glyphsaw`'
Re:Since it can use anything it wants (Score:3, Funny)
Re:Since it can use anything it wants (Score:2)
I don't know about you, but when I code, I *never* use any useful libraries. Programming should never be about getting something done- rather, it should be about reinventing the all the wheels, gears, axels and windshield wipers that I could ever need... In other words, re-writing the OS for each and every app! WOOT! 152 thumbs up!
More importantly... (Score:2, Funny)
But the important question is, can it assemble the puzzle faster than Gary Kasparov?
Re:More importantly... (Score:3, Funny)
No, Gary Kasparov takes a much longer time to assemble.
200 lines? (Score:5, Insightful)
Re:200 lines? (Score:2)
1. initialize DataGlyph, webcam.
2. Get Webcam image. Hand off image of puzzle piece to DataGlyph library.
3. DataGlyph library returns code. DataG
Re:200 lines? (Score:4, Insightful)
> What is a reliable means of counting LOC then?
Count every line of code written specifically for this project. Publically availabe libraries don't count; internal libraries written by the author (for use in this project or generalized internal code from a previous project does. This accurately reflects the complexity of the app from the coder's perspective.
Re:200 lines? (Score:2)
While not explicitly mentioned in the writeup, I also programmed the computer to beep when a piece was successfully processed. That added a line right there.
Re:200 lines? (Score:2)
You seem to have missed the whole point of this accomplishment.
Re:200 lines? (Score:2)
exec "if foo:\n print bar()\nelse: print baz()"
etc
Re:200 lines? (Score:2)
Anything can be done in 2 lines, if you don't count the code in libraries.
slow already (Score:3, Informative)
Jiglyph (Score:5, Interesting)
Re:Jiglyph (Score:2)
Re:Jiglyph (Score:4, Funny)
Please no more Jiglyphs (Score:2)
MOD parent up (Score:2)
External libraries (Score:3, Insightful)
200 lines of Python? At least this time they mentioned the additional external libraries, unlike with that "15-line" P2P program [slashdot.org] a while back...
Re:External libraries (Score:4, Informative)
like the tetris-playing bot (Score:5, Insightful)
Oh, and I also think it's pretty stupid to talk about how few lines it took to write the program when it's using a bunch of libraries. I could just write a one-liner that calls this program, by that rationale.
Here's the Artificial Intelligence Tetris [colinfahey.com] I was mentioning.
Re:like the tetris-playing bot (Score:2)
You are so correct, my man. What is the point of a library if you didn't write it yourself? Why, it would be utterly useless!
I could just write a one-liner that calls this program, by that rationale.
Well it's not the same, because you'd just be doing what someone has already done, now wouldn't you? This guy did something original, and he did with economy.
Re:like the tetris-playing bot (Score:2)
First, you ought to know that sarcasm does not work well in ASCII.
Second, who the fuck said libraries weren't useful? Python is great for many reasons (my favorite is that code can look like pseudocode if you don't use lambdas all over the place), and one reason is the great libraries available. I threw together a working curve-fitting program with NumPy [scipy.org], Numarray, and the bui
Re:like the tetris-playing bot (Score:2)
That would be trivial given the right processor and instruction set.
Re:like the tetris-playing bot (Score:2)
Re:like the tetris-playing bot (Score:2)
Maybe talking about the small size of the application was meant as a complement to the supporting software libraries, rather than an attempt at "taking credit"
Re:like the tetris-playing bot (Score:2)
That would seem to be supported by the note at the bottom:
The Glyphsaw Puzzle solver is implemented in less than 200 lines of Python code by making good use of the PARC DataGlyph Toolkit, the Python Imaging Library (PIL), and Numerical Python.
I don't doubt that he did make very good use of the libraries, but that doesn't detract from th
Puzzle (Score:5, Insightful)
NOW if they could do this with an off the Walmart shelf puzzle, THAT would be something.
Facial barcodes (Score:2)
Could also use this technology for foolproof facial recogtion. Just need to have barcodes stamped on your face!
You mean like this? (Score:4, Informative)
Goldberg, D.; Malon, C.; Bern, M. W. A global approach to automatic solution of jigsaw puzzles. Computational Geometry. 2004 June; 28 (2): 165-174.
Re:Puzzle (Score:2)
Indeed, and why use glyphs at all? As jigsaws are basically grids it'd be far simpler just to print the row,column coordinates on each piece - and it'd take even fewer lines of code to do the recognition, this ain't solving a jigsaw at all.
Re:Puzzle (Score:3, Informative)
Wow !!! (Score:2, Funny)
A REAL puzzle (Score:3, Funny)
One Line! (Score:1)
Coral link to this (Score:2, Informative)
http://www2.parc.com.nyud.net:8090/istl/members/j
Interesting article, but it's using a special digitally encoded pattern to "help" the software identify the pieces. You can't just input the picture from a puzzle box, then start showing it pieces, and have it solve them for you.
Didn't they just... (Score:2, Informative)
Tell me if I'm mistaken, but didn't the summary imply that it was identifying the puzzle piece by the picture on it? Now that would be cool.
So much for using this to make a face-scanner, unless we tattoo bar codes on everyone's faces.
I guess this is an interesting academic exercise, but I don't see how they've really done anything new.
This isn't as clever as you think (Score:5, Insightful)
200 lines of code? (Score:2)
Lame! (Score:5, Insightful)
Essentially it is just a bunch of puzzle pieces with 2-D barcodes printed on them, and a computer+webcam+python used as a barcode reader.
(oh, and as a bonus, the 2-D barcodes are somewhat colored so that it looks like a picture from a distance.)
It is no more a "Jigsaw Puzzle Solver" than a locomotive's wheels are an autopilot decive. They each achieve the end goal only when the rails have been laid in advance.
-CV
Oh yeah, GlyphMarks (Score:4, Insightful)
This
You wanna repeat this experiment at home? Buy a small jigsaw puzzle. Solve it. Label each piece with it's (x,y) coordinate in the solved puzzle. For instance, top-left could be (1,1), the one to its immediate right could be (2,1), and so on.
Then take the puzzle apart and AMAZE your friends when you can deduce the position of each piece simply by HOLDING IT UP TO YOUR EYES!
MOD PARENT UP (Score:2)
This uses Reed-Solomon coding for error correction (Score:3, Interesting)
I wrote a version of this library originally as a contractor for PARC when I was in grad school, to use as the error correction coding for their data glyphs. This is bsaically the same algorithm used for audio and CD-ROM data.
Actually it doesn't (Score:2)
IEEE article [parc.com].
This defeats the entire purpose of doing jigsaws. (Score:3, Insightful)
When the entire purpose of buying a puzzle is to make you do some mental work, then having that work done automatically is self-defeating.
Re:This defeats the entire purpose of doing jigsaw (Score:3, Insightful)
-psy
so what? (Score:2, Insightful)
Typical Slashdot. (Score:2)
So Jeff, please don't listen to these fools.
FOOLS... I know this is Slashdot... but go RTFA, and ignore the 200 line thing, it's a red herring.
Numerical Python (Score:2)
In Perl, PDL is a wonderful tool, but it relies on some of those ancient fortran libraries that everyone (in the scientific community, anyway) has been dragging around since the dawn of time, and getting it to compile and install can be a bear.
If Numerical Python does essentially the same thing, and is slightly easier to get up and running, I migh
Re:Numerical Python (Score:2)
Thanks for the info. I imagine all high-level languages go through this process of figuring out how to balance abstraction with number-crunching. Good to see two camps come to roughly the same conclusions independently, as it offers some credibility to both.
What a cheat! (Score:2)
Haiku synopsis (Score:2)
Jigsaw robot is
Genius solver of puzzles
Only with barcodes
Re:Anti-spam image checks? (Score:4, Interesting)
"The Glyphsaw Puzzle solver is implemented in less than 200 lines of Python code by making good use of the PARC DataGlyph Toolkit, the Python Imaging Library (PIL), and Numerical Python."
^ I bet you'd win that bet.
It's not image recognition (Score:3, Insightful)
It reads digital information encoded into the image... it doesn't look at the actual image itself. It's still quite cool, but no good for what you are thinking.
I already explained more about this to a comment Here [slashdot.org]
Messagelabs (Score:2)
Re:It's a cheat (Score:2)
See A Global Approach to Automatic Solution of Jigsaw Puzzles [xerox.com]