pygame is
Simple DirectMedia Layer is
Site Swing
AR example

AR example - 0.3.1

slmgc (slmgc)



AR example is a (not so) simple augmented reality example with an event-driven architecture written in python using pygame library. Linux only. Added win32 support out of the box with VideoCapture by Markus Gritsch.


After a few days of development of a new version of AR example, I've decided that it would be more interesting to switch to an event-driven engine architecture, which I'm using in my gamedev. So, no sooner said than done lol.

There are 5 main components:

  1. a loop-spinner, which initializes all other subsystems
  2. a window
  3. a renderer
  4. a capturer
  5. and a controller

which pass events to each other. The main great thing about that is that you can add/switch/replace/remove subsystems easily. All of them are loosely-coupled. For example, you could switch off a main window or a keyboard controller, but the application would finely run. Nothing ever breaks.

I'm eager to get some feedback on the subject.

P.S. there is not much left of an augmented part in AR example at the moment, but I'm working on it lol. If you need an old (0.3.1) but working augmented reality example, you can download it.


  1. Take an object of a simple shape and solid color.
  2. Fixate an object's color in a color picker.
  3. Change the chosen color's RGB components so only the targeted object would be visible on screen.
  4. After you are ready, switch from the calibration to the targeting mode.
  5. If the result is not good enough, switch back to the calibration mode and repeat the above steps.

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


An old working version of AR example 0.3.1.


Home Page:


click to view original size


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
Apr 25, 2014

Apr 21, 2014

Apr 19, 2014

Apr 16, 2014

Apr 13, 2014

Apr 9, 2014

Mar 18, 2014

Mar 15, 2014

Mar 14, 2014

Mar 13, 2014

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