<<Prev 1 2 3 4 5 6 Next>>
Where's the Ball
Given our original image we now need to process the same image for the white ball. We can revert
RoboRealm to the original image by using the Marker module to save
the current image and revert the viewable image to the aligned source image.
We'd like to separate the white ball from the rest of the maze. The first step is to collect
all the white pixels into a blob that can be processed at a higher level in order to determine which
one is the white ball. We start this by using the Flood Fill module.
This helps to group pixels into like colors. Note that as the white ball is considerably higher in
intensity from the rest of the image we can use a very large threshold value. While this causes the
green and blue colors to merge it does keep the ball separate from the background. As we have already
processed for the blue blocks we are not concerned about this green blue color merging.
Now we can separate each of the blobs using the Blob Separate module
so that they can be processed individually.
we can process the image for the strongest circles using the Circles module. Note
that using the flood fill module to first group like pixels as apposed to just
detecting edges straight from the source image as is normally used as a precursor to the Circles module helps
reduce the amount of false circles detected. False circles might be detected due to lighting changes that
momentarily cause a circle to be seen.
Once the circles are detected each circle is filled with the mean color of the pixels that makeup
that circle using the Blob Colorize module and checked to see that
this value is high (i.e. towards white). This blob removal processing
is done by using the blob filter module. What we are left with
is a single circle that best represents where the ball is (i.e. it is a white circle). The center of gravity of this
circle is then considered to be the X and Y coordinate of the ball. Note that this coordinate is
also divided by 14 in order to ensure that the values are within the range of the previously
created 2x2 dimensional array that represents the maze.
Next we move to the destination square. This is easily determined by filtering the image for
red once again using the RGB Filter module and then filtered for the largest
red square using the Blob Filter module as seen in the image below. The resulting
center of gravity coordinates of the red blob is then also scaled into the 14x14 array.
Now that we have all the information we need we have to determine how to calculate the route
from where the ball is to the destination red square using a custom ball rolling path planning algorithm.
<<Prev 1 2 3 4 5 6 Next>>
|