How to Generating calib.xml using ALVAR

Posted: September 13, 2010 in C/C++
Tags: , ,

In this article, i’ll create a simple tutorial how to generate calib.xml that are needed for GoblinXna.  Here’s my system environment :

  • Windows 7 Ultimate… since i don’t like XP :D
  • Visual Studio 2008 Professional
  • XNA 3.1
  • Logitech QuickCam Pro 9000

Note : i recommend to use specific version number of these software/libraries below, although never version available, for example, ALVAR won’t work on OpenCV 2.0

1. OpenCV 1.0

Our first step is installing OpenCV 1.0

2. ALVAR 1.3.0

You can download it in here :, you’ll need to register first and they’ll send an email with download link.

3. CMake 2.6.3


or Zip :

I suggest to download exe version because it is easier to install.

4. OpenGL

What…we are using XNA, why we need OpenGL ? Don’t worry… since OpenGL is only required for ALVAR example program…

extract file in

C:\Program Files\glut-3.7.6-bin

5. Configuring Environment Variable

Click Start > Left Click My Computer > Properties >Advanced System Settings

in the Advanced Tab,  choose “Environment Variables…”

In System variables part, choose Path variable, make sure paths below are listed :

C:\Program Files\Alvar 1.3.0\bin\msvc90


C:\Program Files\OpenCV\bin

After this step, you should restart your computer

6. Generating ALVAR Visual Studio Solution (.sln)

open your command prompt and type

cd “Program Files\Alvar 1.3.0\build\msvc90”



CMake window will appear :

for variable GLUT_ROOT_PATH fill with C:/Program Files/glut-3.7.6-bin

Press “Configure”, if there is no error press “Generate”

If Success, Alvar.sln will appear in C:\Program Files\Alvar 1.3.0\build\msvc90\build

7. Build Alvar.sln

Set SampleCamCalib as startup program

Last, press F5 to start debugging

8. Running SampleCamCalib

Confirm that your webcam is in good condition and ready to use

SampleCamCalib window will be appeared

Not to forget to print chess pattern in C:\Program Files\Alvar 1.3.0\doc\Alvar.pdf on page 9

Place your printout chess pattern in front of your webcam (as straight as possible… ) the SampleCamCalib will getting the chess image pattern for 50 times

After that, The program will generate calib.xml similar to this

<?xml version="1.0"?>
<intrinsic_matrix type_id="opencv-matrix">
    33.3938142881664460 0. 447.7360683574579000 0. 33.7270673715510800
    358.5932427136596100 0. 0. 1.</data></intrinsic_matrix>
<distortion type_id="opencv-matrix">
    -2.1527226093206867e-004 9.8774282594007105e-008
    -6.1339995506029709e-006 -8.0580568465034872e-004</data></distortion>

8. Having problem with ?

When starting SampleCamCalib.exe maybe yu’ll get this error: “ could not be located, register it using RegSRVR 32.exe”. What’s wrong?

This error does not always occured, if you get this error, please download and execute this patch

  1. Kyle says:

    Dude, u just saved my life.

  2. John Melo says:

    u did save my life too, for a moment, now i cant get that freaking samplemarkerdetector to work, i am trying to create markers with the samplemarkercreator, but i dont know how to use them with goblin xna, all it does is export a .png file. how can i get a .xml or an .txt file like in example number 8 from goblin xna? pleeeease help D:

  3. kumar says:

    Hi i am a newbie and i am getting this error “Unable to start program C:\….\SampleCamCalib.exe” and i went into the directory and found it missing too and not only that i was not able to generate the ALVAR solution in the first place i got the solution file from my friend and he faces the same problem too Pls help

  4. Muhammad Humza says:

    hi, I’ve done till 6 and alvar.sln is generated but its actually alvar.sln.bat which is not compatible with VS2008 as shown in point no7 above. Please help

  5. dcoli says:

    Two different methods for generating calib.xml are now documented in the Documentation section of the GoblinXNA codeplex site (one of them is super easy), and in the next week or so I’ll be posting an explanation of the MarkerLayout tool. – Colin

  6. Toni says:

    Access is denied.
    generating msvc90 build environment
    Access is denied.
    Access is denied.
    The system cannot find the path specified.
    Access is denied.
    Access is denied.
    setting up path batch file
    Access is denied.
    The system cannot find the path specified.

    error at step 6 while in command prompt, help me please…

  7. amelia says:

    hi.. I’ve done till build alvar.sln, but when I start debugging.. it says that it couldn’t find any capture plugins.. do you have any idea what is happening?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s