Realsense Difference between `poll_for_frames` and `wait_for_frames` modes

def wait_for_frames(self, timeout_ms=5000): # real signature unknown; restored from __doc__
    """
    wait_for_frames(self: pyrealsense2.pyrealsense2.pipeline, timeout_ms: int=5000) -> pyrealsense2.pyrealsense2.composite_frame
    
    Wait until a new set of frames becomes available.
    The frames set includes time-synchronized frames of each enabled stream in the pipeline.
    In case of different frame rates of the streams, the frames set include a matching frame of the slow stream, which may have been included in previous frames set.
    The method blocks the calling thread, and fetches the latest unread frames set.
    Device frames, which were produced while the function wasn't called, are dropped. To avoid frame drops, this method should be called as fast as the device frame rate.
    The application can maintain the frames handles to defer processing. However, if the application maintains too long history, the device may lack memory resources to produce new frames, and the following call to this method shall fail to retrieve new frames, until resources become available.
    等到新的一组帧集可用为止。
     帧集包括管道中每个已启用流的时间同步帧。
     在流的帧率不同的情况下,帧集合包括慢流的匹配帧,该慢帧的匹配帧可能已经包括在先前的帧集合中。
     该方法阻止调用线程,并获取最新的未读帧集。
     未调用函数时生成的设备帧集将被丢弃。 为避免丢帧,应以与设备帧速率一样快的速度调用此方法。
     应用程序可以保持帧集句柄以延迟处理。 但是,如果应用程序保持的历史记录过长,则设备可能会缺少产生新帧集的内存资源,并且对该方法的后续调用将无法检索新帧集,直到资源可用为止。
    """
    pass
def poll_for_frames(self): # real signature unknown; restored from __doc__
    """
    poll_for_frames(self: pyrealsense2.pyrealsense2.pipeline) -> pyrealsense2.pyrealsense2.composite_frame
    
    Check if a new set of frames is available and retrieve the latest undelivered set.
    The frames set includes time-synchronized frames of each enabled stream in the pipeline.
    The method returns without blocking the calling thread, with status of new frames available or not.
    If available, it fetches the latest frames set.
    Device frames, which were produced while the function wasn't called, are dropped.
    To avoid frame drops, this method should be called as fast as the device frame rate.
    The application can maintain the frames handles to defer processing. However, if the application maintains too long history, the device may lack memory resources to produce new frames, and the following calls to this method shall return no new frames, until resources become available.
    检查是否有新的帧集对并取回最新的未交付的帧集。
     帧集对包括管道中每个已启用流的时间同步帧。
     该方法返回时不会阻塞调用线程,无论是否有新帧集的状态。
     如果可用,它将获取最新的帧集。
     未调用函数时生成的设备帧集将被丢弃。
     为避免丢帧,应以与设备帧速率一样快的速度调用此方法。
     应用程序可以维持帧句柄以延迟处理。 但是,如果应用程序维持的历史记录过长,则设备可能会缺少产生新帧的内存资源,并且对此方法的以下调用将不返回任何新帧,直到资源可用为止。
    """
    pass

    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方法。请注意,frame而不是frames。它们具有相同的语义。
通常,如果您要实现单一生产者/单一消费者模型wait_for_frame/s是最好的选择。如果在处理完成时有可用的帧,它将立即返回,否则,它将阻塞并释放CPU,直到下一帧可用为止。如果您有多个生产者(多摄像机设置),则此模型会出现问题(因为API中没有诸如“等待多个对象”之类的东西)。然后,我们建议poll_for_frames像multicam示例中那样切换到。
如果确实使用过poll_for_frames,则应该手动决定何时使CPU进入睡眠状态以及持续多长时间,否则最终可能会使用100%的单核。
    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自然地与单个pipeline/ frame_queue对象一起工作。如果有多个poll_for_frames队列,则最好使用它来确保在等待另一个队列时不会丢失一个队列中的帧。

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值