Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Kiect SDK V1.8 C# 2010...I have to do a code that will listen to my voice and pr

ID: 654229 • Letter: K

Question

Kiect SDK V1.8 C# 2010...I have to do a code that will listen to my voice and press a specific key. I got the code for that correct now i need to do the same thing but using hand gestures..Please help.. I am getting the folowing errors........

Error   4   The name 'fasle' does not exist in the current context   
Error   5   The name 'isMoveLeftGestureActive' does not exist in the current context   
Error   6   The name 'isMoveLeftGestureActive' does not exist in the current context   
Error   7   The name 'isMoveLeftGestureActive' does not exist in the current context   
Error   1   The name 'isMoveRightGestureActive' does not exist in the current context
Error   2   The name 'isMoveRightGestureActive' does not exist in the current context   
Error   3   The name 'isMoveRightGestureActive' does not exist in the current context
Error   8   The name 'isStopGestureActive' does not exist in the current context   
Error   9   The name 'isStopGestureActive' does not exist in the current context   

namespace Speech
{
using System;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.Kinect;
using Microsoft.Speech.AudioFormat;
using Microsoft.Speech.Recognition;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;


public class Program
{
public static void Main(string[] args)
{
// Obtain a KinectSensor if any are available
KinectSensor sensor = (from sensorToCheck in KinectSensor.KinectSensors where sensorToCheck.Status == KinectStatus.Connected select sensorToCheck).FirstOrDefault();
if (sensor == null)
{
Console.WriteLine(
"No Kinect sensors are attached to this computer or none of the ones that are " +
"attached are "Connected". " +
"Attach the KinectSensor and restart this application. " +
"Make sure the Power Adapter of the Kinect sensor is plugged in " +
"Press any key to continue. ");

// Give a chance for user to see console output before it is dismissed
Console.ReadKey(true);
return;
} // end if (sensor == null)

sensor.Start();

// Obtain the KinectAudioSource to do audio capture
KinectAudioSource source = sensor.AudioSource;
source.EchoCancellationMode = EchoCancellationMode.None; // No AEC for this sample
source.AutomaticGainControlEnabled = false; // Important to turn this off for speech recognition

RecognizerInfo ri = GetKinectRecognizer();

if (ri == null)
{
Console.WriteLine("Could not find Kinect speech recognizer. Please refer to the sample requirements.");
return;
}

Console.WriteLine("Using: {0}", ri.Name);

// NOTE: Need to wait 4 seconds for device to be ready right after initialization
int wait = 4;
while (wait > 0)
{
Console.Write("Device will be ready for speech recognition in {0} second(s). ", wait--);

Thread.Sleep(1000);
}

Console.Write(" ");
//=========================================================================   
  
//==========================================================================
sensor.Stop();
} // end public static void Main

private static RecognizerInfo GetKinectRecognizer()
{
Func<RecognizerInfo, bool> matchingFunc = r =>
{
string value;
r.AdditionalInfo.TryGetValue("Kinect", out value);
return "True".Equals(value, StringComparison.InvariantCultureIgnoreCase) && "en-US".Equals(r.Culture.Name, StringComparison.InvariantCultureIgnoreCase);
};
return SpeechRecognitionEngine.InstalledRecognizers().Where(matchingFunc).FirstOrDefault();
}

////////////////////////////////////////////////////GESTURE//////////////////////////////////////////////////////////////////////////

private void ProcessControlGesture(Joint head, Joint rightHand,Joint leftHand, Joint spine)
{
if (leftHand.Position.X > head.Position.X && rightHand.Position.Y > spine.Position.Y)

{
if (!isMoveRightGestureActive)
{
isMoveRightGestureActive = true;
Console.WriteLine(" Move Left Gesture Regniized: MOVE LEFT");
System.Windows.Forms.SendKeys.SendWait("F3");
}
}
else
{
isMoveRightGestureActive = fasle;
}

if(rightHand.Position.X < head.Position.X && leftHand.Position.Y > spine.Position.Y)
{
if (!isMoveLeftGestureActive)
{
isMoveLeftGestureActive = true;
Console.WriteLine(" Move Right Gesture Recognized: MOVE RIGHT");
System.Windows.Forms.SendKeys.SendWait("{F1}");
}
}
else{
isMoveLeftGestureActive = false;
}

if (leftHand.Position.Y > head.Position.Y && rightHand.Position.Y > head.Position.Y)
{
if (!isStopGestureActive)
{
isStopGestureActive = true;
Console.WriteLine("STOP");
System.Windows.Forms.SendKeys.SendWait("{F5}");

}
  
}
}

} // end public class Program
} // end namespace Speech

Explanation / Answer

The following part has the error.

or this sample
source.AutomaticGainControlEnabled = false; // Important to turn this off for speech recognition

RecognizerInfo ri = GetKinectRecognizer();

if (ri == null)