Created
December 13, 2014 08:24
-
-
Save non117/e7073853191278fc1de6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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