emboss_snapshot.py
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 浮雕效果快照示例
#
# 注意:运行此示例需要一张SD卡。
# 您可以使用OpenMV摄像头保存修改后的图像文件。
import csi
import time
import machine
csi0 = csi.CSI()
csi0.reset() # 重置并初始化传感器。
csi0.pixformat(csi.RGB565) # 将像素格式设置为RGB565 (or GRAYSCALE)
csi0.framesize(csi.QVGA) # 将帧大小设置为QVGA (320x240)
csi0.snapshot(time=2000) # 等待设置生效。
led = machine.LED("LED_BLUE")
start = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), start) < 3000:
csi0.snapshot()
led.toggle()
led.off()
img = csi0.snapshot()
img.morph(1, [+2, +1, +0, +1, +1, -1, +0, -1, -2]) # 对图像进行浮雕处理。
img.save("example.jpg") # 或“example.bmp”(或其他文件)
raise (Exception("Please reset the camera to see the new file."))