Touchlib barrel distortion correction tool

Laurence Muller (aka Falcon4ever)
www.multigesture.net
19/12/2007

Purpose: 
- Correcting the barrel distortion of the lens
- Supports usb and firewire camera's (CMU driver)

Based on the example in:
C:\Program Files\OpenCV\samples\c\calibration.cpp

Required:
- the image from pattern.pdf printed on a piece of paper (perhaps glued on some cardboard)

Usage:
1. Connect a usb camera or firewire cam (using CMU)
2. Start the touchlib_barreldistortion_tool.bat
3. Select your camera type and press enter
4. start the calibration by pressing g
5. Put the pattern on the table
- After each snapshot (the screen will blink) you should move the pattern to another corner or side.
- You should also vary in rotation.
- Don't forget to put the patter in the middle aswell
6. After 10 snapshots the tool will calculate the correction values and save them to camera.yml
7. By pressing u it is possible to preview the correction.

If the tool has cropped the result too much, add this argument: -b 
Example: -w 6 -h 8 -s 2 -n 10 -b 20
20 seems to be good for a F 2.5 mm lens

In touchlib:
8. the camera.yml should be in the same directory as config.xml
9. add this line to your config.xml
<barreldistortioncorrection label="barreldistortioncorrection1">
    <border_size value="20" />
</barreldistortioncorrection>

The border size is a value you need to experiment it. It will add a black border of xx pixels.
Try using it with the value 0 first. If it resulting image is cropped too much, try increasing this value.
