Kinect から 2 つのスクリーンショット (1 つの IR イメージと 1 つの深度イメージ) を取得し、それを 2 つの画像ボックスに直接ロードし、マウスをクリックして IR スクリーンショットのポイントの位置を測定できるプログラムを作成しています。
IR スクリーンショットで x- と y- の位置を取得するのに問題はありません。必要なのは深さ (mm) です - IR と深さの画像が同じカメラから取得されたことを考えると、マウスをクリックするとx 座標と y 座標を深度画像にリンクして、深度値を mm 単位で取得する必要があります。
私の考えは、変数short depth = depthPixels[i].Depth;にアクセスすることでした。メソッドSensorDepthFrameReadyで。しかし、なぜうまくいかなかったのでしょうか。深度画像が RGB ではなくグレースケールで表示されるのはなぜですか (Kinect Studio とは異なります)。
private void SensorDepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
{
using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (depthFrame != null)
{
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);
int colorPixelDDIndex = 0;
for (int i = 0; i < this.depthPixels.Length; ++i)
{
short depth = depthPixels[i].Depth;
...
}
this.colorBitmapDD.WritePixels(new Int32Rect(0, 0, this.colorBitmapDD.PixelWidth, this.colorBitmapDD.PixelHeight),this.colorPixelsDD,this.colorBitmapDD.PixelWidth * sizeof(int),0);
}
}
}
private void imageIR_MouseClick(object sender, System.Windows.Input.MouseEventArgs e)
{
System.Windows.Point mousePoint = e.GetPosition(imageIR);
double xpos_IR = mousePoint.X;
double ypos_IR = mousePoint.Y;
lbCoord.Content = "x- & y- Koordinate [pixel]: " + xpos_IR + " ; " + ypos_IR;
zpos.Content = "z- Koordinate [mm]: " + depth;
}
問題を解決するためのアイデアはありますか? 前もって感謝します。
メインプログラムのスクリーンショット: