-
Notifications
You must be signed in to change notification settings - Fork 0
Goal Posts
Currently (summer 2011) we have two distinct goals, one YELLOW and one BLUE. This is likely to change soon. Each goal consists of two posts connected by a crossbar. The goal of the vision system is to accurately detect these goals and provide distance and bearing information to our localization system. The code for finding goal posts is in the ill-named (it was a good name 5 years ago) ObjectFragments.cpp.
Since we know where the goals are on the field we use that information to constrain our search for posts. In particular the goal posts are relatively near the field edges. That means they are normally almost completely above the field horizon in the image (this is not true when the robot is at the side of the goals).
The first part of our algorithm is to scan up from the field horizon in every column of the image. As we scan we look for runs of YELLOW or BLUE. If the runs meet our criteria we save them in a data structure. Once we have scanned all of the columns we then look specifically for BLUE and YELLOW posts.
Since the posts are tall and thin and our robots are normally looking at them upright the most likely location of posts in the image are the places where we have seen the longest runs of the appropriate color. So the first thing we do is find the longest run of the color we are examining. It is a candidate to be a post. Now the other runs we collected are potentially useful too, so we collect up adjacent runs that are of similar size to have a good starting estimate of the post's size. This defines a rectangle (even though our pose may not align exactly vertically - we'll deal with that in a later step).
The rectangle is our candidate for being a post. Our goal is to expand the rectangle to the full size it is in the image. We do this by scanning out from each of the four edges. We divide each edge up into fifths and send a scanline out from that point and scan as far as we still see the color we are looking for. We then look at how far each of the scans went and select a middle value to expand the post (e.g. if all scans went 5 pixels, we would move the edge over by 5). Our scans are not done axis-parallel, but are done according to the slope indicated by the robot's pose. It turns out that this doesn't always line up with the goals however so we also do a correction step.
The basis of the correction is to look at the bottom and top of the post to see if they are mis-aligned. We scan to find the proper alignment and then use it to reset our slopes for further scanning.
Once we are through this process we have found a region of the image that is a candidate post. We then run it through a variety of sanity checks to ensure it is a post. Among these:
- Is it big enough?
- Does the distance estimate from pose match the size?
- Is it the right general shape (e.g. taller than wide)?
Our next job is to see if we can identify the post - whether it is the left or right post. Note: this may actually shift to our context section this year. We have a variety of tools to make this determination.
- We use nearby corners supplied by the line system. This is the best method.
- We use the crossbar if we have seen it.
- We use the (apparent) presence of another post of the same color.
If we have identified another post it makes the next step simpler. The next step is to see if there is a second post in the image. If we know which post we started with it constrains where in the image the second post can be. It may be, however, that we would be better off looking for the second post first. After all, if we find it, then we needn't worry about identifying the first post. In any case the process of finding the second post is identical to finding the first, except that we have reduced the number of colored runs that we have found. Once we have found a suitable candidate we run it through the same sanity checks with a few additions. Namely to ensure that the relative size and locations of the two posts make sense geometrically (Note: these need revisiting as they haven't been checked in years).