One of my primary goals with the Warhammer table is ease of use – I want it to be easy to setup and use; otherwise, no one would do either. That being the case, this article will focus on making setup and calibration as easy as possible by sticking to the following goals:
- No measurements needed: During setup, there should be no need to measure the height of the projector or any other distances explicitly.
- Protractor not required: If the projector and/or webcam is angled relative to the gaming table, the software should be able to determine this and correct for it so that measurements remain correct.
- Keyboardless: Once the program is run, the user should be able to run calibration from the table, not the keyboard.
With those restrictions, it is worth noting the primary problems that need to be solved:
- Calibrate the webcam, in particular, determine the angle between the webcam and the gaming table.
- Calibrate the projector.
- Determine the available play area, i.e. the intersection of the area covered by the projector and the webcam.
Calibrating the webcam
Calibrating the webcam is the only step that implicitly requires some measurements, but I still want to stick to not having to measure anything directly. Because of that, I propose 2 strips with alternating white and black segments, each a known length. These strips will be placed on the gaming table so that they do not intersect, but also ensuring that they are not parallel (the closer they are to perpendicular, the better).
These calibration strips provide all the information needed to approximate the relative tilt in the gaming table. In particular in each linear direction (along the strip) the lengths will appear longer to the camera the closer they are, i.e. if the black rectangle on the left side is longer than the white rectangle on the right, the left side appears closer to the webcam so when determining lengths, the program will need to correct for that. Additionally, with both strips the program can determine the relative tilt along those two axes and build a model for the general tilt (as long as they are not parallel).
Calibrating the projector
Once the webcam is calibrated, the software can use it to calibrate the projector (because it’s quite possible the two are different). First, by drawing vertical and horizontal lines through the center of the projection canvas the relative centers of the webcam and projector canvases can be determined. By the same measurement, the software can determine the relative rotation between the webcam and projector canvases. Then, by projecting two alternating colored strips (similar to those for calibrating the webcam) the software can determine the relative tilt of the table to the projector.
Determining the available play area
Mathematically, this is the least elegant solution, but also the simplest. Simply project a rectangle defining the total projection area: if the entire rectangle is picked up by the webcam, the play area is the projector’s area (the area inside the rectangle). Otherwise, iteratively shrink each edge until it is picked up by the webcam. At the end of this process, the rectangle outlined is the play area.
That’s it! There’s a lot of math involved, but I’ll be detailing that in another post.