Intel Realsense D4XX Difference between `poll_for_frames` and `wait_for_frames` modes? 函数区别

Intel Realsense D4XX Difference between `poll_for_frames` and `wait_for_frames` modes? 函数区别

Wait for frames will block until frame is available. Poll for frames will always return instantly. There is also try_wait_for_frames that will block but not throw on timeout but rather return false. frame_queue has similar wait_for_frame / poll_for_frame / try_wait_for_frame methods. Note frame instead of frames. These share the same semantics.
Usually, if you are implementing single producer / single consumer model wait_for_frame/s is best choice. If frame is available by the time your processing finish, it will return immediately, if not, it will block and free up CPU until next frame is available. If you have multiple producers (multi-camera setup) this model becomes problematic (since we don’t have something like “wait for multiple objects” in the API). Then we recommend to switch to poll_for_frames, like in the multicam example.
If you do use poll_for_frames you should manually decide when to put the CPU to sleep and for how long, otherwise you can end up using 100% of a single core.

等待帧将阻塞,直到帧是可用的。帧轮询将始终立即返回。还有try_wait_for_frames将阻止但不会引发超时,而是返回false。 frame_queue具有类似的wait_for_frame / poll_for_frame / try_wait_for_frame方法。注意帧而不是帧集。它们具有相同的语义。
通常,如果要实现单一生产者/单一消费者模型,wait_for_frame / s是最佳选择。如果在处理完成时有可用的帧,它将立即返回,否则,它将阻塞并释放CPU,直到下一帧可用为止。如果你有多个生产商(多摄像机设置)这种模式成为问题(因为我们没有类似的API中“等多个对象”)。然后,我们建议切换到poll_for_frames,就像在多机位示例中一样。
如果你使用poll_for_frames您应该手动决定何时把CPU睡多长时间,否则,你可以使用单核心的100%结束。

Intel Realsense D4XX Difference between `poll_for_frames` and `wait_for_frames` modes? 函数区别

wait_for_frame/s works naturally with single pipeline / frame_queue
object. If you have multiple, better use poll_for_frames to ensure you
are not missing frames from one queue when waiting on another.

wait_for_frame / s自然可以与单个管道/ frame_queue对象一起使用。 如果有多个队列,最好使用poll_for_frames确保在等待另一个队列时不会丢失一个队列中的帧。

参考文章1:Difference between poll_for_frames and wait_for_frames modes?