logo

sensor.snapshot() 若是拍照不成功,或者摄像头出故障,返回什么值?

2018-06-23 11:29
1
sunnyjack236
97316ef4-1810-4124-a3d1-cac855052903.png
# 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.")
I
网红小智智 星瞳科技

不会不成功

如果故障,根本不能启动,上电有自检

2018-06-25 08:45
1
sunnyjack236

运行的时候有没有状态自检?

2018-06-25 17:14
I
网红小智智 星瞳科技

没有

不过。。。为什么要有?sensor又不会坏。

2018-06-26 09:50
1
sunnyjack236

@kidswong999 有个项目,需要对摄像头在使用时自检,如果不能正常拍照了,需要及时通知维修,避免用户使用时体验不佳;

2018-06-26 11:34
I
网红小智智 星瞳科技

并不会出现这种情况:smiling_face_with_open_mouth_cold_sweat: