在Kinect avateering c#sample的Kinect选择器类中,我总是遇到这个错误“对象引用没有设置为对象的实例。”任何想法为什么?我想知道它是否真的是我的kinect
的问题public KinectChooser(Game game, ColorImageFormat colorFormat, DepthImageFormat depthFormat)
: base(game)
{
this.colorImageFormat = colorFormat;
this.depthImageFormat = depthFormat;
this.nearMode = false;
this.seatedMode = false;
KinectSensor.KinectSensors.StatusChanged += this.KinectSensors_StatusChanged;
this.DiscoverSensor();
this.statusMap.Add(KinectStatus.Undefined, "Required");
this.statusMap.Add(KinectStatus.Connected, string.Empty);
this.statusMap.Add(KinectStatus.DeviceNotGenuine, "Device Not Genuine");
this.statusMap.Add(KinectStatus.DeviceNotSupported, "Device Not Supported");
this.statusMap.Add(KinectStatus.Disconnected, "Required");
this.statusMap.Add(KinectStatus.Error, "Error");
this.statusMap.Add(KinectStatus.Initializing, "Initializing...");
this.statusMap.Add(KinectStatus.InsufficientBandwidth, "Insufficient Bandwidth");
this.statusMap.Add(KinectStatus.NotPowered, "Not Powered");
this.statusMap.Add(KinectStatus.NotReady, "Not Ready");
}
/// <summary>
/// Gets the SpriteBatch from the services.
/// </summary>
public SpriteBatch SharedSpriteBatch
{
get
{
return (SpriteBatch)this.Game.Services.GetService(typeof(SpriteBatch));
}
}
/// <summary>
/// Gets the selected KinectSensor.
/// </summary>
public KinectSensor Sensor { get; private set; }
/// <summary>
/// Gets the last known status of the KinectSensor.
/// </summary>
public KinectStatus LastStatus { get; private set; }
/// <summary>
/// Gets or sets a value indicating whether near mode is enabled.
/// Near mode enables depth between 0.4 to 3m, default is between 0.8 to 4m.
/// </summary>
private void DiscoverSensor()
{
// Grab any available sensor
this.Sensor = KinectSensor.KinectSensors.FirstOrDefault();
if (null != this.Sensor)
{
this.LastStatus = this.Sensor.Status;
// If this sensor is connected, then enable it
if (this.LastStatus == KinectStatus.Connected)
{
// For many applications we would enable the
// automatic joint smoothing, however, in this
// Avateering sample, we perform skeleton joint
// position corrections, so we will manually
// filter when these are complete.
// Typical smoothing parameters for the joints:
// var parameters = new TransformSmoothParameters
// {
// Smoothing = 0.25f,
// Correction = 0.25f,
// Prediction = 0.75f,
// JitterRadius = 0.1f,
// MaxDeviationRadius = 0.04f
// };
this.Sensor.SkeletonStream.Enable();
this.Sensor.ColorStream.Enable(this.colorImageFormat);
this.Sensor.DepthStream.Enable(this.depthImageFormat);
this.Sensor.SkeletonStream.EnableTrackingInNearRange = true; // Enable skeleton tracking in near mode
try
{
this.Sensor.Start();
}
catch (IOException)
{
// sensor is in use by another application
// will treat as disconnected for display purposes
this.Sensor = null;
}
}
}
else
{
this.LastStatus = KinectStatus.Disconnected;
}
}