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. :)
38 comments:
Wow...you're amazing.
Awesome!
Thanks :D
Simply cool .. :-)
Man this pisses me off, the damn computer plays pong better than me! ;)
i want to have time to do such things ...
Very cool :>
Next step : a robot & real ping pong table ?
Well done Ashish! that was well thought of and executed.
really cool! you are becoming an expert on cameras and image recognition! :)
next step is face recognition for a robot, i think ;)
Thanks everyone. :D
@nico: Real ping pong? That's a really cool idea..but I bet it'll be really difficult too! Well..I guess nothing is impossible. :)
@niko - italy: Thanks for the comment. :) I've been thinking over face recognition for quite a long time..its a really cool thing. Some people have definitely achieved face detection..I have no idea how advanced face recognition is right now. I guess face detection should be the first step.
Soooo ehm who won?
I'm a little disappointed.
With the information provided you could have your "bot" determine the angle and velocity of the ball in a fraction of a second, and have the paddle be exactly where the ball will hit every time. Rather than simply matching the y-coordinates.
And better yet, it could adaptively use the full length of the paddle to put the ball as far away from the other player as possible.
Nice idea, but you could do better.
@jared: I thought about determining the angle and velocity of the ball..but then I thought it would just make things more complicated. However, I think I'll give it a try. :)
That's pretty cool! So who won? And how long did it take? I assume neither opponent won if you didn't increase velocity.
Yeah, they keep playing for hours if I don't increase velocity. If I make the ball go really fast, the image recognition code ultimately fails to track the ball quickly enough. :)
Awesome!!!!!!
Sweet!!
Thats pretty neat ! Keep up the interesting work.
Great Idea ! Now we are closer to Terminator Scenario!
In a hurry, but check this out: http://www.imageaddicts.net/uploads/collision.jpg
After work, I checked the file I uploaded. The resolution was low. Try this higher resolution grayscale version:
http://www.imageaddicts.net/uploads/collisionBIG.jpg
Eventually I will get around to fully implimenting this method in my flash pong game.
For anyone out there looking for info on line intersection detection or how to test if two line segments intersect, I have plenty of code to share.
Nerd... Nerd... Nerd...
soo cool
it is cool. very cool enough~
Not bad ;) I love pong!
Cool software Ashish.
What programming language did you use for the pong game?
You could've used Camstudio, instead of Screen Recorder Gold.
What's the background music?
can u help on how to do that? would u mind to send me steps to make that.... just like yours...im interested b4 in programming..and iv seen what youve got so i like it
you can contact me @gbtniel@yahoo.com
When both PCs become "aware", we'll have you to thank. Very cool. Nice tune selection.
Good Job! :)
This is a great site. Thank you for your information. I THANK YOU I SALUTE YOU IT,S A AMZING SITE.
Hey,
Thanks for that important information, it really helpful..Interesting article
It was your great attempt yaar
Awesome work!!
It is extremely interesting for me to read this post. Thank you for it. I like such themes and everything that is connected to this matter. I definitely want to read a bit more soon.
Post a Comment