Goals
• To have the robot detect when there are/are not treasures. • To have the robot successfully distinguish between red and blue treasures.• To have the robot successfully distinguish a square, triangle, and diamond shape.
Color Detection
From the integration portion of Lab 4, we are successfully able to detect if an image is primarily red, primarly blue, or neither. This allows us to detect if there is a treasure in front of the camera, and if that treasure is red or blue, as shown below.
Below is a video of our camera distinguishing between red and blue treasures (this is the same result as in the end of lab 4):
Shape Detection
To detect shapes, we extended the color detection logic to regions of the screen and used this information to determine which is the corresponding shape. To elaborate, once it has been identified there is a treasure and its color is found, we divide the screens into 3 parts across: top, middle, and bottom. We then compare the number of colored pixels in each region and use this to find the right shape: a square has the same proportion of color distributed across its three regions, a diamond has the most in the middle and the least in the top and bottom, and finally a triangle has colored pixels in order of least to most in its top, middle, and bottom regions. The following are snippets of code serving different purposes in the above implementation:
Shape identification
Color detection
Region pixel count
Below is a video of our camera distinguishing both the shape (square, diamond, triangle) and color (red, blue) of treasures, meaning it can identify all 6 possible treasures (note also it indicates when there is no treasure):
Thank you team 5 for having their code public on their github repository. A lot of the FPGA code was taken from their repository.