**Language:** Done in C++ using OpenCV library.

**Pre-processing:** For the image pre-processing, i.e. transforming the image into a more raw form to give to the algorithm, I used 2 methods:

Changing color domain from RGB to HSV and filtering based on “red” hue, saturation above a certain threshold to avoid orange-like colors, and filtering of low value to avoid dark tones. The end result was a binary black and white image, where all white pixels would represent the pixels that match this threshold. Obviously there is still a lot of crap in the image, but this reduces the number of dimensions you have to work with. Binarized image

Noise filtering using median filtering (taking the median pixel value of all neighbors and replace the pixel by this value) to reduce noise.

Using Canny Edge Detection Filter to get the contours of all items after 2 precedent steps. Contour detection

**Algorithm:** The algorithm itself I chose for this task was taken from this awesome book on feature extraction and called Generalized Hough Transform (pretty different from the regular Hough Transform). It basically says a few things:

- You can describe an object in space without knowing its analytical equation (which is the case here).
- It is resistant to image deformations such as scaling and rotation, as it will basically test your image for every combination of scale factor and rotation factor.
- It uses a base model (a template) that the algorithm will “learn”.
- Each pixel remaining in the contour image will vote for another pixel which will supposedly be the center (in terms of gravity) of your object, based on what it learned from the model.