Answers.Body: <p>If you just need to draw a rectangle around each key, this is an <a href="https://www.mathworks.com/discovery/object-detection.html" rel="nofollow noreferrer"><strong>object detection</strong></a> or <a href="https://en.wikipedia.org/wiki/Template_matching" rel="nofollow noreferrer"><strong>template matching</strong></a> problem, so you can use any of the available models for object detection (e.g. <a href="https://lilianweng.github.io/lil-log/2018/12/27/object-detection-part-4.html" rel="nofollow noreferrer">YOLO</a>) or any technique for multi-template template matching (e.g. you can use <a href="http://www.cs.cmu.edu/%7Edfouhey/earlier/thesis/dfouhey_thesisPresentation.pdf" rel="nofollow noreferrer">sequential RANSAC</a> or <a href="https://ieeexplore.ieee.org/document/6909900" rel="nofollow noreferrer">t-linkage</a>). In the first case, you will need a labeled dataset, while, in the second case, you will need the original image and the templates (in your case, a template would be an image of a key).</p>
  <p>So, no, this is not a segmentation problem (which would be the task of classifying each pixel in the objects of interest, and not just locating the objects).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-25T10:08:54.660Z
Answers.LastActivityDate: 2021-04-22T01:09:13.623Z
Answers.LastEditDate: 2021-04-22T01:09:13.623Z
Answers.UserDisplayName: nbro
Answers.Body: <p>There are two related problems for images</p>
  <ol>
  <li>Semantic segmentation, where you need to assign each pixel on the image some class. I.e. you have a satellite image and want to segmentate roads/forests/fields and so on</li>
  <li>Objects detection, where you need to detect different types of objects and draw a bounding box for each. I.e. there is a popular dataset MSCOCO for the task, where you need to localize all bikes/people/cats/etc on the image</li>
  </ol>
  <p>U-net is good for the first task, but I would say you have a second. You can use something like YOLOv3 (if you need fast inference) or fast R-CNN if you need precision. If you need really good performance, you can browse top methods for the task on the paperswithcode.com: <a href="https://paperswithcode.com/task/semantic-segmentation" rel="nofollow noreferrer">semantic segmentation</a>, <a href="https://paperswithcode.com/task/object-detection" rel="nofollow noreferrer">object detection</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-25T10:26:43.870Z
Answers.LastActivityDate: 2021-03-25T10:41:53.267Z
Answers.LastEditDate: 2021-03-25T10:41:53.267Z
Answers.UserDisplayName: Kirill Fedyanin
Body: <p>This is a 600*800 image.</p>
  <p><a href="https://i.sstatic.net/gQ6LD.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gQ6LD.jpg" alt="enter image description here" /></a></p>
  <p><strong>Which algorithm/model should I use to get an image like the one below, in which each key is detected and labeled by a rectangle?</strong></p>
  <p>I guess this is some kind of a segmentation problem where U-net is the most popular algorithm, though I don't know how to apply it to this particular problem.</p>
  <p><a href="https://i.sstatic.net/XyqiJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XyqiJ.png" alt="enter image description here" /></a></p>
  
Tags: <computer-vision><object-detection><algorithm-request><model-request><template-matching>
Title: Should I use U-net to label keys in a keyboard image?
UserDisplayName: JJJohn
ThreadText: # Should I use U-net to label keys in a keyboard image?
  
  (Asked by: username_0 on 2021-03-25)
  
  This is a 600\*800 image.
  
  [![enter image description here](https://i.sstatic.net/gQ6LD.jpg)](https://i.sstatic.net/gQ6LD.jpg)
  
  **Which algorithm/model should I use to get an image like the one below, in which each key is detected and labeled by a rectangle?**
  
  I guess this is some kind of a segmentation problem where U-net is the most popular algorithm, though I don't know how to apply it to this particular problem.
  
  [![enter image description here](https://i.sstatic.net/XyqiJ.png)](https://i.sstatic.net/XyqiJ.png)
  
  **Tags:** computer-vision, object-detection, algorithm-request, model-request, template-matching
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-03-25. Score: 1 | Accepted answer
  
  If you just need to draw a rectangle around each key, this is an [**object detection**](https://www.mathworks.com/discovery/object-detection.html) or [**template matching**](https://en.wikipedia.org/wiki/Template_matching) problem, so you can use any of the available models for object detection (e.g. [YOLO](https://lilianweng.github.io/lil-log/2018/12/27/object-detection-part-4.html)) or any technique for multi-template template matching (e.g. you can use [sequential RANSAC](http://www.cs.cmu.edu/%7Edfouhey/earlier/thesis/dfouhey_thesisPresentation.pdf) or [t-linkage](https://ieeexplore.ieee.org/document/6909900)). In the first case, you will need a labeled dataset, while, in the second case, you will need the original image and the templates (in your case, a template would be an image of a key).
  
  So, no, this is not a segmentation problem (which would be the task of classifying each pixel in the objects of interest, and not just locating the objects).
  
  
  ---
  
  ### Answer by username_2 on 2021-03-25. Score: 1
  
  There are two related problems for images
  
  1. Semantic segmentation, where you need to assign each pixel on the image some class. I.e. you have a satellite image and want to segmentate roads/forests/fields and so on
  2. Objects detection, where you need to detect different types of objects and draw a bounding box for each. I.e. there is a popular dataset MSCOCO for the task, where you need to localize all bikes/people/cats/etc on the image
  
  U-net is good for the first task, but I would say you have a second. You can use something like YOLOv3 (if you need fast inference) or fast R-CNN if you need precision. If you need really good performance, you can browse top methods for the task on the paperswithcode.com: [semantic segmentation](https://paperswithcode.com/task/semantic-segmentation), [object detection](https://paperswithcode.com/task/object-detection)
  
  
  ---
  
  