Detect marker with opencv and python

I am trying to detect a marker in a webcam video feed and overlay it with a 3d object - pretty much exactly like this:

I know artoolkit is the best module for this, but I was hoping to just use opencv in python since I dont know nearly enough c/c++ to be able to use artoolkit. I am hoping someone will be able to get me on the right track towards detecting the marker and determining its location and orientation etc since I have no idea how best to go about this or what functions I should be using.


OpenCV doesn't have marker detection / tracking functionality out of box. However it provides all algorithms needed so it's fairly easy to implement your own one. The article you are referring to uses OpenCV only for video grabbing. The marker detection is done by NyARToolkit which is derived from ARToolkit. NyARToolkit have versions for Java, C# and ActionScript.

ARToolkit is mostly written in plain C without using fancy C++ features. It's probably easier to use than you thought. The documentation contains well explained tutorials. e.g

The introductory documentation can help you understand the process of marker detection even if you decide not to use ARToolkit.

I think the most used way to perform marker detection using python and open CV is to use SURF Descriptors. I have found very useful this video and the linked code you can find in this page. Here you can download the code. I don't know how to overlay it with a 3d object but I'm sure you can do something with pygame or matplotlib.

Need Your Help

Fading a loaded image into Canvas with drawImage

javascript jquery html5 canvas drawimage

This question about crossfading images already gave an answer to the crossfading solution in Canvas. I am trying to do the same thing, only difference is that i am trying to fade images that are lo...

iPhone: Best Method for Passing Data to and from a Server

iphone sql json soap data-transfer

I am developing an iPhone application that downloads data from a website. The website database is implemented in SQL and the site itself uses the classic ASP interface.