我正在Windows7上使用Kynect+Python(不使用Micosoft visualstudio)。在
有人知道如何在不使用事件循环的情况下从Kinect获取帧吗?在
我指的是PyKinect/nui/init.py的这种方法
def get_next_frame(self, milliseconds_to_wait = 0):
# TODO: Allow user to provide a NUI_IMAGE_FRAME ?
return self.runtime._nui.NuiImageStreamGetNextFrame(self._stream, milliseconds_to_wait)
上面的功能正是我需要的,它还没有实现。我需要它来按需获取帧(不使用事件循环)。在
我该怎么做?在
我正在使用以下环境和版本:
您无法“按需”获取RGB、深度或骨架帧。Kinect数据由事件提供,因此您必须使用它们来获取数据。在
要解决这个基于事件的系统,您唯一能做的就是将数据保存在一个全局变量中,然后在需要时读取该变量。在
例如,假设您将一个名为
depth_frame_ready
的函数与深度数据相关的事件相关联:您可以编写
^{pr2}$depth_frame_ready
函数来保存全局变量上的数据(比如depth_data
)。您还需要一个同步机制来读写该变量(一个简单的Lock
来避免同时读写):现在,如果需要使用深度数据,可以随时引用全局变量。在
记住使用
depth_lock
来同步访问,就像在update_depth_data()
函数中所做的那样。在相关问题 更多 >
编程相关推荐