MATLAB: [ASK] Euclidean Distance

euclidean distanceImage Acquisition Toolbox

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.