Skip to content

Instantly share code, notes, and snippets.

@non117
Created December 13, 2014 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non117/e7073853191278fc1de6 to your computer and use it in GitHub Desktop.
Save non117/e7073853191278fc1de6 to your computer and use it in GitHub Desktop.
private void FrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
{
bool multiSourceFrameProcessed = false;
bool colorFrameProcessed = false;
bool depthFrameProcessed = false;
bool bodyIndexFrameProcessed = false;
MultiSourceFrame multiSourceFrame = e.FrameReference.AcquireFrame();
if (multiSourceFrame != null)
{
using (DepthFrame depthFrame = multiSourceFrame.DepthFrameReference.AcquireFrame())
using (ColorFrame colorFrame = multiSourceFrame.ColorFrameReference.AcquireFrame())
using (BodyIndexFrame bodyIndexFrame = multiSourceFrame.BodyIndexFrameReference.AcquireFrame())
{
if (depthFrame != null)
{
FrameDescription depthFrameDescription = depthFrame.FrameDescription;
// depthBufferはushort[]
depthFrame.CopyFrameDataToArray(this.depthBuffer);
depthFrameProcessed = true;
}
if (bodyIndexFrame != null)
{
FrameDescription bodyFrameDescription = bodyIndexFrame.FrameDescription;
// bodyIndexBufferはbyte[]
bodyIndexFrame.CopyFrameDataToArray(this.bodyIndexBuffer);
bodyIndexFrameProcessed = true;
}
if (colorFrame != null)
{
FrameDescription colorFrameDescription = colorFrame.FrameDescription;
// colorPixelsはbyte[]
colorFrame.CopyConvertedFrameDataToArray(this.colorPixels, ColorImageFormat.Bgra);
colorFrameProcessed = true;
}
multiSourceFrameProcessed = true;
}
}
if (multiSourceFrameProcessed && depthFrameProcessed && colorFrameProcessed && bodyIndexFrameProcessed)
{
// do something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment