pygame is
Simple DirectMedia Layer is
Site Swing
AR example

AR example - 0.4.0

slmgc (slmgc)



AR example is a simple augmented reality example written in python using pygame library.
Linux only. Added win32 support out of the box with VideoCapture by Markus Gritsch.


  1. Take an object of simple shape and solid color.
  2. Switch the color mode with [1][2][3].
  3. Target the object and fixate it's color by pressing [space].
  4. Calibrate the object's color with the color picker using [q][w][e] and [a][s][d]. Only the targeted object should be visible on the screen.
  5. When done, switch from the calibration mode to the tracking mode [enter].
  6. Switch on/off the tracking frame with [1].
  7. If the result is not good enough, switch back to the calibration mode [enter] and repeat the steps above.

P.S. if you have any questions or suggestions, please drop me a line.


  • Added py2exe win32 executable.
  • Added win32 webcam settings dialog for compatibility with non-standard webcams.
  • Fixed some win32 bugs.


Home Page:


click to view original size


AR example - 0.4.0 - Jun 19, 2014
AR example - 0.3.1 - Sep 9, 2012
AR example - 0.5-frog-knows - Sep 8, 2012 account Comments

If you wish to leave a comment with your account, please sign in first.

September 2, 2010 7:32am - slmgc - nickname: (slmgc)
It was my first python program ever (C programmer here), but I've tried to make the code as readable as possible. The passive state is the callibration mode, when there are no algorithmic calculations, and the active state is the opposite, in this mode beggins to work the program's bouncing and interface code. As for the full-screen mode... maybe I should default the program to the windowed mode or just make an on-screen instruction?
September 2, 2010 1:25am - Xandar Kablandar - nickname: (eternalcheesecake) - 4/5
Very neat! This is the first time that I looked at the code to work with webcams with Pygame and your example shows how simple it is. It took me awhile to memorize the instructions because when the example goes full-screen, I couldn't switch back. So I wound up just tinkering until I got it, but was surprised at how well it kept up. In the code, I didn't understand the difference between the active & passive state, though.

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
May 22, 2016

May 21, 2016

May 18, 2016

May 1, 2016

Mar 27, 2016

Mar 26, 2016

Mar 22, 2016

Mar 19, 2016

Mar 17, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)