使用 Kinect 进行线程化

发布于 2024-11-14 13:35:29 字数 300 浏览 3 评论 0原文

我正在编写一个使用 Kinect 的 C# 应用程序,我当前正在获取输出并将其写入着色器资源并将其渲染为纹理,我的问题是 Kinect(显然)仅以 30fps 运行,因此它受到限制我的表现很糟糕。

克服这个问题的最佳方法是什么,是多线程吗? 是否有某种设计模式可以帮助解决此类问题? 据我所知,我可能想让 kinect 在线程上处理数据,然后在进程完成后访问它,但我不确定从哪里开始以安全的方式。

感谢您提供的任何建议。

我目前使用 OpenNI 作为 kinect 驱动程序/api,使用 SlimDX 作为 directX 渲染端。

I am writing a C# application that is using the Kinect, i am taking the output currently and writing it to a Shader Resource and rendering it as a texture, my issue is that the Kinect (apparently) only runs at 30fps, so it is throttling my performance badly.

What is the best way to overcome this, is it multithreading?
Is there some sort of design pattern that would help with this type of issue?
As far as i can tell i may want to have the kinect processing the data on a thread, and then get access to it when the process is finished, but i'm not sure where to start with that in a safe manner.

Thanks for any advice you can offer.

I am currently using OpenNI for the kinect drivers/api, and SlimDX for the directX side of rendering.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鱼忆七猫命九 2024-11-21 13:35:29

我以前没有使用过 Kinect,并且您没有指定您正在使用哪些驱动程序/包装器,但我怀疑这可能并不重要。

您可能需要执行以下操作:

  1. 将 Kinect 的“更新”周期分离到它自己的线程上。这将使您的应用程序逻辑可以自由地尽可能快地运行,而无需停止等待 kinect 硬件的更新。
  2. 当 kinect 填充新数据时,您需要在每次传递时“锁定”图像/深度数据。
  3. 如果 Kinect 填充数据的过程需要两长时间,您可以尝试缓冲图像和深度数据(如果驱动程序尚未这样做)。这意味着只需在内存中保留两份副本,并在写入另一份时读取一份。

对于有关 C# 线程的优秀教程,我始终推荐 Albahari's Threading in C#。我还建议,如果您想要有关如何加快应用程序速度的更多具体信息,您可能应该编辑您的问题并添加有关您现在如何构建它以及您正在使用什么包装器/驱动程序等的详细信息。

I have not worked with the Kinect before and you didn't specify which drivers/wrapper you are using, but I suspect that it probably won't matter.

What you will probably need to do is the following:

  1. Seperate the "Update" cycle for the Kinect onto it's own thread. That will leave your application logic free to run as fast as it can without being stopped waiting for an update from the kinect hardware.
  2. You will need to "lock" the image/depth data on each pass while the kinect fills in the new data.
  3. If the process of the Kinect filling in the data is taking two long you could try buffering the image and depth data if the drivers don't already do that. This means just keeping two copies in memory and read one while the other is being written.

For excellent tutorials on threading in c#, I always recommend Albahari's Threading in C#. I would also recommend if you want more specific information on what you can do to speed up your application, you should probably edit your question and add details about specifically how you have it structured now and what wrapper/driver's you are using, etc.

月棠 2024-11-21 13:35:29

任何需要高性能的 Kinect 开发都应该使用池模型而不是事件模型。作为补充,您最好的选择是打开一个线程并执行池操作。
您也可以将线程与事件模型一起使用,以进行长时间操作而不冻结用户界面。

您可以看到: http://msdn.microsoft.com/en-us/library /hh973076

Any development with Kinect that requires high perfomance you should use the pooling model instead event model. And complementary to this, your best option is open a thread and do the pooling operations.
You can use too threads with event model , to make long time operations and not freeze the user interface.

And you can see this : http://msdn.microsoft.com/en-us/library/hh973076

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文