Open zzf971129 opened 1 month ago
README 中 Screenshot 小节已经提到了
This is the default and the only supported format (for now). It is worth noting that
.grab
will returnNone
if there is no new frame since the last time you called.grab
. Usually it means there's nothing new to render since last time (E.g. You are idling).
也可以参考grab
的实现
class DXCamera:
def _grab(self, region: Tuple[int, int, int, int]):
if self._duplicator.update_frame():
if not self._duplicator.updated:
return None
self._device.im_context.CopyResource(
self._stagesurf.texture, self._duplicator.texture
)
self._duplicator.release_frame()
rect = self._stagesurf.map()
frame = self._processor.process(
rect, self.width, self.height, region, self.rotation_angle
)
self._stagesurf.unmap()
return frame
else:
self._on_output_change()
return None
所以,如果你的场景需要每次截图都有内容返回,那么当grab
返回None
的时候,你可以将上一帧返回。
如果不需要的话,那就检查一下返回值,若为None
跳过即可。
Hello,
I've encountered an issue with the dxcam library where calling camera.grab() consecutively causes the second call to return None. Here’s a minimal example that reproduces the issue:
camera = dxcam.create() camera.grab() # First call works fine camera.grab() # Second call returns None It seems that after the first call to grab(), the second call immediately returns None and fails to capture the frame. This issue prevents me from taking multiple quick successive screenshots.
Could you please advise on how to resolve this or if there is a workaround available?
Thank you!