how to find the distance between a webcam with an object ..?
Best Answer
Take a snapshot. Convert to grayscale. threshold it. Use regionprops() on it to find the MajorAxisLength. If the MajorAxisLength is greater than a pre-determined value, but less than another pre-determined value, then the card is between 30cm and 10cm, so work with that image. Otherwise go back and try again.
To the two "pre-determined value", take a snapshot when you know that the ID card is 30 cm away, and determine the regionprops MajorAxisLength; the other pre-determined value should be found from a snapshot taken 10 cm away.
The Euclidean distance calculation will be done within the regionprops MajorAxisLength request.
REad about imdistline; this will allow you to calculate the distance between the points interactively. For this you are supposed to have image toolbox.
[y,x] = find(I==1) ; % give the pixel value
The above line, gives you the coordinates/ points of the required pixel. YOu have the points in hand, you can do the process needed.
Best Answer