以毫米为单位显示深度数据C# [英] Show depth data in millimeters C#

查看:73
本文介绍了以毫米为单位显示深度数据C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个程序,用户可以获得颜色流和深度流。在深度图像中,用户应该能够选择两个感兴趣的点并获得x和y的坐标(以像素为单位)和点的深度(mm)。

I'm trying to write a program in wich the user gets the color stream and the depth stream presented. In the depth image the user should be able to select two points of interest and get the coordinates of x and y in pixels and the depth of the point in mm.

在当前状态下我的程序用户可以选择两点,但我真的需要帮助计算给定坐标的深度。

In the current state of my program the user is able to selcet the two point, but i really need help with calculating the depth of the given coordinates.

我真的希望你能帮助我

BeeKinect

BeeKinect

private void Mouse_Click(object sender, System.Windows.Input.MouseEventArgs e)
        {
            System.Windows.Point mousePoint = e.GetPosition(DepthImage);

            double xpos = mousePoint.X;
            double ypos = mousePoint.Y;
            double zpos;

            int XPointOne = 0;
            int YPointOne = 0;
            int XPointTwo = 0;
            int YPointTwo = 0;

            int x = (int)xpos;
            int y = (int)ypos;

            //int z = (ushort)pixelData[x + y * this.depthFrame.Width];
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (string.IsNullOrEmpty(TxtCoordX.Text))
                {
                    if (x < 0 || y < 0)
                    {
                        TxtCoordX.Text = string.Empty;
                        TxtCoordY.Text = string.Empty;
                    }
                    else if (x > 640 || y > 480)
                    {
                        TxtCoordX.Text = string.Empty;
                        TxtCoordY.Text = string.Empty;
                    }
                    else
                    {
                        XPointOne = x;
                        YPointOne = y;
                        TxtCoordX.Text = string.Format("X: {0}", x);
                        TxtCoordY.Text = string.Format("Y: {0}", y);
                    }
                }
                else
                {
                    if (x < 0 || y < 0)
                    {
                        TxtCoordX2.Text = string.Empty;
                        TxtCoordY2.Text = string.Empty;
                    }
                    else if (x > 640 || y > 480)
                    {
                        TxtCoordX2.Text = string.Empty;
                        TxtCoordY2.Text = string.Empty;
                    }
                    else
                    {
                        XPointTwo = x;
                        YPointTwo = y;
                        TxtCoordX2.Text = string.Format("X: {0}", x);
                        TxtCoordY2.Text = string.Format("Y: {0}", y);
                    }
                }

                if (depthFrame != null)
                {
                    zpos=GetDepthValue(dFrame,Convert.ToInt16(mousePoint.X),Convert.ToInt16(mousePoint.Y));
                    TxtCoordZ2.Text = string.Format("Y: {0}", zpos);
                }
            }
        }

推荐答案

在进行计算之前,您应该将深度点映射到Skeleton(World)坐标。一旦这些点在世界空间中,就使用毕达哥拉斯定理。
You should be mapping the depth point to Skeleton(World) coordinates before doing your calculation. Once the points are in world space use Pythagorean theorem.


这篇关于以毫米为单位显示深度数据C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆