I'm trying to develop a basic photograph capturing application in WPF with Kinect SDK. It looks easy to capture frames in Kinect_ColorFrameReady event handler but what I want to do is to capture frame when the user says "Capture" which is already defined in my Grammar.xml. And then I want to save it with an image extension like bmp,jpeg... What should I do in the commented line in the code below:
private void speechRecognized(object sender, SpeechRecognizedEventArgs e)
{
recognizedWord = e.Result.Semantics.Value.ToString();
if (recognizedWord == "Capture")
{
// Capture rgb frame?
}
}
You can have the WriteableBitmap
used to display the image stored as a global variable.
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();
}
}
}