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

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# GIF视频录制示例
#
# 注意:运行此示例需要一张SD卡。
#
# 您可以使用OpenMV Cam录制gif文件。您可以向
# 录制器对象提供RGB565帧或灰度帧。使用照片编辑软件
# 如GIMP来压缩和优化Gif,然后再上传到网络。

import sensor
import time
import gif
import machine

sensor.reset()  # 重置并初始化传感器。
sensor.set_pixformat(sensor.RGB565)  # 将像素格式设置为RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)  # 将帧大小设置为QQVGA(160x120)
sensor.skip_frames(time=2000)  # 等待设置生效。

led = machine.LED("LED_RED")

led.on()
g = gif.Gif("example.gif", loop=True)

clock = time.clock()  # 创建一个时钟对象来跟踪FPS。
for i in range(100):
    clock.tick()
    # clock.avg()返回帧之间的毫秒数 - gif延迟以
    g.add_frame(sensor.snapshot(), delay=int(clock.avg() / 10))  # 百分之一秒为单位。
    print(clock.fps())

g.close()
led.off()

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

results matching ""

    No results matching ""