Share My Creation Automatic Pong Player (experiment)

This is a funny experiment which I've had in my head for some months but never went into it. At the end I found the time and it was not as hard as expected. At least the basic concept.

The idea was to build an automatic Pong player using OpenCV and some Android devices:)


How it works:

A central device is the 'tennis court' and visualizer.
  • It animates the ball, calculating collisions against the walls or the racket if the ball hits it
  • The racket position is controlled by means of an UDP socket.
Then there is a second device (in fact two, but the video is limited to one as I made a one player version for simplicity), which is the Player:
  • It looks at the first device screen using its back camera
  • The preview is analyzed using OpenCV
  • It detects the court boundaries (blue squares) and the ball using colorBlobdetection. Then perspective is 'corrected' and calculates the ball position, relative to the court. With this information (and at this moment nearly no 'intelligence', since it only follows its vertical position) it calculates where the racket should be in order to hit the ball.
  • As the devices are connected through Wifi (the player knows the IP and port of the first device), the new racket position is sent through UDP

At this moment the 'player' is a bit clumsy and misses some balls :D. There are things to be improved, such as choosing other colors and make detection more reliable, since the squares used are very small and detection also depends very much on light conditions.
 

Attachments

  • vlcsnap-2017-10-03-00h57m27s863.png
    vlcsnap-2017-10-03-00h57m27s863.png
    237.4 KB · Views: 3,225

Sandman

Expert
Licensed User
Longtime User
Pongception! Very cool indeed.

Now you just need to figure out how to make this a circle of 36 mobiles filming each others screens... ;-)

a88.jpg
 

JordiCP

Expert
Licensed User
Longtime User
I only have 35 ;)

What would happen if one of them displayed a red dot for one second? how long would the image remain in the circle? :eek::rolleyes:
 
Top