Neural Net book
For a book on a kind of dry subject, this book has an oddly humorous tone:
“It is also interesting to rotate a frog and notices that his eyes try to maintain their orientation up to some maximum angle at which time the frog will close his eyes, giving up the attempt at computing the appropriate adjustment of the visual input. Try not to let anyone see you doing these experiments”
“If a hole is punched in the visual cortex, V1, the only apparent deficit is a hole in the field of view… There are anecdotal records of people receiving damage to this part of the cortex. They report seeing President Bush’s thousand points of light.”
“At a recent neural network conference, Minsky tried to clear up the misconception that he was the devil.”
That last one is because Minsky wrote a proof that single-layer perceptrons can’t do the XOR operation, and funding for neural networks dried up for years. This made him unpopular with the people who had been getting that funding.
Rave in a Briefcase
As part of preparations for a local party, I am building a sound system to fit in a small suitcase and run on 12V DC. The system consists of a small DJ mixing deck and a car audio amplifier. Powering the car amp is easy, as it was designed to take 12V DC power. Powering the mixing deck is not so easy.
Mixers are audio gear, so they tend to have audio signals that are AC, and have components above and below 0V. As a result, they have double-ended power supplies. For the mixer I have, there is an 18V AC power brick, which gets rectified, filtered, and put through a +15V regulator and a -15v regulator. 15, being higher than 12, is an inconvenient number of volts to get out of a 12V battery. Since it’s double-ended, I really need a voltage spread of 30V, with a 0V rail in the middle.
The simple, stupid way to do this is to power the rig with two 12V batteries and two 6V batteries. Across each set of one 6V and one 12V, I would have 18V, and if each of the pairs of batteries shared a common ground, that would be my 0V rail. Unfortunately, I’d also have to manage charging, connecting, and monitoring charge on all of those batteries, not to mention carrying them to wherever I was using the audio. Lead-acid batteries are heavy. Since this is inelegant, heavy, and requires lots of fiddling, I’m going to call it “Plan C” and only do it if everything else fails.
Another simple solution is to use a 12V DC to 120V AC inverter. That takes up a lot of space, and isn’t all that efficient, but it means I don’t have to build a replacement power supply for the amplifier. I have all the parts for it, and it requires less hauling and fiddling than Plan C, but it is still inefficient, so this is “Plan B”.
Since the AC wall wart is rated for 300mA, I have an upper bound on what the mixer can draw. That means I can start looking into DC/DC converters. Vicor makes a 12V to 15V converter, but it costs $99 dollars and I would need two of them. Since I don’t need a lot of current, I can probably make a pair of step-up converters that have a 15-18V output. This site has a simple schematic, and more importantly, the equation for the output voltage, given the current and frequency of a switching circuit in the converter. The control IC takes care of monitoring the output voltage and varying the frequency, but I may be able to use a simpler circuit and change the frequency by splitting off part of the output voltage and feeding it back to the RC timer circuit.The whole circuit would be small, and probably more efficient than using an inverter and the power supply of the mixer.
What is going on
I started this blog to keep a sort of running list of what projects I have going on and my progress on each of them. Instead of doing that, I’ve been working on the projects and ignoring the blog.
My main project right now is the Seizuredome. The “dome” part is an icosahedron made out of electrical conduit. Five of the faces of the icosahedron are left off, and it rests on the ground on that side, forming a sort of dome. I used the construction techniques from Desert Domes to build the frame, but the process is essentially flattening the ends of the pieces of pipe and drilling holes in them so they can be held together with bolts. There is a picture of the completed dome frame in a previous post. That frame will be covered with mylar “space blankets” to provide a reflective surface.
The “seizure” part of the dome is a little more complicated. If you close your eyes and look at a bright light, you can still sort-of see the light, as a red glow through your eyelids. If that light pulses in the 5-20Hz range, you would expect to see the blinking through your eyelids. Instead, most people end up seeing colorful patterns, like swirling fractals, tye-die designs, spiderwebs, and such. What happens is that the blinking signal is close enough to the patterns of electrical activity in the brain that it can drive the dominant frequencies of neural activity to synchronize with it, resulting in hallucinations and mildly altered states of consciousness. You can buy goggles with blinking lights in them, or make your own devices, which will allow one person to do this. I’m building a photic driver for multiple users.
The Seizuredome will have a bright red strobing light in its center. This light is made of 20 1-watt red LEDs mounted on the surface of an aluminum icosahedron. Each LED is driven by a constant-current driver, which is controlled by a TLC5940 LED driver chip. The TLC5940 chips are controlled by an Arduino. Power for the whole thing is supplied by a LM7805 supply with a beefy pass transistor. That light will be hung inside the reflective dome, illuminating the inside. Since the light is suspended inside a reflective dome, there will probably be no place inside the dome that isn’t strobing red, so users inside the dome will be able to see the psychedelic show by entering the dome and closing their eyes.
That still doesn’t really answer why I called it the Seizuredome, though. I turns out that some people are photosensitive epileptics, but don’t know it. Strobing lights of the frequencies most likely to cause seizures by interfering with neural electrical activity are rare, and don’t usually last long enough to trigger seizures. As a result, it’s possible for someone to grow up without ever seeing a blinking light that is intense enough for a long enough time to cause a seizure.
Until now.
Seizuredome!
This is the framework for a geodesic dome. It will be wrapped in mylar blankets to make the interior reflective and lit with a very powerful red LED strobe. Anyone inside it will be able to get brain-machine-like effects by sitting and looking at the strobe.
Of course, it could also cause seizures in previously undiagnosed photosensitive epileptics, so there will have to be warning signs.
Lex and Yacc syntax highlighting for Nano
There’s not a lot to them, but it’s better than anything I could find on the Internet. The real key feature is a line in the yacc syntax highlighting file that marks whitespace at the end of lines. Since yacc/bison are sensitive to that, it’s good to be able to see it.
Nano syntax highlighting for yacc or bison:
## Syntax highlighting for yacc/bison input files syntax "yacc" ".y$" color red "%[a-zA-Z0-9]*" ## String highlighting. You will in general want your comments and ## strings to come last, because syntax highlighting rules will be ## applied in the order they are read in. color brightyellow "<[^= ]*>" ""(\.|[^"])*"" ## This string is VERY resource intensive! color brightyellow start=""(\.|[^"])*\[[:space:]]*$" end="^(\.|[^"])*"" ## Comments color brightblue start="/*" end="*/" ## Visible space at line ends color green,green "[[:space:]]+$"
Nano syntax highlighting for Lex or Flex:
## Syntax highlighting for lex/flex input files syntax "lex" ".l$" color red "%[^[[:space:]]]*" ## String highlighting. You will in general want your comments and ## strings to come last, because syntax highlighting rules will be ## applied in the order they are read in. color brightyellow "<[^= ]*>" ""(\.|[^"])*"" ## This string is VERY resource intensive! color brightyellow start=""(\.|[^"])*\[[:space:]]*$" end="^(\.|[^"])*"" ## Comments color brightblue start="/*" end="*/"
Magic Card Code
Now available at my GitHub repo. Note that using these scripts is probably a horrible violation of Wizards of the Coast’s ToS for their website, and can probably get you banned.
More on recognizing Magic cards
Computer vision is hard.
I have code written that detects edges in a video image, picks pairs of edges that are both within a certain ratio of lengths relative to each other and within a specific angle of each other. I’ll post the code up once I have pushing to my github account set up correctly. It’s actually pretty poor at locating cards in a video image, but it is a demo of how to use some of the UI and feature recognition stuff from OpenCV.
From here, I have a few ideas about how to proceed. The first is to have the program display a rectangle and ask the user to align the card to that rectangle. This means the program will not have to find the card in the image, and can focus on recognizing parts of the image. This will use template-based recognition to pick out mana symbols, and should be pretty simple. The classifier that tries to pick out colors will be even easier, as it will just select a sample region, blur it, and match it to precomputed colors. This can be calibrated for specific lighting conditions for each run.
An even less hands-on approach was suggested by my co-worker Eric. The cards could be displayed by a machine that essentially deals one card at a time. The machine would have a magazine of cards, and would photograph a card, deal it into a hopper, photograph the next card, and so forth, until it was empty. This would have the problem that it wouldn’t be something anyone could download and use, as it would require a special card-handling machine, but the software end would be compatible with the user-based registration approach described above, so someone with a lot of patience could use the manual method.
Another approach would be to throw all the cards on a flatbed scanner (possibly with a funny-colored (e.g. red) bed lid, do template matching to locate card borders, and then segment the images based on that. An ADF scanner with a business card attachment could probably also make short work of a modestly-sized set of cards.
Magic Card Recognizer
I used to play the collectible card game (CCG) Magic:The Gathering. Like most CCGs, Magic has a large set of different cards that players can use to build a set for playing games. This is both fun, as it means new cards will allow new play types and strategies, and annoying because of the artificial rarity of some of the cards. I don’t have a lot of people to play with, so I am planning to sell my cards.
I will probably make more money selling the cards as individual cards (“singles”) than I would get by selling the whole set. However, that means that I need to know how many of each card I have. Given that I probably have upwards of 8,000 cards, I don’t want to sit down and type in the name of each card. It would be better if I could have a computer program do it for me, so I’m working on writing one. The rest of this article uses jargon from Magic and computer vision, so it may be a little incomprehensible to people who are not Magic-playing computer vision nerds.
The program will take an image using a web cam and look for two straight edges, probably using some form of edge detection or a Hough transform. Once it has the edges, it will look for two edges whose ratio of lengths is the same as a Magic card. The edges must share an endpoint, so that the system can tell they are the edges of the same object. The area inside the rectangle that has those lines as its edges is the card.
Once the card is detected, the simplest thing to do is to match the card image against card images stored in a massive database of all card images. Unfortunately, there are over 11,000 unique cards (11,458 as of Feb 2009), which would make for a processor-intensive comparison process.
My plan to circumvent this is to have the program get the casting cost of the card by using processing techniques similar to face detection. The most useful technology to detect mana symbols is probably feature-based template matching. Feature-based template matching allows the computer to pick out a region of a picture that matches another, smaller image, even in the presence of some distortion. Mana symbols haven’t changed significantly since the development of the game, so they should be easy to pick out.
I can also get the color of the card by selecting a region of border, blurring it to remove any texture, and comparing the color to a set of swatches. I’ve done this sort of comparison before, by measuring distance in RGB color space, and it can be done quickly and effectively. The main possible pitfall is poor lighting shifting the color of the object, but I can at least arrive at a probabilistic result based on the RGB distance. Combining the estimated color of the card and the casting cost will allow me to significantly reduce the set of possible pictures that the card image needs to be matched against.
There is also the question of building the database of card images, but I believe I can do that by screen-scraping the web site of the company that makes Magic Cards. I won’t be able to distribute the database with my program, as it will contain copies of copyrighted data, but I can distribute the screen-scraping script.
I may also be able to recognize features like card text, but that will rely on very good lighting and very good cameras. I would prefer that this program work with a moderately high-quality webcam, so that it will be useful to people other than me.
The recognizer will try to build a list of cards that it thinks matches, ordered by the confidence of the match. If the user rejects the first card, it will present the next, until it runs out of guesses. If the use accepts the guess, the recognizer will add that card to a database of all the cards the user owns. In this manner, the user can build a database of cards by simply showing the cards to a computer.
Inspiration
There are a few DIY plasma cutter plans floating around the Internet. Most of them are napkin-sketches that someone scanned and put on a forum for experienced welders to blanch at.

This has a few issues. The main one is that it’s not properly isolated from the AC mains. An isolation transformer can provide that isolation, and can be improvised from two identical transformers back-to-back, with their secondaries connected. That will act as a 1:1 transformer, but instead of having a conductive path from the input to the output, the power is passed by induction.
I am making a plasma cutter with a pair of isolation transformers made from microwave oven transformers. I chose microwave oven transformers because I can get them for cheap or free, and they can handle a lot of power.
After I wire up my variac, I’m going to test the power supply. Assuming all goes well with the test, I’ll look into getting a plasma torch head off Ebay or from Harbor Freight, and finish the assembly with a borrowed or improvised air compressor.
Cracking Captchas
Captchas are those distorted snippets of text that some web sites use to try to prevent spammers and bots from automatically registering accounts. The idea is that a human can read the words, but a computer cannot, and so only a human can fill out the text box correctly.
However, it’s probably possible to get humans to crack the captcha for fun. Imagine a “missile defense” typing tutor and game, where each incoming missile is a captcha text. If you type the text, it goes away. Since the game can’t tell what the texts are to begin, it would send the same word to multiple players and only block the “incoming missile” when multiple players typed in the same thing. From that, it could build a massive database of images and corresponding text, which could then be used to register accounts. Alternatively, someone who wants to crack a captcha could submit it to a server, which would then include that captcha in all the currently-running games and reply with the text when several people typed the same thing.
Recent Comments