Created
March 13, 2021 15:39
-
-
Save dnnsmnstrr/6197a9e2b78106b0500de5eefe3c294a to your computer and use it in GitHub Desktop.
Takes a picture using the raspberry pi camera and saves the resulting image with datetime filename
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from picamera import PiCamera | |
import time | |
import os | |
camera = PiCamera() | |
camera.start_preview() | |
time.sleep(3) | |
currentTime = time.strftime("%Y-%m-%d-%T") | |
#print(currentTime) | |
if not os.path.exists('/home/pi/Desktop/camera/'): | |
os.makedirs('/home/pi/Desktop/camera/') | |
path = '/home/pi/Desktop/camera/' + currentTime + '.jpg' | |
camera.capture(path) | |
camera.stop_preview() | |
os.system('xdg-open ' + path) | |
print(path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment