本文整理汇总了C#中Microsoft.Kinect.Toolkit.KinectChangedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# KinectChangedEventArgs类的具体用法?C# KinectChangedEventArgs怎么用?C# KinectChangedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KinectChangedEventArgs类属于Microsoft.Kinect.Toolkit命名空间,在下文中一共展示了KinectChangedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SeletorKinect_KinectChanged
private void SeletorKinect_KinectChanged(object sender, KinectChangedEventArgs kinectArgs)
{
if (kinectArgs.OldSensor != null)
{
try
{
if (kinectArgs.OldSensor.DepthStream.IsEnabled)
kinectArgs.OldSensor.DepthStream.Disable();
if (kinectArgs.OldSensor.SkeletonStream.IsEnabled)
kinectArgs.OldSensor.SkeletonStream.Disable();
if (kinectArgs.OldSensor.ColorStream.IsEnabled)
kinectArgs.OldSensor.ColorStream.Disable();
}
catch (InvalidOperationException)
{
// Captura exceção caso o KinectSensor entre em um estado inválido durante a desabilitação de um fluxo.
}
}
if (kinectArgs.NewSensor != null)
{
if (MetodoInicializadorKinect != null)
MetodoInicializadorKinect(SeletorKinect.Kinect);
}
}
开发者ID:gilgaljunior,项目名称:CrieAplicacoesInterativascomoMicrosoftKinect,代码行数:28,代码来源:InicializadorKinect.cs
示例2: SensorChooserOnKinectChanged
private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs args)
{
MessageBox.Show(args.NewSensor == null ? "No Kinect" : args.NewSensor.Status.ToString());
}
示例3: myChooser_KinectChanged
void myChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
if (null != e.OldSensor)
{
//Alten Kinect deaktivieren
if (mySensor != null)
{
mySensor.Dispose();
}
}
if (null != e.NewSensor)
{
mySensor = e.NewSensor;
mySensor.ColorStream.Enable(ColorImageFormat.InfraredResolution640x480Fps30);
myColorArray = new byte[this.mySensor.ColorStream.FramePixelDataLength];
myBitmap = new WriteableBitmap(this.mySensor.DepthStream.FrameWidth, this.mySensor.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Gray16, null);
image1.Source = myBitmap;
mySensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(mySensor_AllFramesReady);
try
{
this.mySensor.Start();
SensorChooserUI.Visibility = Visibility.Hidden;
}
catch (IOException)
{
this.mySensor = null;
}
}
}
示例4: ChooserSensorChanged
private static void ChooserSensorChanged(object sender, KinectChangedEventArgs e)
{
//As of 6/12/2013 @ 10:30AM, the program never enters here
var old = e.OldSensor;
StopKinect(old);
var newsensor = e.NewSensor;
if (newsensor == null)
{
return;
}
newsensor.SkeletonStream.Enable();
//newsensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
//newsensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
newsensor.AllFramesReady += SensorAllFramesReady;
try
{
newsensor.Start();
}
catch (System.IO.IOException)
{
//maybe another app is using Kinect
_chooser.TryResolveConflict();
}
}
示例5: sensorChooser_KinectChanged
void sensorChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
if (e.OldSensor != null)
{
e.OldSensor.Stop();
}
if (e.NewSensor != null)
{
e.NewSensor.ColorStream.Enable();
e.NewSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
//var parameters = new TransformSmoothParameters
//{
// Smoothing = 0.3f,
// Correction = 0.0f,
// Prediction = 0.0f,
// JitterRadius = 1.0f,
// MaxDeviationRadius = 0.5f
//};
//e.NewSensor.SkeletonStream.Enable(parameters);
e.NewSensor.SkeletonStream.Enable();
e.NewSensor.DepthStream.Range = DepthRange.Near;
e.NewSensor.SkeletonStream.EnableTrackingInNearRange = true;
e.NewSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
e.NewSensor.AllFramesReady += NewSensor_AllFramesReady;
_colorBitmap = Coding4Fun.Kinect.Wpf.WriteableBitmapHelper.CreateWriteableBitmap(e.NewSensor.ColorStream);
_image1.Source = _colorBitmap;
}
}
示例6: myChooser_KinectChanged
void myChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
if (null != e.OldSensor)
{
//Alten Kinect deaktivieren
if (mySensor != null)
{
mySensor.Dispose();
}
}
if (null != e.NewSensor)
{
mySensor = e.NewSensor;
mySensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
myDArray1 = new short[this.mySensor.DepthStream.FramePixelDataLength];
myDArray2 = new short[this.mySensor.DepthStream.FramePixelDataLength];
myDArray3 = new short[this.mySensor.DepthStream.FramePixelDataLength];
myHistoArray = new int[50];
myFinalArray = new short[this.mySensor.DepthStream.FramePixelDataLength];
mySensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(mySensor_AllFramesReady);
try
{
this.mySensor.Start();
SensorChooserUI.Visibility = Visibility.Hidden;
}
catch (IOException)
{
this.mySensor = null;
}
}
}
示例7: myChooser_KinectChanged
void myChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
if (null != e.OldSensor)
{
//Alten Kinect deaktivieren
if (mySensor != null)
{
mySensor.Dispose();
}
}
if (null != e.NewSensor)
{
mySensor = e.NewSensor;
mySensor.AudioSource.Start();
mySensor.AudioSource.BeamAngleChanged += new EventHandler<BeamAngleChangedEventArgs>(AudioSource_BeamAngleChanged);
mySensor.AudioSource.SoundSourceAngleChanged += new EventHandler<SoundSourceAngleChangedEventArgs>(AudioSource_SoundSourceAngleChanged);
myBitmap = new WriteableBitmap(640,480, 96.0, 96.0, PixelFormats.Pbgra32, null);
image1.Source = myBitmap;
try
{
this.mySensor.Start();
SensorChooserUI.Visibility = Visibility.Hidden;
}
catch (IOException)
{
this.mySensor = null;
}
}
}
示例8: ChooserSensorChanged
void ChooserSensorChanged(object sender, KinectChangedEventArgs e)
{
var old = e.OldSensor;
StopKinect(old);
var newsensor = e.NewSensor;
if (newsensor == null)
{
return;
}
newsensor.SkeletonStream.Enable();
newsensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
newsensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
newsensor.AllFramesReady += SensorAllFramesReady;
try
{
newsensor.Start();
rtbMessages.Text = "Kinect Started" + "\r";
}
catch (System.IO.IOException)
{
rtbMessages.Text = "Kinect Not Started" + "\r";
//maybe another app is using Kinect
_chooser.TryResolveConflict();
}
}
示例9: OnKinectSensorChanged
public void OnKinectSensorChanged(object sender, KinectChangedEventArgs args)
{
if (null == args)
{
throw new ArgumentNullException("args");
}
if (null != args.OldSensor)
{
args.OldSensor.ColorFrameReady -= this.ColorImageReady;
}
if ((null != args.NewSensor) && (KinectStatus.Connected == args.NewSensor.Status))
{
if (ColorImageFormat.RawYuvResolution640x480Fps15 == args.NewSensor.ColorStream.Format)
{
throw new NotImplementedException("RawYuv conversion is not yet implemented.");
}
else
{
args.NewSensor.ColorFrameReady += this.ColorImageReady;
}
}
}
示例10: chooser_KinectChanged
/* This function is used to stop any previous instances of a running kinect sensor
* and starts a new reference under the name NewSensor.
* if a kinect sensor is connected to the PC then its depth stream is enabled
* to receive the depth data and the sensor is started. Exceptions may occur
* during the process of starting the sensor which is taken care of in the try-
* catch block.
*/
void chooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
KinectSensor oldSensor = (KinectSensor)e.OldSensor;
//Get reference to any old sensor
StopKinect(oldSensor);
//Stop the previous instances if any
KinectSensor newSensor = (KinectSensor)e.NewSensor;
//Get a reference to a new (latest) kinect sensor
if (newSensor == null)
{
//If no kinect sensor is connected simply return
return;
}
//If a kinect sensor is attached then ...
newSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
//Enable the depth stream to recerive depth data of the frame of resolution 320 x 240
newSensor.AllFramesReady += newSensor_AllFramesReady;
//Initializing the AllFramesReady event
try
{
newSensor.Start();
//Start the kinect sensor
}
catch (System.IO.IOException)
{
//Some other application is streaming from the same Kinect sensor
chooser.TryResolveConflict();
//Allow chooser to resolve conflict if any
}
}
示例11: myChooser_KinectChanged
void myChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
if (null != e.OldSensor)
{
//Alten Kinect deaktivieren
if (mySensor != null)
{
mySensor.Dispose();
}
}
if (null != e.NewSensor)
{
mySensor = e.NewSensor;
mySensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
myArray = new short[this.mySensor.DepthStream.FramePixelDataLength];
myBitmap = new WriteableBitmap(this.mySensor.DepthStream.FrameWidth, this.mySensor.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Gray16, null);
image1.Source = myBitmap;
mySensor.DepthFrameReady += this.SensorDepthFrameReady;
try
{
this.mySensor.Start();
//SensorChooserUI.Visibility = Visibility.Hidden;
}
catch (IOException)
{
this.mySensor = null;
}
}
}
示例12: myChooser_KinectChanged
void myChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
if (null != e.OldSensor)
{
//Alten Kinect deaktivieren
if (mySensor != null)
{
mySensor.Dispose();
}
}
if (null != e.NewSensor)
{
RecognizerInfo ri = GetKinectRecognizer();
mySensor = e.NewSensor;
if (null != ri)
{
myEngine = new SpeechRecognitionEngine(ri.Id);
using (var memoryStream = new MemoryStream(Encoding.ASCII.GetBytes(Properties.Resources.Grammar)))
{
var g = new Grammar(memoryStream);
myEngine.LoadGrammar(g);
}
myEngine.SpeechRecognized+=new EventHandler<SpeechRecognizedEventArgs>(myEngine_SpeechRecognized);
myEngine.SpeechRecognitionRejected+=new EventHandler<SpeechRecognitionRejectedEventArgs>(myEngine_SpeechRecognitionRejected);
myEngine.SetInputToAudioStream(mySensor.AudioSource.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
myEngine.RecognizeAsync(RecognizeMode.Multiple);
}
}
}
示例13: SensorChooserOnKinectChanged
private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs args)
{
bool error = false;
if (args.OldSensor != null)
{
try
{
args.OldSensor.DepthStream.Range = DepthRange.Default;
args.OldSensor.SkeletonStream.EnableTrackingInNearRange = false;
args.OldSensor.DepthStream.Disable();
args.OldSensor.SkeletonStream.Disable();
}
catch (InvalidOperationException)
{
// KinectSensor might enter an invalid state while enabling/disabling streams or stream features.
// E.g.: sensor might be abruptly unplugged.
error = true;
}
}
if (args.NewSensor != null)
{
try
{
args.NewSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
args.NewSensor.SkeletonStream.Enable();
try
{
args.NewSensor.DepthStream.Range = DepthRange.Near;
args.NewSensor.SkeletonStream.EnableTrackingInNearRange = true;
args.NewSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
}
catch (InvalidOperationException)
{
// Non Kinect for Windows devices do not support Near mode, so reset back to default mode.
args.NewSensor.DepthStream.Range = DepthRange.Default;
args.NewSensor.SkeletonStream.EnableTrackingInNearRange = false;
}
}
catch (InvalidOperationException)
{
error = true;
// KinectSensor might enter an invalid state while enabling/disabling streams or stream features.
// E.g.: sensor might be abruptly unplugged.
}
try
{
if (!error)
kinectRegion1.KinectSensor = args.NewSensor;
}
catch (Exception)
{
throw;
}
}
}
示例14: SensorChooserOnKinectChanged
private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs kinectChangedEventArgs)
{
Trace.WriteLine("kinect changed!");
KinectSensor oldSensor = kinectChangedEventArgs.OldSensor;
KinectSensor newSensor = kinectChangedEventArgs.NewSensor;
if (oldSensor != null)
{
Trace.WriteLine("old sensor");
oldSensor.AllFramesReady -= KinectSensorOnAllFramesReady;
oldSensor.ColorStream.Disable();
oldSensor.DepthStream.Disable();
oldSensor.DepthStream.Range = DepthRange.Default;
oldSensor.SkeletonStream.Disable();
oldSensor.SkeletonStream.EnableTrackingInNearRange = false;
oldSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default;
}
if (newSensor != null)
{
try
{
newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
newSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
try
{
// This will throw on non Kinect For Windows devices.
newSensor.DepthStream.Range = DepthRange.Near;
newSensor.SkeletonStream.EnableTrackingInNearRange = true;
}
catch (InvalidOperationException)
{
newSensor.DepthStream.Range = DepthRange.Default;
newSensor.SkeletonStream.EnableTrackingInNearRange = false;
}
newSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
Trace.WriteLine("before enable");
newSensor.SkeletonStream.Enable();
Trace.WriteLine("after enable");
newSensor.AllFramesReady += KinectSensorOnAllFramesReady;
}
catch (InvalidOperationException)
{
// This exception can be thrown when we are trying to
// enable streams on a device that has gone away. This
// can occur, say, in app shutdown scenarios when the sensor
// goes away between the time it changed status and the
// time we get the sensor changed notification.
//
// Behavior here is to just eat the exception and assume
// another notification will come along if a sensor
// comes back.
}
}
}
示例15: KinectSensor_KinectChanged
void KinectSensor_KinectChanged(object sender, KinectChangedEventArgs e)
{
bool error = true;
if (e.OldSensor == null)
{
try
{
e.OldSensor.DepthStream.Disable();
e.OldSensor.SkeletonStream.Disable();
}
catch (Exception)
{
error = true;
}
}
if (e.NewSensor == null)
return;
try
{
Kinect = e.NewSensor;
e.NewSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
e.NewSensor.SkeletonStream.Enable();
e.NewSensor.SkeletonFrameReady += KinectSensor_SkeletonFrameReady;
try
{
e.NewSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
e.NewSensor.DepthStream.Range = DepthRange.Near;
e.NewSensor.SkeletonStream.EnableTrackingInNearRange = true;
}
catch (InvalidOperationException)
{
e.NewSensor.DepthStream.Range = DepthRange.Default;
e.NewSensor.SkeletonStream.EnableTrackingInNearRange = false;
}
}
catch (InvalidOperationException)
{
error = true;
}
ZonaCursor.KinectSensor = e.NewSensor;
KinectRegion.AddHandPointerGripHandler(this.ZonaCursor, this.OnHandGripHandler);
KinectRegion.AddHandPointerGripReleaseHandler(this.ZonaCursor, this.OngRripReleaseHandler);
KinectRegion.AddHandPointerMoveHandler(this.ZonaCursor, this.OnMoveHandler);
KinectRegion.AddHandPointerPressHandler(this.ZonaCursor, this.OnPressHandler);
KinectRegion.AddHandPointerPressReleaseHandler(this.ZonaCursor, this.OnPressRelaaseHandler);
}