1

I am drawing situation.

Camera (Raspberry pi) looking on scene, there is an object. I know real width and height of object. Is there any way, how can I calculate distance between camera and object from cam photo? Object on picture is not always situated in the middle. I know height of camera and angle of camera.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Pan Orm
  • 13
  • 3
  • Possible duplicate of [Finding distance to an LED](http://stackoverflow.com/questions/42762538/finding-distance-to-an-led) – Spektre Mar 26 '17 at 14:39

1 Answers1

1

Yes, but it's gonna be difficult. You need the intrinsic camera matrix and a depth map. If you don't have them, then forget it. If you only posses a RGB image then it won't work.

Armen Avetisyan
  • 1,140
  • 10
  • 29
  • So answer is: There is not simple formula for this problem. Ok? – Pan Orm Mar 25 '17 at 12:01
  • Correct, it's not simple. – Armen Avetisyan Mar 25 '17 at 12:02
  • Actually, you need the intrinsic camera matrix, and if you can find the object in the image, it's very easy to calculate the distance. – Photon Mar 25 '17 at 12:33
  • Find object in picture is not problem. But i have no idea how can i get this matrix from picture or cam. I use standart Raspberry pi cam. – Pan Orm Mar 25 '17 at 14:29
  • Ok, I know intrinsic matrix and position of object in picture. Can you tell me method for distance calculate? – Pan Orm Mar 27 '17 at 11:59
  • Without `depth map` it will not work. period. The intrinsic matrix is just a collection of some parameters of the camera to relate to the global `xyz` coordinate world, but it will tell you nothing about the depth. – Armen Avetisyan Mar 27 '17 at 13:42
  • @PanOrm of coarse you can obtain the distance form RGB alone.... If you had a depth map then you already have the distance and no algo is needed. The idea is to estimate view layers and their scale from known objects in the image (etalones) and then just convert unknown object visual size and interpolated scale at its location into real units of size and distance. For that you need FOV of camera and some etalones in the view or knonw geometry of something. If your object is knonw then it is even simpler like in the answer I linked as duplicate ... – Spektre Mar 29 '17 at 07:29
  • @PanOrm this is another example: [Which is the best way to estimate measure of photographed things?](http://stackoverflow.com/a/34085449/2521214) but it is very simplified the link [selection criteria for different projections](http://stackoverflow.com/a/32795205/2521214) provides complete answer but you do not have the rep to see deleted QAs and was deleted by community which is sad as you're not alone to ask this kind of thing but you guys who needed this forget to vote (usually low rep users)... so without any positive attention it got deleted. – Spektre Mar 29 '17 at 07:33