Calibrating your Camera with calib.xml
Option Two, the ALVAR Calibration Tool
(If you can, we recommend you use the GoblinXNA calibrator instead.)
To generate calib.xml you will need to compile and run the example program provided by Alvar, "SampleCamCalib".
To this end 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 http://www.opengl.org/resources/libraries/glut/glut_downloads.php, and for Intel systems the precompiled libraries can be found at
http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip. Unzip these to your desired location (you will point to them later.)

Next install CMake 2.6, found at
http://www.cmake.org/files/v2.6/cmake-2.6.4-win32-x86.exe. 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):
<!--[if gte vml 1]><v:shape id="_x0000_i1034" type="#_x0000_t75" style='width:6in;height:320pt'> <v:imagedata src="ALVAR4_files/image019.wmz"
o:title="" /> </v:shape><![endif]-->
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 SampleCamCalib.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 run the samplecamcalib.exe file, I recommend right-clicking the project on the right-hand side of the
screen,

... choosing "Debug" and "Start new instance". On my system, the first time I run this I get a command
window with instructions on how to run it, but then I get a black window instead of the image viewable by my webcam. However, running it again launches the first command window followed by a series of dialogues asking you for parameters about your camera.
(For me, the defaults worked fine.)
Follow the directions using the checkerboard printout provided in the Alvar.pdf file, page 8. Once the
program recognizes the pattern, it will begin a series of passes to calibrate to your camera (your pose may differ if you are not actively writing a how-to):

Wait for the passes to complete. If it seems to be taking a long time, try shutting down all programs that
access your video camera (Skype, I'm looking at you.) Also make sure you have adequate lighting.
At the end of this process you'll have a spiffy new calib.xml file. Link to this file within your project
so it can find it, and you are ready to go. For example, for Tutorial 8 I put it in "C:\Users\Colin\Documents\GoblinXNAv3.5\tutorials\Tutorial8 - Optical Marker Tracking."