例程讲解05-Snapshot->time_lapse_photos延时拍照
import pyb, machine, sensor, image, pyb, os
rtc = pyb.RTC()
newFile = False
try:
os.stat('time.txt')
except OSError:
rtc.datetime((2018, 3, 9, 5, 13, 0, 0, 0))
newFile = True
dateTime = rtc.datetime()
year = str(dateTime[0])
month = '%02d' % dateTime[1]
day = '%02d' % dateTime[2]
hour = '%02d' % dateTime[4]
minute = '%02d' % dateTime[5]
second = '%02d' % dateTime[6]
subSecond = str(dateTime[7])
newName='I'+year+month+day+hour+minute+second
rtc.wakeup(10000)
BLUE_LED_PIN = 3
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 1000)
pyb.LED(BLUE_LED_PIN).on()
if(newFile):
with open('time.txt', 'a') as timeFile:
timeFile.write('Date and time format: year, month, day, hours, minutes, seconds, subseconds' + '\n')
timeFile.write(newName + ',' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + second + ',' + subSecond + '\n')
else:
with open('time.txt', 'a') as timeFile:
timeFile.write(newName + ',' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + second + ',' + subSecond + '\n')
if not "images" in os.listdir(): os.mkdir("images")
img = sensor.snapshot()
img.save('images/' + newName, quality=90)
pyb.LED(BLUE_LED_PIN).off()
machine.deepsleep()
星瞳科技OpenMV官方中文文档函数讲解: