在另一个线程中初始化传感器? [英] Initializing sensor in another thread?

查看:68
本文介绍了在另一个线程中初始化传感器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从主线程调用NuiSetDeviceStatusCallback()。但是我想在另一个线程中初始化Kinect传感器,以避免在初始化时使主线程停滞。

I call NuiSetDeviceStatusCallback() from my main thread. However I would like to do the initialization of the Kinect sensor in another thread to avoid stalling my main thread while it initializes.

我发现这非常不稳定。我在NuiShutdown()中发生随机挂起,或者StreamOpen()调用失败(但是如果我马上再次调用它,它将第二次工作)。如果我尝试启用近深度模式,所有流在启动
后失败(我停止获取新数据)

I've found this to be very unstable. I get random hangs occurring in NuiShutdown(), or StreamOpen() calls failing (but then if I call it again right away, it'll work the 2nd time). If I attempt to enable Near Depth Mode, all of the streams fail after starting up (I stop getting new data)

没有竞争条件正在发生,主要线程不是任何Kinect对象,直到我的初始化任务完成。

There is no race condition happening, with the main thread not though any of the Kinect objects until my initialization task has finished.

我需要在NuiSetDeviceStatusCallback()中发生某种线程设置吗?意识到?这只是不支持吗?

Is there some sort of per thread setup occurring in NuiSetDeviceStatusCallback() that I need to be aware of? Is this just not supported?

谢谢

推荐答案

只要您在同一个线程上处理传感器和回调/事件,那么它就不是问题。 您能提供代码来演示您的设置吗?如何从这个"Kinect"中向您的UI线程发送更新?线程?

As long as you are handling the sensor and your callbacks/events on that same thread then it shouldn't be an issue. Can you provide code to demonstrate your setup? How are you sending updates to your UI thread from this "Kinect" thread?


这篇关于在另一个线程中初始化传感器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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