Screenshots
In case you want to track what is happening in your desktop, you can use landingai.image_source.Screenshot
to capture screenshots of your desktop.
In the example below, we capture the first 20 frames, and save them to a video file.
from landingai.pipeline.image_source import Screenshot
from landingai.pipeline.frameset import FrameSet
import time
frameset = FrameSet() # (1)!
with Screenshot() as screenshots: # (2)!
for i, frame in enumerate(screenshots): # (3)!
if i >= 20:
break
frame.resize(width=512) # (4)!
frameset.append(frame) # (5)!
time.sleep(0.5) # (6)!
frameset.save_video("/tmp/resized-video.mp4") # (7)!
- Creates an empty
FrameSet
, where we will store the modified frames - Build the screenshot capture object
- Iterate over each frame captured from the desktop
- Resize the frame to
width=512px
(keeping aspect ratio) - Append the resized frame to the
FrameSet
- Wait for 0.5 seconds before capturing the next frame
- Save the resized video to
/tmp/resized-video.mp4
.