0

XBox-Kinect (ベータ SDK) を使用しています。

ロボットに、多くのオブジェクトを含むボックスからオブジェクトをつかむように指示しようとします (学士号取得)。そのためには、kinect に最も近いオブジェクトの最も近いポイントを見つける必要があります。領域の成長によって完全なオブジェクトをローカライズし、ロボットのグラブ ポイントを見つけることができます。

今、私はそのトピックについて2つの質問があります:

  1. この点の x 座標と y 座標を調べるにはどうすればよいですか? (距離はすでにあります)
  2. private byte[] FindMinimum(ImageFrame imageFrame) ボタンをクリックして最も近い距離を見つけるにはどうすればよいですか?

これが私のコードです:

    void nui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
    {
        image1.Source = e.ImageFrame.ToBitmapSource();
         byte[] Minumum = FindMinimum(e.ImageFrame);
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        FindMinimum();
    }

    private byte[] FindMinimum(ImageFrame imageFrame)
    {
        int height = imageFrame.Image.Height;
        int width = imageFrame.Image.Width;

        Byte[] depthData = imageFrame.Image.Bits;

        Byte[] colorFrame = new byte[imageFrame.Image.Height * imageFrame.Image.Width * 4];


        int min = int.MaxValue, max = int.MinValue;
        for (int i = 0; i < depthData.Length; i += 2)
        {
            int dist = GetDistance(depthData[i], depthData[i + 1]);
            if (dist < min && dist > 0) min = dist;
            if (dist > max) max = dist;
        }
        textBox1.Text = Convert.ToString(min);
        return colorFrame;
    }

    private int GetDistance(byte firstFrame, byte secondFrame)
    {
        int distance = (int)(firstFrame | secondFrame << 8);
        return distance;
    }

    private void Window_Closed(object sender, EventArgs e)
    {
        nui.Uninitialize();
    }
}

}

4

0 に答える 0