This project is read-only.

Creating Custom Markers using ALVAR

The good people at VTT have created a program for creating marker images that is available when you install the ALVAR libraries. (As of this writing, the source code for the sample programs can be found in the "Example programs" section at

Compiling the Sample Program

To generate the example program provided by Alvar, "SampleMarkerCreator", you will need to install a variety of utilities and programs, including OpenCV 1.0, GLUT 3.7, and CMake 2.6. OpenCV will have been installed already if you followed the directions in the GoblinXNA Installation Guide to install Alvar. In addition, to compile the program you will need either Microsoft Visual Studio 2003, 2005, or 2008, or MinGW and GNU Make.

Let's start off by obtaining the GLUT libraries. A variety of compiled and uncompiled code can be found at, and for Intel systems the precompiled libraries can be found at Unzip these to your desired location (you will point to them later.)


Next install CMake 2.6, found at When you are asked, choose to save the file and then launch it. In Google Chrome it looks like this (see the bottom of the screen shot):


When asked if you wish to allow the program to run, choose "Yes".


On the first screen click "Next", and on the next screen click "I Agree" (after carefully reading the disclaimer and pondering its ramifications, of course). Then you need to tell it to add itself to the path for the current user (or all users if you wish):


You can accept the default installation location or choose one of your own. Likewise, you can select the Start Menu folder. Then click Install. If all goes well you should see this screen, and can click "Finish".



At this point you probably need to log off and on again so that your environment variables are reloaded and the CMake executable will be in your path. Next you can generate the development environment by locating the build script in the Alvar installation directory, located here on my machine (don't launch it yet):


To run this you need to be an administrator. Using the Start Menu, find the Command Terminal in the menu and right-click it:


In the context menu that appears, choose to "Run as administrator". Then navigate to the location of your generate.bat file and run that. (Depending upon your path, you may need to surround the command in double quotes.) It will take a moment to build, but then you should see this:


Next launch the GUI version of CMake:


Before you proceed, note that you must not change the location where the binaries will be built. But fill out the rest of the requirements as shown below (substituting your own paths for mine.)


Click "Configure", and then click "Generate". This will create the sample projects - on my system, located at C:\Program Files\Alvar 1.4.0\build\msvc90\build\sample. When you open the SampleMarkerCreator.vcproj file, you might witness this warning:


Choose "Restart Visual Studio under different credentials", then choose to allow this program to make changes to your computer.

To create the samplemarkercreatord.exe file, I recommend choosing Build ... Build Solution <F6> from the top menu. This will produce the executable at C:\Program Files\Alvar 1.4.0\build\msvc90\build\sample\Debug.

Running the Sample Program

To run the program, open a command prompt and navigate to the file. Upon running it, you will see this:

Alvar Library 1.4.0 Copyright (c) VTT 2008-2010
Compiled on Windows 5.1 x86 (Jul  7 2010)
Day 303/365 of usage period for this version


  This is an example of how to use the 'MarkerData' and 'MarkerArtoolkit'
  classes to generate marker images. This application can be used to
  generate markers and multimarker setups that can be used with
  SampleMarkerDetector and SampleMultiMarker.

  samplemarkercreatord.exe [options] argument

    65535             marker with number 65535
    -f 65535          force hamming(8,4) encoding
    -1 "hello world"  marker with string
    -2 catalog.xml    marker with file reference
    -3     marker with URL
    -u 96             use units corresponding to 1.0 unit per 96 pixels
    -uin              use inches as units (assuming 96 dpi)
    -ucm              use cm's as units (assuming 96 dpi) <default>
    -s 5.0            use marker size 5.0x5.0 units (default 9.0x9.0)
    -r 5              marker content resolution -- 0 uses default
    -m 2.0            marker margin resolution -- 0 uses default
    -a                use ArToolkit style matrix markers
    -p                prompt marker placements interactively from the user

Prompt marker placements interactively
  units: 1 cm 0.393701 inches
  marker side: 9 units
  marker id (use -1 to end) [0]:




If you simply run the program without passing any arguments you are put into interactive mode. This mode is very handy, especially for beginners, since it defaults to logical choices that create good markers.

Last edited May 11, 2011 at 1:25 AM by dcoli, version 7


No comments yet.