When I attempt to run my skeletal tracking code to test out the following line of code I have added in, it crashes with an error.
void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
if (closing)
{
return;
}
//Get a skeleton
Skeleton first = GetFirstSkeleton(e);
if (first == null)
{
return;
}
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
//if (skeletonFrame == null)
//{
// return;
//}
this.recordStream = new MemoryStream(100);
KinectRecorder Recorder = new KinectRecorder(KinectRecordOptions.Skeletons, recordStream);
if (skeletonFrame != null)
{
this.Recorder.Record(skeletonFrame);
}
//StartRecord
// Skeleton[] skeletonData = this.Recorder.Record(skeletonFrame);
}
// some more stuff
}
I am calling the Record function available in the Kinect Toolbox.
The error is: System.NullReferenceException was unhandled ....... Message=Object reference not set to an instance of an object. ..... Source=SkeletalTracking
Update: If I have moved the initialization into the same function as the call of the recorder.