Monday, March 30, 2009

(Lisp) is mind-numbing

Well, not entirely Lisp... its actually (lush). But the parentheses... Oy. Thank god for Emacs paren highlighting. Here's the whole thing: robotest.lsh, but here's just a little sample of the beauty of (lush) syntax:

(setq len (* h (/ (- (* k f) y) (+ (* k y) f))))

Just like http://xkcd.com/224/ and http://xkcd.com/297/!

The whole point of this was to take in an image (top), mask out the color (bottom) by first eroding, to eliminate noise, and then dilating, to get back the origninal big blob of color (the eraser):

Then that formula (above) tells the robot how far the object is from it, based on how many pixels down the screen the middle of it is, how high off the ground the robot's lens is, and its focal point (-371). That distance formula took a whole classroom a while to figure out....

This is for a Rovio robot (which is controlled over wifi), and that picture was taken from the robot.

Labels: , , , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home