获取彩色图像不在框架就绪事件中 [英] Get color Image not in the frame ready event

查看:77
本文介绍了获取彩色图像不在框架就绪事件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Kinect有问题. 当我尝试从事件中获取彩色图像时:Sensor_AllFramesReady一切正常. 例如:

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);
}

但是当我尝试使用

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

}

我收到错误消息: 设置了事件侦听器后,无法调用此API"

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

推荐答案

您必须选择事件处理程序或轮询方法.您可以使用事件并保存最后一帧以在其他地方使用它.

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.

这篇关于获取彩色图像不在框架就绪事件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆