Get color Image not in the frame ready event

五迷三道 提交于 2019-12-12 05:38:14

问题


I have some problem with the kinect. when I try to get color Image from the event: Sensor_AllFramesReady everything is ok. example:

using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) {
    //save image for print
    if (colorFrame == null) {
        return;
    }
    byte[] colorData = new byte[colorFrame.PixelDataLength];
    colorFrame.CopyPixelDataTo(colorData);
    int averagedImage = colorFrame.Width * PixelFormats.Bgr32.BitsPerPixel / 8;
    int stride = colorFrame.Width * 4;
    pictureBitmap = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, colorData, stride);
}

But when I try to do the same code outside the event with

using (ColorImageFrame Image = Sensor.ColorStream.OpenNextFrame(10)) {

}

I get error : "This API cannot be called when an event listener has been set"

I try to remove the event before calling this function but this don't change anything


回答1:


You have to choice, event handler or poll method. You can use the event and save the last frame to use it some else place.



来源:https://stackoverflow.com/questions/12210931/get-color-image-not-in-the-frame-ready-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!