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. :)