Example: 01-Camera/01-Video-Recording/imageio_write.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 图像写入器示例
#
# 注意:此示例需要SD卡。
#
# 此示例展示了如何使用图像写入器对象录制原始视频文件
# 以便稍后使用图像读取器对象进行分析。

import sensor
import image
import time
import machine

record_time = 10000  # 10秒的毫秒数

sensor.reset()  # 重置并初始化传感器。
sensor.set_pixformat(sensor.RGB565)  # 将像素格式设置为RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)  # 将帧大小设置为QQVGA(160x120)
sensor.skip_frames(time=2000)  # 等待设置生效。
clock = time.clock()  # 创建一个时钟对象来跟踪FPS。

led = machine.LED("LED_RED")
stream = image.ImageIO("/stream.bin", "w")

# 红色LED亮表示我们正在捕获帧。
led.on()

start = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), start) < record_time:
    clock.tick()
    img = sensor.snapshot()
    # 如果你愿意,可以在此处修改图像...
    stream.write(img)
    print(clock.fps())

stream.close()
led.off()

raise (Exception("Please reset the camera to see the new file."))

results matching ""

    No results matching ""