Answers.Body: <p>Disclaimer: I have never used Siamese networks</p>
  
  <p>I would approach this problem in two steps:</p>
  
  <p>First: train object detector and train it for eligible classes of object, for example using <a href="https://github.com/pjreddie/darknet/wiki/YOLO:-Real-Time-Object-Detection" rel="nofollow noreferrer">Yolo</a> architecture.</p>
  
  <p>You could use pretrained object detector and finetune it for your classes of objects.</p>
  
  <p>Second: extract a lot of bounding boxes of eligible objects of the same classes from your dataset and train Siamese network on their subimages.</p>
  
  <p><a href="https://en.wikipedia.org/wiki/Siamese_network" rel="nofollow noreferrer">Siamese network</a> output similarity measure between two objects.</p>
  
  <p>Your pipleline would look like:</p>
  
  <ol>
  <li><p>Run object detetctor</p></li>
  <li><p>For each two pair of objects of the same class rescale bounding boxes and run Siamese network.</p></li>
  <li><p>Check if the similarity distance between two objects is less then threshold (tunable hyperparameter)</p></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T07:39:04.863Z
Answers.LastActivityDate: 2019-03-13T07:47:07.023Z
Answers.LastEditDate: 2019-03-13T07:47:07.023Z
Answers.UserDisplayName: mirror2image
Body: <p>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":</p>
  
  <p><a href="https://i.sstatic.net/pIBRs.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pIBRs.jpg" alt="enter image description here"></a></p>
  
  <p>The detection routine should identify similar objects. So for the given input, it should e.g. identify the following output:</p>
  
  <p><a href="https://i.sstatic.net/jHtR8.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jHtR8.jpg" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>It can be assumed that all objects are of similar kind, so e.g. only Lego bricks or a heap of sweets.</p>
  
  <p>My initial idea is to apply a two-phased approach:</p>
  
  <ol>
  <li><p>Extract all objects in input image.</p></li>
  <li><p>Compare those extracted objects and find similar ones.</p></li>
  </ol>
  
  <p>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?</p>
  
Tags: <object-recognition>
Title: How do I detect similar objects in an image?
UserDisplayName: Sebi
ThreadText: # How do I detect similar objects in an image?
  
  (Asked by: username_0 on 2019-03-12)
  
  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](https://i.sstatic.net/pIBRs.jpg)](https://i.sstatic.net/pIBRs.jpg)
  
  The detection routine should identify similar objects. So for the given input, it should e.g. identify the following output:
  
  [![enter image description here](https://i.sstatic.net/jHtR8.jpg)](https://i.sstatic.net/jHtR8.jpg)
  
  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?
  
  **Tags:** object-recognition
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-13. Score: 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](https://github.com/pjreddie/darknet/wiki/YOLO:-Real-Time-Object-Detection) 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](https://en.wikipedia.org/wiki/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)
  
  
  ---
  
  