我正在尝试使用Kinect SDK在WPF中开发基本的照片捕获应用程序。在Kinect_ColorFrameReady事件处理程序中捕获帧看起来很容易,但我想要做的是在用户说出已经在我的Grammar.xml中定义的“Capture”时捕获帧。然后我想用像bmp,jpeg这样的图像扩展名来保存它...我应该在下面的代码中的注释行中做什么:
private void speechRecognized(object sender, SpeechRecognizedEventArgs e)
{
recognizedWord = e.Result.Semantics.Value.ToString();
if (recognizedWord == "Capture")
{
// Capture rgb frame?
}
}
答案 0 :(得分:1)
您可以让WriteableBitmap
用于显示存储为全局变量的图像。
WriteableBitmap image;
... //write/display bitmap
private void speechRecognized(object sender, SpeechRecognizedEventArgs e)
{
recognizedWord = e.Result.Semantics.Value.ToString();
if (recognizedWord == "Capture")
{
using (FileStream stream5 = new FileStream(filename, FileMode.Create))
{
JpgBitmapEncoder encoder5 = new JpgBitmapEncoder();
encoder5.Frames.Add(BitmapFrame.Create(image));
encoder5.Save(stream5);
stream5.Close();
}
}
}