一、连续拍照
连续拍照代码如下,可在range中修改参数来改变拍照的数量和命名范围
import sensor, image, time,lcd
sensor.reset()
sensor.set_vflip(1)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 5000)
for i in range(110,500):
filename = str(i) + '.jpg'
print(i)
img = sensor.snapshot()
img.save(filename)
img = sensor.snapshot()
lcd.display(img)
lcd.display(img.draw_string(0,0,"end"))
二、裁剪图像,设ROI
import image,lcd,sensor
lcd.init(freq=15000000)
sensor.reset() # Reset and initialize the sensor. It will
# run automatically, call sensor.run(0) to stop
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_vflip(1)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
while(1):
img = sensor.snapshot()
ROI=(75,75,204,166)
img = img.crop(ROI)
lcd.display(img)
img.save("1.jpg")
图1为裁剪后保存在TF卡中的"1.jpg"
图2是裁剪后传回到IDE的图像,可以看到它并不是很正常,不过不影响正常使用,no worries
如图3,测试了一下,没什么问题 ,可以保存裁剪后的图像。要注意的是,range参数给0-100,得到的照片是0-99