Skip to content
Augmented reality proof of concept project with Python and OpenCV
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
models "Add files" Sep 16, 2018
reference "Add files" Sep 16, 2018
src "Add files" Sep 16, 2018
.gitignore Initial commit Sep 16, 2018
LICENSE Initial commit Sep 16, 2018 Explain how to modify model scale in readme Jan 5, 2019


Augmented reality card based application with Python, numpy and OpenCV


  • Place the image of the surface to be tracked inside the reference folder.
  • On line 36 of src/ replace 'model.jpg' with the name of the image you just copied inside the reference folder.
  • On line 40 of src/ replace 'fox.obj' with the name of the model you want to render. To change the size of the rendered model change the scale parameter (number 3) in line 103 of src/ by a suitable number. This might require some trial and error.
  • Open a terminal session inside the project folder and run python src/

Command line arguments

  • --rectangle, -r: Draws the projection of the reference surface on the video frame as a blue rectangle.
  • --matches, -m: Draws matches between reference surface and video frame.


If you get the message:

Unable to capture video

printed to your terminal, the most likely cause is that your OpenCV installation has been compiled without FFMPEG support. Pre-built OpenCV packages such as the ones downloaded via pip are not compiled with FFMPEG support, which means that you have to build it manually.

If you get the error:

Traceback (most recent call last):
File "src/", line 174, in
File "src/", line 40, in main
obj = OBJ(os.path.join(dir_name, 'models/fox.obj'), swapyz=True)
File "[...]/augmented-reality/src/", line 16, in init
v = v[0], v[2], v[1]
TypeError: 'map' object is not subscriptable

The most likely cause is that you are trying to execute the code with Python 3 and the code is written in Python 2. The map function in Python 3 returns an iterable object of type map, and not a subscriptible list. To fix it, change the calls to map() by list(map()) on lines 14, 19 and 24 of src/


See this blog entries for an in-depth explanation of the logic behind the code:


You can’t perform that action at this time.