Detecting Shapes In Images (team project) | SCSE Computing Challenge 2022
Context:
SCSE CC is a competition that invites teams of students to work on a computing project. For 2022, we were tasked to program a robot car to travel along a path based on shape instructions that it sees with a camera. I was assigned the role of writing the algorithm for detecting shapes.
The whole process took me about a month or two to complete, and I tried to take photos in random conditions to help improve the algorithm. Testing was done on a Raspberry Pi as that was the platform used by the robot car.
The algorithm was written in Python.
Libraries used:
- scipy.spatial.dist was used to calculate the distance between 2 colour points.
- numpy was used to speed up calculations on matrices (since images are like 2D matrices).
- cv2 and imutils was used to conduct image processing.
Rough Description of Algorithm: 
- Image is blurred to remove noise.
- All regions outside of white regions (paper) are removed.
- White regions are removed to isolate shapes.
- Pure red, green and blue (all possible colours for shapes) are exaggerated to further isolate shapes.
- Otsu’s method is used to ensure there are only non-shape pixels and shape pixels.
- Gradient around the edges of shape are calculated to determine how many points they have. (This part was largely taken from the internet)
- Shape and colour of shape is determined.
- Triangles have 3 points, squares have 4 points, and anything with more points is considered a circle.
- Red, green or blue colour is determined by the shape’s colour’s euclidean distance from each other.