これ何て呼びますか

OpenNI(キネクトセンサー)のサンプルプログラムは、C#のパネルにbitmapを描画し続けるのですが、
描画中、そのパネルのマウスイベントが生じない(無視されている?)ようです。マウスの位置から
補助線を引いたりしたいのですが、描画中にマウスイベントが取得できる方法をご存知の方、お願いします。以下サンプルソースそのままです。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenNI;
using System.Threading;
using System.Drawing.Imaging;

namespace SimpleViewer.net
{


private unsafe void ReaderThread()
{
DepthMetaData depthMD = new DepthMetaData();

while (this.shouldRun)
{
try
{
this.context.WaitOneUpdateAll(this.depth);
}
catch (Exception)
{
}

this.depth.GetMetaData(depthMD);


lock (this)
{
Rectangle rect = new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height);
BitmapData data = this.bitmap.LockBits(rect, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

ushort* pDepth = (ushort*)this.depth.DepthMapPtr.ToPointer();

// set pixels
for (int y = 0; y < depthMD.YRes; ++y)
{
byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride;
for (int x = 0; x < depthMD.XRes; ++x, ++pDepth, pDest += 3)
{
byte pixel = (byte)this.histogram[*pDepth];
pDest[0] = 0;
pDest[1] = pixel;
pDest[2] = pixel;
}
}

this.bitmap.UnlockBits(data);
}

this.Invalidate();
}
}

private readonly string SAMPLE_XML_FILE = @"../../../Data/SamplesConfig.xml";

private Context context;
private ScriptNode scriptNode;
private DepthGenerator depth;
private Thread readerThread;
private bool shouldRun;
private Bitmap bitmap;
private int[] histogram;
}
}

A 回答 (1件)

求めていることの解答にはなりませんが,



とりあえず,いま,Kinect for Windows SDK 1.5で試してみたら,

Panelに深度画像を表示し続けても
普通にマウスイベントは取得できました.

ご参考まで.

この回答への補足

解決しました!!!! ( 多少疑問は残りますが。)
サンプルのPanelView のマウスイベントは受け取れませんが、フォームのマウスイベント
は機能しました。toro_nekomataさんはフォームのClickイベントを使いましたか?
DockがFillの設定でフォームいっぱいだったので気づきませんでした。

イベントの発生を勉強しないといけませんね。ありがとうございました。

補足日時:2012/10/02 08:15
    • good
    • 0
この回答へのお礼

ありがとうございます。
private void panelView_Click(object sender, EventArgs e)
{
textBox1.Text = System.Windows.Forms.Cursor.Position.X.ToString();
}
センサーはXtionProLive なのですが、それとは関係ないですよね。
たったこれだけのコードで、ファイルに書き出したら、、、、同じ、ためしに
このイベントの中にブレークポイントを置いてみると、デバッガが停止もしません。
つまりマウスイベントが起きていないかどこかにいってしまっている。これを
確認できる知識は持っていません。
同じフォームに描画されている以外のパネルを設置してみると
ちゃんとマウス座標が取得できるのでなにか描画に特別な部分があるのかと
思ったのです。すみませんが、お使いのソースを教えていただけませんか?
同じことを試してみたいです。

お礼日時:2012/10/02 07:36

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!