Question

Basically I want to take a fixed straight line across the devices point of view and determine if anything intercepts it but in my example I want to make the "laser line" configurable with regards to the distance from the top of the field of view.

Now it's easy enough to get the depth data at a given pixel point simply by doing this.

var depthInMM = DepthImagePixel.Depth;

and its also easy to simply say I want to focus on the 100th line of pixels from the top by doing something like this.

for (int i = 0; i < this._DepthPixels.Length; ++i) //_DepthPixels.Length is obviously 307200 for 640x480
{
    if (i >= 64000 && i <= 64640) //Hundredth vertical pixel line
    {
        //Draw line or whatever
    }
}

Which ends up with something like this.

enter image description here

BUT for example I might want to have the line intercept at 50 cm from the top of the field of view at 3 meters depth. Now obviously I understand that as the depth increases so does the area represented but I cannot find any reference or myself work out how to calculate this relationship.

So, how can one calculate the coordinate space represented at a given depth utilizing the Kinect sensor. Any help sincerely appreciated.

EDIT:

So if I understand correctly this can be implemented as such in C#

double d = 2; //2 meters depth
double y = 100; //100 pixels from top
double vres = 480; //480 pixels vertical resolution
double vfov = 43; //43 degrees vertical field of view of Kinect
double x = (2 * Math.Sin(Math.PI * vfov / 360) * d * y) / vres;
//x = 0.30541768893691434
//x = 100 pixels down is 30.5 cm from top field of view at 2 meters depth
Was it helpful?

Solution

     2 sin(PI VFOV / 360) D Y
X = --------------------------
              VRES

X: distance of your line from the top of the image in meters

D: distance - orthogonal to the image plane - of your line from the camera in meters

Y: distance of your line from the top of the image in pixels

VRES: vertical resolution of the image in pixels

VFOV: vertical field of view of the camera in degrees

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top