Monday, June 11, 2007

Pong Playing Computer playing against another computer using a webcam as an eye!


Download video (5.54 MB)

Several years ago, when I was a stupid little schoolboy, I created a really fun and addictive game called Ping Pong. It was based on the classic arcade game, PONG, and had some cool features like gradual speed increase, two game modes, and some neat sound effects.

I had almost forgotten about that game until I saw this auto wood-chopper project in which a computer plays a simple game on a PSP using only a webcam to view its screen. I thought the idea was pretty good. So, I decided to make my own computer play that old pong game of mine on another computer using a webcam for vision! I fired up my code editor, and after several hours of coding and experimentation, my image recognition code started looking good. It uses edge detection to determine the boundaries of the ball and the bat in the webcam’s field of view. The area of the ball is more than the bat, so that’s how it differentiates between the two. The other steps are more or less similar to the things I did for my object tracking app. Like the auto wood-chopper dude, I thought about using motors to press the keyboard keys on my laptop. However, I thought it would be overkill when I could write a simple TCP client/server program to establish communication between the two computers.

Be sure to watch the video above! I’d love to hear what you think. Oh and here’s a similar project in which a computer plays Minesweeper on another computer using a webcam – wow!

You can download my fun Pong game from here. (1.20 MB)

This was a very exciting project. In my opinion, one of the coolest webcam based projects I’ve done so far. I entered the world of webcams after working on CamCapture – a project based on a Coding4Fun article by Scott Hanselman. :) Webcams are fun but I sometimes wonder why they’re called Webcams. I never use them for online video conversations! In my opinion, they should be simply called USB cameras. :)

Opto-isolated Parallel Port Driven Relays

A few months back, I made a parallel port driven relay box for Engineer 2007 with four outputs which were opto-isolated from my PC. Since I didn't have opto-isolators, I built my own by taping LED/photoresistor pairs together. It worked perfectly.


I also combined it with laser gesture recognition to turn four appliances on or off using a laser pointer for Engineer 2007. I guess everyone loved it. :)

If you can make pcbs, and are interested in a simple little circuit
to provide opto-isolator protection to 4 parallel port inputs, and relays on the other 4 bits, as outputs, then check the offer on....

http://www.arunet.co.uk/tkboyd/ele1pp.htm


... which is a little way down the page, next to the Google panel, in
the paragraph starting "I have a third generatino, inexpensive...".