我正在尝试使用C#创建一个用于Windows Kinect的接口。到目前为止,我已经能够实现所有功能,并且使用手形光标可以完美地完成手势移动。然后,我的任务是在程序中实现语音识别,这样用户也可以使用手势同时提供程序语音命令。问题出在我的Window_Loaded方法中,我已经放置了一个sensor.Start();和sensorChooser.Start();在方法中,但只有其中一个将依赖于首先声明的方法。
我的问题是如何解决此问题,以便能够同时运行传感器和传感器,以便能够使用语音识别和手势。
感谢您的帮助,目前这是方法。
private void Window_Loaded(object sender,RoutedEventArgs e) {
if(KinectSensor.KinectSensors.Count > 0)
{
sensor = KinectSensor.KinectSensors[0];
}
this.sensorChooser = new KinectSensorChooser();
this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
initializeSpeech();
sensor.Start();
sensorChooser.Start();
//string[] lines = { "using System;", "namespace First {", "public class Program {", "public static void Main() {", @"Console.WriteLine(""Hello test!""); } } }" };
//System.IO.File.WriteAllLines(@"C:\Users\John\Documents\University\Interface Programming\CW 2\WpfApplication1\test2.txt", lines);
//string code = System.IO.File.ReadAllText(@"C:\Users\John\Documents\University\Interface Programming\CW 2\WpfApplication1\test2.txt");
//runCode(code);
string fileDirectory = System.IO.Directory.GetCurrentDirectory() + @"\User Projects";
DirectoryInfo textFileDirectory = new DirectoryInfo(fileDirectory);
FileInfo[] Files = textFileDirectory.GetFiles("*.txt");
Thickness m = Margin;
m.Left = 0;
foreach (FileInfo file in Files)
{
KinectTileButton btn = new KinectTileButton
{
Label = file.Name,
};
btn.Click += buttonRunCode;
btn.VerticalAlignment = VerticalAlignment.Center;
btn.HorizontalAlignment = HorizontalAlignment.Left;
loadedButtons.Children.Add(btn);
}
}
答案 0 :(得分:0)
自此解决了这个问题后,我提出了:
this.sensorChooser = new KinectSensorChooser();
this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
initializeSpeech();
&安培;
sensorChooser.Start();
进入main方法并且工作正常:)