Jump to content

[Q] Ideas about getting location of the object which is in camras focus point


am2

Recommended Posts

Hi,
I have faced a problem and I hope I post my question in right place,
I want to develop an AR application,When a user focus camera on a building it recognize its location and load data based on its location,
I have some ideas how to find the location of building which is in front of camera
It can calculate distance(how?) from camera and building and estimate the exact location of building using phons location service.
It also can buffer a distance (how much?) from cameras location and find what is in that distance..
Any other ideas which we can do this job using android sensors?
Thank you so much

Link to comment
Share on other sites

You can drive here for focal length related issues http://en.wikipedia.org/wiki/Focal_length

 

The most simple formula to estimate distance to the object is 

BSF7a.png

where x is the size of the object on the sensor, f is focal length of the lens, X is the size of the object, and dis distance from nodal point to the object. x and f, and X and d are measured in the same units, e.g. mm and m respectively (to calculate x you'll need to estimate pixel size for your sensor; for example, for Pentax K20D it is 23.4 mm/4672 px ≈ 5.008e-3 mm/px, i.e. an image 100 px long corresponds to x = 50.08e-3 mm).

In the following I assume that the size of the object (X) is unknown, and the only known parameters are x(image size) and f (focal length).

The problem is that we cannot tell from one photo if is a small object very close to the camera or a big object far away, because the depth of field in landscape shots is usually very big (and that's why pinhole formula is applicable).

To solve this problem we may use two or more images to measure the distance. Provided you can measure all angles and distance between two camera positions, you can also calculate distance to the remote object. But measuring all angles is not an easy task.

An easier approach is to take two photos which stay on the same line with the object, with object in the center of the image. Let distance to the object on the first photo be d₁, and image size be x₁:

59Drq.png

Then if we move the camera s meters directly towards the object, then on the second photo we have image size x₂ slightly bigger than x₁:

MYcQx.png

Which gives us

roP1U.png

Evidently, if s is not big enough to affect image size significantly, you cannot estimate distance reliably, and need to use more complicated methods. The bigger is difference x₂ - x₁, the better.

Another formula is: -----------------------------------

distance to object (mm) = focal length (mm) * real height of the object (mm) * image height (pixels)
                          ---------------------------------------------------------------------------
                                       object height (pixels) * sensor height (mm)

  • Like 1
Link to comment
Share on other sites

You can drive here for focal length related issues http://en.wikipedia.org/wiki/Focal_length

 

The most simple formula to estimate distance to the object is 

BSF7a.png

where x is the size of the object on the sensor, f is focal length of the lens, X is the size of the object, and dis distance from nodal point to the object. x and f, and X and d are measured in the same units, e.g. mm and m respectively (to calculate x you'll need to estimate pixel size for your sensor; for example, for Pentax K20D it is 23.4 mm/4672 px ≈ 5.008e-3 mm/px, i.e. an image 100 px long corresponds to x = 50.08e-3 mm).

In the following I assume that the size of the object (X) is unknown, and the only known parameters are x(image size) and f (focal length).

The problem is that we cannot tell from one photo if is a small object very close to the camera or a big object far away, because the depth of field in landscape shots is usually very big (and that's why pinhole formula is applicable).

To solve this problem we may use two or more images to measure the distance. Provided you can measure all angles and distance between two camera positions, you can also calculate distance to the remote object. But measuring all angles is not an easy task.

An easier approach is to take two photos which stay on the same line with the object, with object in the center of the image. Let distance to the object on the first photo be d₁, and image size be x₁:

59Drq.png

Then if we move the camera s meters directly towards the object, then on the second photo we have image size x₂ slightly bigger than x₁:

MYcQx.png

Which gives us

roP1U.png

Evidently, if s is not big enough to affect image size significantly, you cannot estimate distance reliably, and need to use more complicated methods. The bigger is difference x₂ - x₁, the better.

Another formula is: -----------------------------------

distance to object (mm) = focal length (mm) * real height of the object (mm) * image height (pixels)

                          ---------------------------------------------------------------------------

                                       object height (pixels) * sensor height (mm)

Thank you for your great information,

As It seems The secound method is better because tacking two picture is a little hard for end user,But here the problem is getting real hieght of the object.

I was wondering what if we use spatial queries?we have the exact location of camera.we can find cameras direction using phones sensores. If we have a map of buildings. we can use a set of buffers to find closest polygon to our camera's location in the specified direction,

Is this possible using spatial queries?with assumption that there is a map of buildings around us

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.

Disable-Adblock.png

 

If you enjoy our contents, support us by Disable ads Blocker or add GIS-area to your ads blocker whitelist