Hi, I´d like to use the openMV cam H7 to take snapshots (GRAYSCALE, VGA resolution) every 2 seconds. I also want to give images a name based on timestamp and save them in jpg. I found the below code and I saved it on the cam, then I disconnected the USB and started powering the cam with a power bank. When I reconnected the cam to the laptop to see the saved images it could not find the cam anymore. Suggestion? Is there something I should modify in the code?
import pyb, machine, sensor, image, pyb, os
# Create and init RTC object.
rtc = pyb.RTC()
newFile =False
try:
os.stat('time.txt')
except OSError: # If the log file doesn't exist then set the RTC and set newFile to True
#datetime format: year, month, day, weekday (Monday=1, Sunday=7), hours (24 hour clock), minutes, seconds, subseconds (counds down from 255 to 0)
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 # Image file name based on RTC
# Enable RTC interrupts every 10 seconds, camera will RESET after wakeup from deepsleep Mode.
rtc.wakeup(10000)
BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 1000) # Let new settings take affect.
pyb.LED(BLUE_LED_PIN).on()
if(newFile): # If log file does not exist then create it
with open('time.txt', 'a') as timeFile: # Write text file to keep track of date, time and image number
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: # Append to date, time and image number to text file
timeFile.write(newName + ',' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + second + ',' + subSecond + '\n')
# Take photo and save to SD card
img=sensor.snapshot()
img.save('images/' + newName, quality=90)
pyb.LED(BLUE_LED_PIN).off()
# Enter Deepsleep Mode
machine.deepsleep()