wpf - 如何在SpeechRecognized事件处理程序中保存RGB帧?

标签 wpf kinect kinect-sdk

我正在尝试使用Kinect SDK在WPF中开发一个基本的照片捕获应用程序。在Kinect_ColorFrameReady事件处理程序中捕获帧看起来很容易,但是我要做的是当用户说“捕获”时捕获帧,这已经在我的Grammar.xml中定义了。然后,我想使用bmp,jpeg等图像扩展名保存它。在下面代码的注释行中,我应该怎么做:

private void speechRecognized(object sender, SpeechRecognizedEventArgs e)
{
        recognizedWord = e.Result.Semantics.Value.ToString();

        if (recognizedWord == "Capture")
        {
            // Capture rgb frame?
        }
}

最佳答案

您可以使用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();
        }
    }
}

关于wpf - 如何在SpeechRecognized事件处理程序中保存RGB帧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22194598/

相关文章:

c# - 让 Caliburn.Micro 使用 Windsor 在单独的程序集中绑定(bind)我的 View 和 VM

c# - 如何在 DataTemplate 的 DataType 属性中引用泛型类型?

c# - Kinect 应用程序的源逆向工程

windows - 微软 Kinect(适用于 Windows)

c# - Kinect v2 手到鼠标的位置在手关闭时下降

c# - 如何为User32.dll的sendInput方法在mouse_input中设置适当的缩放值?

WPF 和 WCF 数据服务在查询级别进行身份验证?

c# - 在 WPF 中查看 Word 文档

java - Kinect 2 对象跟踪最佳方法

kinect - 适用于 Windows 的 C# Kinect : How to combining/overlaying the skeleton and color stream/image?