How to get the distance to an object and size of the object using the camera (Android device)?
I am seeking an Android solution to calculate the distance to an object and then determine the size (height, width, length).
Example would be a bridge, building. 开发者_运维知识库
This information is not available in a single image. It would be possible using stereoscopic imaging i.e. take two images spatially separated with some (not insignificant) processing.
Although the focus control might appear to give out of band information on depth in practice it would be very inaccurate with a camera with such a small sensor at anything beyond a few feet since the depth of field is very large.
You can't.
Consider the ship on following image:
Even Human eyes with brain can't perform such task, when there are 2 of them(so that 3d is theoretically possible). With 1 camera it is impossible geometrically.
Most advanced visual systems in the world(astronomy, NASA) measure distance using other ways (ultra-red radiance, other waves).
If you find the distance you find everything through angles. If you >1 cameras and know both sets of angles you can find 3D parameters by basic school geometry.
For this problem I recommend these links:
- Is it possible to measure distance to object with camera?
- How can I determine distance from an object in a video?
Yesterday I wrote a short program (which nevertheless took me 2 hours) to get the x,y,z coordinate values to calculate the angle of the phone. Referring to the first link I want to calculate the distance to an object. With these x,y,z coordinates + the height in which I hold the camera it should be possible. I just want to try this in a room - interested in the precision.
to get the "a" you find the z accelerometer value. convert it to a double. use the a = Math.ToRadians(a)
function. Then a = Math.tan(a)
. Then a = a * h.
精彩评论