Routine description 06-Video-Recording->imageio_memory saves and reads video

# Image Memory Stream I/O Example
#
# 本例程演示如何使用ImageIO流在内存中记录帧并进行回放。
# 注意:虽然这在任何板上都可以使用,但是板上应该有一个SDRAM可以使用。
import sensor, image, time

# 要预分配和记录的帧数
N_FRAMES = 500

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)

# 该帧大小必须与传递给ImageIO的图像大小匹配
sensor.set_windowing((120, 120))
sensor.skip_frames(time = 2000)

clock = time.clock()

# 写入内存流
stream = image.ImageIO((120, 120, 2), N_FRAMES)

for i in range(0, N_FRAMES):
    clock.tick()
    stream.write(sensor.snapshot())
    print(clock.fps())

while (True):
    # 回放流并以100FPS播放
    stream.seek(0)
    for i in range(0, N_FRAMES):
        img = stream.read(copy_to_fb=True)
        # 在此处对图像执行机器视觉算法
        time.sleep_ms(10)

results matching ""

    No results matching ""