INTERFACE

This is part the of vision section that transforms the image coordinates of the balls that were found into world coordinates. The world coordinate of the balls is then the output of the vision section in the form of the ball state. The transformation is done using a lookup table. For ever point in the image the world coordinates are store in the lookup table. The only interesting part about this is the how the table is initialized. The information that I start with are four image and four world coordinates that represent the coordinates of the corners of the pool table in both coordinate systems. The way I did it was to use a trick that I learned in high school art class. When drawing a picture using vanishing points the way you find the center of a square is to draw two diagonal lines from the corners and where they intersect is the center.

 

After I find the center I use the vanishing points to find the middle of each edge (another art trick).

 

Now for the world coordinates. This is much simpler because I assume that the world coordinates linear, so find the same five points that represent the in the image is a simple mater of doing averages of certain points. You may be asking your self why find all this points, well if you look at the picture you'll see that there are four smaller rectangles. I make four recursive calls to split the image until the table is full.

 

Now that we have this nifty lookup table we put it to some use to see how well it works

The result of where the color of every pixel in the orginal image is transformed into world coordinates. One of the interesting properties of this tranformation is the black gaps towards the top of the image (farther from the camrea also) because of the non-linear transformation. This is the orginal image of the pool table with some modifications to show our calculations in a visual form. Th first thing you'll motice is the large gradent on top of the pool table. This gradent is the transformation lookup table were the red chanel was uesd to show the magintued in the X world coordinate and the green channel shows the Y magintued. Some of the other thing going on here is the result of the line detection which is used to get the corners of the pool table and to clip where it looks for circles, and the result of the circles detection which is shown as circles draw on top of where we think there are balls.