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":

enter image description here

The detection routine should identify similar objects. So for the given input, it should e.g. identify the following output:

enter image description here

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:

  1. Extract all objects in input image.

  2. 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?


1 Answer 1


Disclaimer: I have never used Siamese networks

I would approach this problem in two steps:

First: train object detector and train it for eligible classes of object, for example using Yolo architecture.

You could use pretrained object detector and finetune it for your classes of objects.

Second: extract a lot of bounding boxes of eligible objects of the same classes from your dataset and train Siamese network on their subimages.

Siamese network output similarity measure between two objects.

Your pipleline would look like:

  1. Run object detetctor

  2. For each two pair of objects of the same class rescale bounding boxes and run Siamese network.

  3. Check if the similarity distance between two objects is less then threshold (tunable hyperparameter)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .