Answers.Body: <p>If the measurements you want from the object aren't too complicated (ie. length of a clearly defined feature), and if you are able to acquire a training dataset of images of the objects similar to what your model will see in your use case (same scale/distance), their bounding boxes and their measurements, a model you could try to implement is a <a href="https://arxiv.org/abs/1604.02878" rel="nofollow noreferrer">Multi-Task Convolutional Neural Network (MTCNN)</a>.</p>
  <p>MTCNNs are typically used for face detection and alignment, but I would imagine it is possible to adapt them to your use case given proper training and tuning. If there are more complicated measurements that you want to obtain, you could pass on the detected objects to another model to make more specific measurements.</p>
  <p>You will have a problem however, with measuring depth. Depth is hard to estimate from an image because of the information that we lose when moving from a 3D to a 2D space.
  A longer explanation on this is available in <a href="https://stats.stackexchange.com/users/17760/machineepsilon">MachineEpsilon's</a> answer to the Cross Validated question &quot;<a href="https://stats.stackexchange.com/questions/322798/how-to-detect-the-exact-size-of-an-object-in-an-image-using-machine-learning/">how to detect the exact size of an object in an image using machine learning?</a>&quot; but quoting his main statements:</p>
  <blockquote>
  <p>This task of depth estimation is part of a hard and fundamental problem in computer vision called 3D reconstruction. Recovering metric information from images is sometimes called photogrammetry. It's hard because when you move from the real world to an image you lose information.</p>
  <p>Specifically, the projective transformation  that takes your 3D point  to your 2D point  via = does not preserve distance. Since  is a 2×3 matrix, calculating −1 to solve −1= is an underdetermined inverse problem. A consequence of this is that pixel lengths are not generally going to be meaningful in terms of real world distances</p>
  </blockquote>
  <p>However, that's not to say you could add additional sensors to resolve the depth estimation problem (ie. stereoscopic cameras or infrared distance sensors) if additional cost is not an issue.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T09:57:14.723Z
Answers.LastActivityDate: 2019-11-06T03:11:18.063Z
Answers.LastEditDate: 2020-06-17T09:57:20.710Z
Answers.UserDisplayName: evantkchong
Answers.Body: <p><a href="https://youtu.be/MMiKyfd6hA0" rel="nofollow noreferrer">Father Ted explains why this is a hard problem</a>.</p>
  
  <p>Seriously -- if you have stereo images it should be possible, since that's what <em>we</em> use for depth perception. If you know how far away points x1 and x2 are, then you can measure distance using trigonometry. No neural networks needed, I guess. <a href="https://en.wikipedia.org/wiki/Triangulation_(computer_vision)" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Triangulation_(computer_vision)</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T01:22:41.977Z
Answers.LastActivityDate: 2019-11-05T18:22:31.173Z
Answers.LastEditDate: 2019-11-05T18:22:31.173Z
Answers.UserDisplayName: jmmcd
Body: <p>I would like to develop a neural network to measure the distance between two opposite sides of an object in an image (in a similar way that the fractional caliper tool measures an object).</p>
  <p>So, given an image of an object, the neural network should produce the depth or height of the object.</p>
  <p>Which computer vision techniques and neural networks could I use to solve this problem?</p>
  
Tags: <neural-networks><computer-vision><image-processing><algorithm-request>
Title: How can I "measure" an object using Computer Vision techniques and neural networks?
UserDisplayName: Carme Afonso
ThreadText: # How can I "measure" an object using Computer Vision techniques and neural networks?
  
  (Asked by: username_0 on 2019-11-04)
  
  I would like to develop a neural network to measure the distance between two opposite sides of an object in an image (in a similar way that the fractional caliper tool measures an object).
  
  So, given an image of an object, the neural network should produce the depth or height of the object.
  
  Which computer vision techniques and neural networks could I use to solve this problem?
  
  **Tags:** neural-networks, computer-vision, image-processing, algorithm-request
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-11-05. Score: 2
  
  If the measurements you want from the object aren't too complicated (ie. length of a clearly defined feature), and if you are able to acquire a training dataset of images of the objects similar to what your model will see in your use case (same scale/distance), their bounding boxes and their measurements, a model you could try to implement is a [Multi-Task Convolutional Neural Network (MTCNN)](https://arxiv.org/abs/1604.02878).
  
  MTCNNs are typically used for face detection and alignment, but I would imagine it is possible to adapt them to your use case given proper training and tuning. If there are more complicated measurements that you want to obtain, you could pass on the detected objects to another model to make more specific measurements.
  
  You will have a problem however, with measuring depth. Depth is hard to estimate from an image because of the information that we lose when moving from a 3D to a 2D space.
  A longer explanation on this is available in [MachineEpsilon's](https://stats.stackexchange.com/users/17760/machineepsilon) answer to the Cross Validated question "[how to detect the exact size of an object in an image using machine learning?](https://stats.stackexchange.com/questions/322798/how-to-detect-the-exact-size-of-an-object-in-an-image-using-machine-learning/)" but quoting his main statements:
  
  > This task of depth estimation is part of a hard and fundamental problem in computer vision called 3D reconstruction. Recovering metric information from images is sometimes called photogrammetry. It's hard because when you move from the real world to an image you lose information.
  >
  > Specifically, the projective transformation that takes your 3D point to your 2D point via = does not preserve distance. Since is a 2×3 matrix, calculating −1 to solve −1= is an underdetermined inverse problem. A consequence of this is that pixel lengths are not generally going to be meaningful in terms of real world distances
  
  However, that's not to say you could add additional sensors to resolve the depth estimation problem (ie. stereoscopic cameras or infrared distance sensors) if additional cost is not an issue.
  
  
  ---
  
  ### Answer by username_2 on 2019-11-05. Score: 2
  
  [Father Ted explains why this is a hard problem](https://youtu.be/MMiKyfd6hA0).
  
  Seriously -- if you have stereo images it should be possible, since that's what *we* use for depth perception. If you know how far away points x1 and x2 are, then you can measure distance using trigonometry. No neural networks needed, I guess. <https://en.wikipedia.org/wiki/Triangulation_(computer_vision)>
  
  
  ---
  
  