
# 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(time = 2000) # Let new settings take affect.
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(time = 2000) # Give the user time to get ready.
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
print("You're on camera!")
img = sensor.snapshot()
print("img=",img) #拍照成功返回img= {"w":320, "h":240, "type"="rgb565", #"size":153600},如果拍照不成功,或摄像头出故障,返回什么值,当摄像头出问题了我们怎么能知道?
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.")不会不成功
如果故障,根本不能启动,上电有自检
运行的时候有没有状态自检?
没有
不过。。。为什么要有?sensor又不会坏。
@kidswong999 有个项目,需要对摄像头在使用时自检,如果不能正常拍照了,需要及时通知维修,避免用户使用时体验不佳;
并不会出现这种情况:smiling_face_with_open_mouth_cold_sweat: