I am working on a time lapse project, and I would like to be able to save my files with a time stamp (something like YYYYMMDD-HMS.jpg). So I used the code below:
import time import picamera VIDEO_DAYS = 1 FRAMES_PER_HOUR = 360 FRAMES = FRAMES_PER_HOUR * 3 * VIDEO_DAYS file = time.strftime("%Y%m%d-%H%M%S") def capture_frame(frame): with picamera.PiCamera() as cam: time.sleep(2) cam.led = False #Turn off the Red LED cam.capture('/home/pi/camera/'+file+'.jpg' % (frame)) # Capture the images for frame in range(FRAMES): # Note the time before the capture start = time.time() capture_frame(frame) # Wait for the next capture. Note that we take into # account the length of time it took to capture the # image when calculating the delay time.sleep( int(60 * 60 / FRAMES_PER_HOUR) - (time.time() - start) )
I end up getting this error message.
File "camera.py", line 20, in <module> capture_frame(frame) File "camera.py", line 14, in capture_frame cam.capture('/home/pi/camera/'+file+'.jpg' % (frame)) TypeError: not all arguments converted during string formatting
I feel like I am missing something simple or obvious, but I am not sure what that is, and my inexperience is starting to show.
Any help would be greatly appreciated, thank you!