Aruco in opencv

So there isn’t great documentation on the python bindings as far as I can find. There are docs on the c++ bindings.  Trying to do this on a mac was a hellish uphill battle, and opencv in the virtual machine has been… hmm actually pretty okay? Well, I did this on my fresh new triple boot ubuntu flash drive.

Invaluable is to go into the python REPL and type

Then you can see what all the available functions are. They’re more or less self explanatory, especially since they are described in the opencv c++ tutorials.

I believe the python bindings are generated programmatically, and they are fairly systematic, but always a touch different from the c++ function calls. A big difference is typically the python calls don’t modify in place.

Anyway, to get you up, I cobbled together some really basic code. It can generate a tag and save it

And this is a basic program to detect the markers

They are sprinkled with the requisite garbage and cruft of me wiggling around with print statements to figure out what everything is.

It sounds like more of what I want is to use Aruco boards. They sound good. I’m looking into using this for maybe robot configuration sensing.


5 thoughts on “Aruco in opencv”

  1. I get the error ‘ImportError: No module named aruco’
    Please give some tips on how to install aruco.
    I use opencv 3.1 with Python 2.7

    1. Hi Raja,

      It’s been a while since I’ve been playing with this and I’ve run all sorts of commands screwing around with my python distro.
      import aruco
      seems to work now and not cv2.aruco. Perhaps this is from a previous attempt to install aruco or perhaps the opencv project organization has changed (I think when I made this post the aruco addition to opencv was pretty fresh and porbably unstable). I believe I did reinstall opencv the other day to play with OpenSfm. I think I might be using aruco for a new project soon, so I’ll make a new post then.

      Edit: Ah. I see. I actually read my own post. I got it working on my ubuntu partition. never mind then.

  2. I have opencv_contrib compiled in ubuntu along with opencv. When I try to run the code to generate a tag, I get the following error –
    Traceback (most recent call last):
    File “”, line 11, in
    aruco_dict = aruco.Dictionary_get(aruco.DICT_5X5_250)
    AttributeError: ‘module’ object has no attribute ‘Dictionary_get’

    How do I resolve this?

  3. I installed opencv3.2 and the issue is fixed. Now, somehow it is not detecting the marker. No errors as such. But marker is not detected.

Leave a Reply

Your email address will not be published. Required fields are marked *