Take multiple pictures on demand using Raspberry Pi python code

The python code below takes as many pictures you want as long as you keep pressing enter and saves images in a specified folder (in this case "images") with image names "image1.jpg" , "image2.jpg", etc., from picamera import PiCamera from time import sleep camera = PiCamera() camera.rotation = 270 i = 0 while not raw_input("Press enter for a photo"):    i = i + 1    camera.start_preview(alpha=200)    sleep(1)    image_path = "./images/image"+str(i)+".jpg"    camera.capture(image_path)    camera.stop_preview()    print("image successfully saved in the path: "+image_path) Important things to remember You could also use input() instead of raw_input() function based on the python version. make sure the folder exists already. This code might not create a new folder. Do while in python doesn't exist.

Raspberry Pi - Creating a camera preview for 1 minute

Creating a camera preview for 1 minute using python code.


from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.rotation = 270 #Your required orientation
camera.start_preview(alpha=200) #transparency - ranging from 0 - 255
sleep(60) #change the time here (in seconds)
camera.stop_preview()


Comments

Popular posts from this blog

Raspberry - Record a video for x minutes / x hours using command line option