Answers.Body: <p>You can use libraries OpenCV and Python to <a href="https://www.pyimagesearch.com/2015/01/19/find-distance-camera-objectmarker-using-python-opencv/" rel="nofollow noreferrer">find the distance.</a></p>
  <p>You can refer this : <a href="https://towardsdatascience.com/vehicle-detection-and-distance-estimation-7acde48256e1" rel="nofollow noreferrer">Vehicle detection and distance estimation.</a></p>
  <p>Since you didn't mention about dataset,you may consider datasets and methods in this <a href="https://arxiv.org/pdf/1806.10890.pdf" rel="nofollow noreferrer">paper</a>.</p>
  <p>If your camera is fixed/has many objects infront of it,you might use <a href="https://github.com/saivarshittha/latitude_longitude_bounds" rel="nofollow noreferrer">nearest object around camera approach.</a>.This approach is extremely useful if you want to deal with latitudes and longitudes.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-09T11:06:28.923Z
Answers.LastActivityDate: 2020-12-09T11:06:28.923Z
Answers.UserDisplayName: sai_varshittha
Answers.Body: <p><strong>In general, calculation of distance between camera and object is impossible if you don't have further scene dependent information.</strong></p>
  <p>To my knowledge you have 3 options:</p>
  <p><strong>Stereo Vision</strong></p>
  <p>If you have 2 cameras looking at the same scene from a different point of view you can calculate the distance with classical Computer Vision algorithms. This is called <a href="https://en.wikipedia.org/wiki/Computer_stereo_vision" rel="nofollow noreferrer">stereo vision</a>, or also <a href="https://en.wikipedia.org/wiki/Epipolar_geometry" rel="nofollow noreferrer">multiview geometry</a>.
  Stereo Vision is the reason why humans can infer the distance to objects around them (because we have 2 eyes).</p>
  <p><strong>Structure from Motion</strong></p>
  <p>You move your camera and therefore change your viewpoint and can essentially do stereo mapping over time. <a href="https://en.wikipedia.org/wiki/Structure_from_motion" rel="nofollow noreferrer">Structure from Motion</a></p>
  <p><strong>Scene Understanding</strong></p>
  <p>Why is it then still possible for a one-eyed person to infer depth to some extent? Because humans have lots of scene dependent understanding. If you see a rubber duck that takes half of your field of view, you know it's pretty close because you know a rubber duck is not big. If you don't know the size of rubber ducks it is impossible to know whether you see a big rubber duck that is far away or a small rubber duck that is really close.</p>
  <p>This is where Deep Learning based models come into play. A recent overview over monocular
  depth estimation can be found in <a href="https://arxiv.org/pdf/2003.06620.pdf" rel="nofollow noreferrer">Zhao2020</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-09T19:43:51.583Z
Answers.LastActivityDate: 2020-12-10T09:44:41.673Z
Answers.LastEditDate: 2020-12-10T09:44:41.673Z
Answers.UserDisplayName: Mr Vinagi
Body: <p>I want to create a Deep Learning model that measures the distance between the camera and certain objects in an image. Is it possible? Please, let me know some resources related to this task.</p>
  
Tags: <deep-learning><computer-vision><reference-request>
Title: How to calculate the distance between the camera and an object using Computer Vision?
UserDisplayName: dato nefaridze
ThreadText: # How to calculate the distance between the camera and an object using Computer Vision?
  
  (Asked by: username_0 on 2020-12-08)
  
  I want to create a Deep Learning model that measures the distance between the camera and certain objects in an image. Is it possible? Please, let me know some resources related to this task.
  
  **Tags:** deep-learning, computer-vision, reference-request
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-12-09. Score: 7 | Accepted answer
  
  **In general, calculation of distance between camera and object is impossible if you don't have further scene dependent information.**
  
  To my knowledge you have 3 options:
  
  **Stereo Vision**
  
  If you have 2 cameras looking at the same scene from a different point of view you can calculate the distance with classical Computer Vision algorithms. This is called [stereo vision](https://en.wikipedia.org/wiki/Computer_stereo_vision), or also [multiview geometry](https://en.wikipedia.org/wiki/Epipolar_geometry).
  Stereo Vision is the reason why humans can infer the distance to objects around them (because we have 2 eyes).
  
  **Structure from Motion**
  
  You move your camera and therefore change your viewpoint and can essentially do stereo mapping over time. [Structure from Motion](https://en.wikipedia.org/wiki/Structure_from_motion)
  
  **Scene Understanding**
  
  Why is it then still possible for a one-eyed person to infer depth to some extent? Because humans have lots of scene dependent understanding. If you see a rubber duck that takes half of your field of view, you know it's pretty close because you know a rubber duck is not big. If you don't know the size of rubber ducks it is impossible to know whether you see a big rubber duck that is far away or a small rubber duck that is really close.
  
  This is where Deep Learning based models come into play. A recent overview over monocular
  depth estimation can be found in [Zhao2020](https://arxiv.org/pdf/2003.06620.pdf)
  
  
  ---
  
  ### Answer by username_1 on 2020-12-09. Score: 4
  
  You can use libraries OpenCV and Python to [find the distance.](https://www.pyimagesearch.com/2015/01/19/find-distance-camera-objectmarker-using-python-opencv/)
  
  You can refer this : [Vehicle detection and distance estimation.](https://towardsdatascience.com/vehicle-detection-and-distance-estimation-7acde48256e1)
  
  Since you didn't mention about dataset,you may consider datasets and methods in this [paper](https://arxiv.org/pdf/1806.10890.pdf).
  
  If your camera is fixed/has many objects infront of it,you might use [nearest object around camera approach.](https://github.com/username_1/latitude_longitude_bounds).This approach is extremely useful if you want to deal with latitudes and longitudes.
  
  
  ---
  
  