例程讲解-05-snapshot保存图片

本例程为 05-Snapshot-snapshot.py
本例程的目标是使用save函数保存摄像头图片。
注意:因为openmv内存较小,需要外接SD卡才能保存图片哦。

# Snapshot Example
#
# Note: You will need an SD card to run this example.
#
# You can use your OpenMV Cam to save image files.

import sensor, image, pyb

RED_LED_PIN = 1
BLUE_LED_PIN = 3

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames(10) # Let new settings take affect.

#红灯亮
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(30) # Give the user time to get ready.

#红灯灭,蓝灯亮
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()

#保存截取到的图片到SD卡
print("You're on camera!")
sensor.snapshot().save("example.jpg") # or "example.bmp" (or others)

pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved image.")

注意:保存的图片需要重启openmv后才能在SD卡中看到哦。

星瞳科技OpenMV官方中文文档函数讲解:

results matching ""

    No results matching ""