Next project
Outreach Initiatives and Community Awareness


What is it?

Gesture Pong is video game playable on your TV or Monitor. Your joystick or game controller is you yourself — the game tracks your body movement and converts that to left and right directions for the pong bar, as shown in video demo

What you need?

ImageNameDescriptionPart No.Qty.Where to Buy/GetWhere to Borrow
Raspberry PiMicro-computer used for prototypingRASPBRRY-MODB-512M1Canada Element 14UOIT SEEK
Pi CamCamera module forimage i/o applicationsRPI NOIR CAMERA BOARD 1Canada Element 14UOIT SEEK
HDMI CableAllows video to be shown on monitors/TVN/A1Amazon CanadaN/A
About 1.2 Amp, 6 Volt Power AdapterPowers the Raspberry PiN/A1Mom or dad's smartphoneN/A
4 Gb or larger SD cardActs as "Hard Disk" for Raspberry PiN/A1Electronics storeN/A

How to image sd card with Raspbian

Download latest Raspbian operating system. Then install Win32DiskImager (for Windows) or ApplePi-Baker (for Mac). Unzip Raspbian download. A file .iso will be extracted. Use Win32DiskImager or ApplePi-Baker to flash or "burn" it to the SD card you have inserted in the card reader of your laptop/pc. After it completes flashing the .iso image to the SD card, pop the SD card out and insert into the Raspberry Pi.

How to connect RPi Cam Module

As Figure 1 shows, you connect the unpowered Raspberry Pi Camera Module to the Raspberry Pi board in orientation with the cam facing down.

Figure 1 How to connect Raspberry Pi Camera Module — connect the rpi cam module facing down to the Raspberry PI board

What Raspberry Pi terminals exist

Figure 2 shows all input and output terminals or "ports" of the Raspberry Pi.

Figure 2 Raspberry Pi layout of i/o terminals — keep this layout in mind as you connect the board to different things, like ethernet, monitor, power supply, etc.

Start Using Raaspberry Pi

Use layout in Figure 2 to connect your board to ethernet using Ethernet or LAN cable to your Router's Ethernet jack. Using HDMI cable connet Raspberry Pi board to a HDMI monitor. Monitor without HDMI, should have DVI Port. Buy or get a HDMI to DVI cable to connect the board to your display monitor. Now power up the Raspberry Pi board You should see on your monitor Raspbian booting and its kernel init messages. Soon you will be asked to login. Use the information in Figure 3. You can change default settings, like the password, by running command shown in Figure 4. Tape the Raspberry Pi Camera itself "flipped" to your monitor.

Username: pi
Password: raspberry

Figure 3 Raspberry pi default login information/credentials

sudo raspi-config

Figure 4 Customize Raspberry Pi with this command. Enable Camera, Increase memory to 256 for GPU, Expand file system, Change Password (otherwise, stranger can hack in) — other customization options will be listed after this command is run. Simply type it in terminal, and press enter.

Install Open CV for Raspberry Pi

Open CV is an API to process images or videos. Open CV acts as a library with tools that can be imported in almost all programming languages ‐ C/C++, Python, Java, etc. We will Python because Python is the language of choice to prototype. Type in your terminal

sudo apt-get install python-opencv
to instal OpenCV and its bindings for Python Programming Langauge.

Raspberry Pi Cam Driver Must Install

uv4l driver must be installed. Instructions to install uv4l driver on Raspberry Pi are shown in Figure 6. Without this driver, you will get OpenCV error shown in Figure 5 everytime you run your Python (or other, like C/C++/Java, etc.) program that imports Open CV library and uses Open CV methods.

OpenCV Error: Assertion failed (scn == 3 || scn == 4)

Figure 5 Python or any program using OpenCV gives this error when the camera device is not found

wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc

sudo apt-key add ./lrkey.asc

sudo sh -c 'echo "deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main" >> /etc/apt/sources.list'

sudo apt-get update

sudo apt-get install uv4l uv4l-raspicam uv4l-raspicam-extras

sudo reboot

Figure 6 This is how you install drivers ‐ UV4L Driver ‐ to show RPi Cam as /dev/video0 interface

RPi cam window preview issue

Disable Raspberry Pi Cam preview window with commands of Figure 7. By default the prview windows would have had openned interfering with your game window.

cd /etc/init.d

sudo nano -m uv4l_raspicam.sh

With down arrow, go down this file after openned and try to find the line

UV4L --syslog-host localhost -k --sched-rr --auto-video_nr --driver raspicam --encoding mjpeg

Add

--nopreview yes
to the end of this line. Then press Ctrl + o to save the file. Then press Ctrl + x to exit.
Figure 7 Disable RPi cam module default preview window — stops RPi cam window popup

Play GesturePong game

Download GesturePong source code and use Figure 8 to unzip, and start the game on your Raspberry Pi board.

unzip source-code.zip

cd gesturepong/

sudo apt-get install xrandr

xrandr --output

Press tab twice after --output

That will show you the name of the monitor/tv your Raspberry Pi board is connected to. For my monitor after tab twice, I see --output DVI1 For you it will be different Finish the command now with xrandr --output YOURDISPLAY --rotate left This will make the whole monitor view rotate by 90 degrees counter clock wise. May be a bit difficult to read the text now, but this will make the game view easier; wait and see.

Start the game with python playpongwithcam.py The game might take upto 20 seconds to load on your monitor/tv

Sit down or stand and move slowly to move your bat/bar left or right.

To exit the game and undo the display rotation do

ctrl + c
and
xrandr --output YOURDISPLAY --rotate normal
Figure 8 Process to extract, load and play the game.
Other Projects
Professional Circuit Drafting
Professional Circuit Drafting CAD drawing gives you professional grade circuit schematics and prototype models. Learn to communicate design of electronics and hardware innovation like the professional engineer. Continue >>
Knock to Ring Bell
Knock to Ring Bell Make a complete musical bell system that rings with your knock. Possibly, this may reduce door banging or frustration at dormitory doors that aren't allowed to have buttoned door bells, yikes! Continue >>
Raspberry Pi Tweet to my Door Raspberry Pi Tweet to my Door Raspberry Pi connected to colour display wirelessly. Show your twitter updates on a screen attached to your door at school's club office, classroom, treehouse room. Display to your audience your... Continue >>
Self-Driving Car
Self-Driving Car Robots are smart. Here you transform your old toy car or another vehicle into a bot that follows a wavy line. Use it for shipping goods between unmanned travel ports. Real world uses are endless. Continue >>
Optical Network Made Easy
Optical Network Made Easy Optical communication is fast, cheap, and reliable. Build your own prototype of a peer-to-peer network using laser. Understand how big Rogers, Bell and use Fibre to connect you in lightning speed to... Continue >>
Pedometer for Athletes
Pedometer for Athletes Supercharge your shoe! Use it to find issues in your run during basketball, track or soccer. Or, track the distance and stats of your jog. Help keep others keep their walk at constant pace, such as... Continue >>
Broadcast Your Radio
Broadcast Your Radio Broadcast your music and voice wirelessly. Spread your news with your friends over short distance using radio. It is easy to make, free, and won't get CRT angry at you. Radio podcasts, chatroom uses... Continue >>
Networked Thermometer
Networked Thermometer Thermometers are old. They are useful: superb tool to control experiments in science labs, monitor body heat, get weather data, save devices from overheating as your flat screen tv, and car engines. Continue >>
Internet Controlled Lights
Internet Controlled Lights Use internet to make lighting during Christmas or other occasions dance! Surprise your buddies with LED sequence control. Make decoration energetic during your sweet holidays. Continue >>
Arduino Tweets to my Door Arduino Tweets to my Door Arduino connected through wire to display. Show your twitter updates on a screen attached to your door at school's club office, classroom, treehouse room. Display to your audience your location at the... Continue >>
Arduino Lilypad Remote Mouse
Arduino Lilypad Remote Mouse Control your computer's mouse with this homemade remote-control. Build touch switches completely in software and then link the remote to the computer via infrared. Continue >>
Paper Music Player Tutorial
Paper Music Player Tutorial Play music from paper as if the paper was an "ipod". You build a system that senses capacitive touch on pencil shaded shapes on paper. With these touches music is controlled. Continue >>

Maintained by Qusay H. Mahmoud
Content Contributors: Rudy Lang, Michael Lescisin, Rahma Mahmood, Ahmad Shamshiri, Ahmad Touseef, Mirna Zohiry