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?
Asked
Active
Viewed 869 times
-2
-
you have to compensate for the fact that (in pixels) the distance is increasing. – Mohammad Athar Apr 17 '18 at 18:22
-
And how would I do that? – lololo wote Apr 18 '18 at 16:41
-
there's probably a dozen different ways to do it. Do some research, try things out (by hand, maybe), and come back with more specific questions. – Mohammad Athar Apr 18 '18 at 18:25
2 Answers
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