The most common use for the Raspberry Pi camera module is taking still pictures. Use Python code to take a photo with the camera.
Change your code to reduce the sleep and add a camera.capture() line. It should look like this:
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
sleep(5)
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()
It's important to sleep for at least two seconds before capturing, to give the sensor time to set its light levels.
Run the code by pressing 'F5'. The camera preview will open for five seconds before capturing a still picture. The preview will adjust to a different resolution as the picture is taken.
The photo will be saved to your desktop. Find the file and double-click on it to open it.
Add a loop to take five pictures in a row:
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
for i in range(5):
sleep(5)
camera.capture('/home/pi/Desktop/image%s.jpg' % i)
camera.stop_preview()
The variable (something that can change) contains the number of times we’ve been around the loop. It starts at 0. Each time the code goes around the loop, that number is increased by 1. So the images will be saved as image0.jpg, image1.jpg, and so on.
Run the code again by pressing 'F5'. It will take one picture every five seconds.
Once the fifth picture is taken, the preview will close.
Now look at the images on your desktop and you'll see five new pictures.