I have been debugging a lot of errors while converting a code that uses Kinect V1 classes, into Kinect V2 classes. As this stated, there are some changes.
So far I have managed to debug some classes like Skeleton into Body, but there are some missing parts with the Skeleon and AllFramesReadyEventsArgs:
private void KinectAllFramesReady(object sender, AllFramesReadyEventArgs e)
{
// Have we already been "shut down" by the user of this viewer,
// or has the SkeletonStream been disabled since this event was posted?
if ((this.Kinect == null) || !((KinectSensor)sender).SkeletonStream.IsEnabled)// Error with Skeleton Stream
{
return;
}
bool haveSkeletonData = false;
using (BodyFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null)
{
if (this.skeletonCanvases == null)
{
this.CreateListOfSkeletonCanvases();
}
if ((this.skeletonData == null) || (this.skeletonData.Length != skeletonFrame.SkeletonArrayLength))// Error with SkeletonArrayLength
{
this.skeletonData = new Body[ skeletonFrame.SkeletonArrayLength];
}
skeletonFrame.CopySkeletonDataTo(this.skeletonData);// Error with Skeleton Frrame
haveSkeletonData = true;
}
}
I still have the Frame reader, what is the Kinect V2 alternative for it? I have the following code which is for Kinect V1:
protected override void OnKinectChanged(KinectSensor oldKinectSensor, KinectSensor newKinectSensor)
{
if (oldKinectSensor != null)
{
oldKinectSensor.AllFramesReady -= this.KinectAllFramesReady;
this.HideAllSkeletons();
}
if (newKinectSensor != null && newKinectSensor.Status == KinectStatus.Connected)
{
newKinectSensor.AllFramesReady += this.KinectAllFramesReady;
}
}
要替换OnKinectChanged
事件,可以在KinectSensor
对象上使用IsAvailableChanged
事件。
主要区别在于Kinect V1中的Skeleton类和kinect V2中的Body类之间,但是要使用SDK2开发kinectV2,则必须使用MultiSourceFrameReader类
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.