3

I have an image that represents a projection. I am going to explain the problem with an example:

In the screen, there is a line from one point E(100,200) to another point H (150,100). A represent one point that in the real world is at 200 cm of distance while B is a point that in real world is at 300 cm of distance.

The thing that I would like to know is this:

Given one point of the line that passes for these two points, is there a way to calculate the z distance data that it should have?

What if the z distance is not a linear function but is some logarithmic function?

If it's not clear ask me everything,

Depth Distance Projection

Cheers

phwd
  • 19,975
  • 5
  • 50
  • 78
manuz
  • 31
  • 2
  • 2
    dont have gimp, you should save the file as a jpeg and paste it in the question, makes everyone else's life much easier – davin Apr 27 '11 at 15:18
  • 1
    E, H, A, B... Aren't there duplicates here ? I agree with davin, your description lacks terribly clarity... What is the z distance you talk about ? B is at 300 cm of distance... of what/who ? – Emmanuel Apr 27 '11 at 15:31
  • sorry guys, that image was created before.. you're right, the z distance is the distance from the camera to the point – manuz Apr 27 '11 at 15:50

2 Answers2

3

I think what you're getting at is perspective correct interpolation. If you know the depth at E and a depth at H, and B is on the line (in the image) joining these two points, solve for the depth at B with:

1/Zb = s * 1/Ze + (1-s) * 1/Zh

where s is the normalized distance/interpolation parameter (between 0 and 1) along the line in screen space, meaning B = s * E + (1-s) * H

YXD
  • 31,741
  • 15
  • 75
  • 115
  • Knowing that perspective projection is inversely proportional to distance this is where I was heading too - looks good to me! – Alnitak Apr 27 '11 at 15:29
  • @Mr E ,I have problems in the calculus of this s parameter. Can you ogive me some more info about how can I calculate it? – manuz Apr 27 '11 at 16:09
  • 1
    I may have misread your question re. which points are which. My assumption is that you have two points in the image, E and H, both have a known depth. You want to calulate the depth at a point along the line joining these two points. The second equation is the equation of a straight line (segment) between E and H. 's' is the variable which moves you along the line. Currently, how do you know that the third point is on a line joining the two points? – YXD Apr 27 '11 at 16:17
  • I am away from my computer for a few hours now but can answer questions later – YXD Apr 27 '11 at 16:17
  • 1
    Thanks, It's a constraint the fact that the third point is on the line. Let's take the image I posted as example, with the a,b,c points. I know the x,y,z coordinates of a and b. If I want to calculate the z coordinate of a point C (that is in the line that passes between A and B), knowing the x and y coordinates (300,300) in this case. How can I find its z coordinate (1.5 meters in that figure) – manuz Apr 27 '11 at 16:51
0

Use homogeneous coordinates, which can be linearly interpolated in screen space (for depth and texture): http://www.cs.unc.edu/~olano/papers/2dh-tri/

  • ok I'm going to read it but I think that even using a different coordinate system the problem remains.. – manuz Apr 27 '11 at 22:08
  • The Z distance is directly computable from the homogeneous coordinates. In fact, 1/Z interpolates linearly (and is the last homogeneous coordinate, usually), if you want to skip to the answer. –  Apr 28 '11 at 04:37
  • I think I've solved the problem using the real world coordinates so thank you anyway :) – manuz Apr 28 '11 at 13:23
  • 1
    If you're using anything but linear interpolation of 1/depth, I'm not sure what you're doing. –  Apr 28 '11 at 13:35
  • I've modified all my code in order to use Kinect's real world coordinates and working with them I can easily find all the z-coordinate I need. – manuz Apr 28 '11 at 17:38