Introduction

In fulfilling this Milestone, we were tasked with converting our functioning camera setup into a more nuanced color and shape determination. We set about this by splitting the work for both types of features, hoping to join the complete setup for both in the end.

Color Detection

The colors of interest to us were blue and red. Given that these are primary colors and supported extensively by RGB styled image processing, we hoped to make use of the on-board image converting of our camera and use more simple calulations on our FPGA to determine color. The method we chose was to be a strict majority and over a baseline threshold. To determine what a majority meant, we simply took each pixels' data and examined whether the larger magnitude belonged to red or blue (again, only over a second threshold). The end result was quite accurate color detection.

Shape Detection

Shape detection offere less obvious routes to success compared to color detection. Our singular attack strategy was that we already had a set of well-defined shapes we wanted to search for (triangle, square, diamond). We began by looking for patterns in rows of pixels we received, and after some initial succes in locating "clumps" of red or blue, were able to extrapolate from there with larger shape detection. The most trouble we received was in determining the presence of a diamond. Having a shape very distinctly between a square and a triangle, the inclusion of this third shape made testing quite extensive to be sure we were thresholding all our values correctly. Unfortunately, we were quite hurried in making our video for demonstraction of completion, and so were only able to show the diamond being correctly identified. However, given that this was the hardest shape to determine, it follows that the square and triangle had to be completed before this task.

Shape Detection Update

The shape detection update greatly improved the accuracy and quality after multiple corrections. Here is how we do the image processing to detect the treasure shapes (Triangle, Square, and Diamond). Our concept is to find the upper bound and the last bound of the treasure for locating and thus, could dynamically locate the middle three rows for shape detection.

  • First of all, we would have to find first row and the last row of the treasure for the second frame for shape detection.
  • Because the frame update so fast, the first row and last row wouldn't make much difference between the two frame unless the the camera or the treasure isn't stable enough. Then, the second frame would be able to locate the treasure according to the upper and lower bound row position.
  • The middle three rows could detect the shape from comparison each other. For example, diamond would have the longest row in the middle. And triangle would have the longest at the last row.
  • Through this algorithm, we would be able to detect the shape accurately and precisely.

    Key for shape detection

    Please beware of that Verilog is a Hardware Design Circuit. Not simply a C like language. You would rather map out the circuit in your mind whenever programming Verilog.

  • * Always access or store the data when falling or rising edge. This would assure you only get one data update not multiple ones.
  • * FPGA runs faster than you thought. Always output your pin with the LED or connect pins to the scope for debugging.
  • * For image processing, always visualize how your algorithm or filter is outputing on the screen for convenience and debugging. It's hard to tell a number for single pinout unless you're presenting in only one bit.
  • Always keep these in mind when programming Verilog.

    Conclusion

    Working with the camera again, we found ourselves in a familiar dilemma of dealing with inaccurate hardware and "touchy" wirings that would often fail between successful tests. This made this portion of our final robot all the more challenging, but also rewarding as we began to see resutls. The final color and shape detection are not combined and able to provide accurate results, provided one takes a running average to sort reduce the chance of false positives.