I want to tackle the problem of detecting similar objects in an image. To illustrate the problem consider this photo of some Lego bricks as my "input":
The detection routine should identify similar objects. So for the given input, it should e.g. identify the following output:
So an object might appear none to multiple times in the input image. For example, there are only two bricks marked with a blue cross, but three bricks marked with a red cross.
It can be assumed that all objects are of similar kind, so e.g. only Lego bricks or a heap of sweets.
My initial idea is to apply a two-phased approach:
Extract all objects in input image.
Compare those extracted objects and find similar ones.
Is this a valid approach or is there already some standard way of solving this kind of problem? Can you give me some pointers how to solve this problem?