多个并发帧读取器 [英] Multiple concurrent Frame Readers

查看:75
本文介绍了多个并发帧读取器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在使用Kinect V2 C ++ SDK,我只是想知道解决这个问题的最佳方法是什么。假设我有2个C1和C2类。我将相同的IKinectSensor实例传递给它们,如下所示:

I am using the Kinect V2 C++ SDK, and I am just wondering what is the best way to go about this problem. Suppose I have 2 classes C1 and C2. I am passing the same instance of IKinectSensor to them, such as follows:

IKinectSensor *kSensor;
GetDefaultKinectSensor(&kSensor);
C1 instance1(kSensor);
C2 instance2(kSensor);

我们还假设这两个类将处理来自同一传感器的IBodyFrame对象,不一定以相同的速率处理。

And let's also suppose that these two classes will process IBodyFrame objects from the same sensor, not necessarily at the same rate.

问题是我将同时处理帧,这涉及获取帧并释放它们。 IKinectSensor是否支持并发帧读取器?

The thing is that I will be processing frames concurrently, and this involves acquiring frames, and releasing them. Does IKinectSensor supports concurrent frame readers?

推荐答案

根据我使用C#和Unity的经验您可以根据需要同时运行多个并发帧读取器,因此没有理由不能在C ++中使用。

In my experience working with C# and Unity you can make as many concurrent frame readers as you like running at the same time, so there is no reason you shouldn't be able to in C++.

但是有一些重要的事情要做记住。如果您只是简单地读取相同的源帧两次,那将浪费资源。一般来说,你应该尝试找到一种方法,让一个类读取框架,并从同一个源读取你的
程序的其余部分。

However there are some important things to keep in mind. If you are simply reading the same source frame twice then that would be a waste of resources. Generally you should try and find a way to have one class that reads the frame and have the rest of your program read from that same source.

但有时候你我需要使用多个阅读器(比如音频)和Kinect V2 SDK就是为此而开发的。

But there are times when you need to use multiple reader (like with Audio) and the Kinect V2 SDK was developed with that in mind.

如果一个类的处理"锁定",也会出现问题。如果处理延长一段时间,则另一类可能会错过读取帧的机会。但是你可以使用多线程来避免这种情况,这是使用C ++获得
优势的地方。

There can be also issues where if the processing of one class "locks up" the processing for an extended period of time the other class may miss the chance to read a frame. But you could use multithreading to avoid that, which is where you have an advantage by using C++.


这篇关于多个并发帧读取器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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