-2

Im tracking two point from my face in a web cam stream using opencv. Im currently doing dist.euclidean(a, b) but the distance change depending how far Im from the camera and this is not what I want, I want the distance to be the same not matter where I am. How can I solve this?

lololo wote
  • 113
  • 1
  • 1
  • 6

2 Answers2

1

You need to know the focal length of your webcam as well as the distance you are from the webcam, otherwise, you cannot know the absolute distance since a camera only measure angle.

TwistedSim
  • 1,960
  • 9
  • 23
0

You have to calculate a ratio between your distance and a given distance taken as model. For example the distance between the eyes.

Coming to your question, to correctly estimate the real distance in the picture you should have something with a known length at the same distance from the camera. In this way you may be able to get the real measure doing a pseudo code like the following

fakeDistance = 5
realLengthOfKnownObject = 10
apparentLengthOfKnownObject = 8
ratio = realLengthOfKnownObject/apparentLengthOfKnownObject
realDistance = fakeDistance * ratio

Obvious this is really hard to obtain.

I found this article that might help. Good luck.

decadenza
  • 2,380
  • 3
  • 18
  • 31