That is the entire science of photogrammetry. Which has made tremendous progress in the past 10 years. There's many tools which will do it for you.