Using the camera with Python
The camera module on the Raspberry Pi is more than just a standard webcam. Since we have full access to the controls and settings from within our own programs, it allows us to take control and create our own camera applications.
In this chapter, we will use the Python module called picamera
created by Dave Hughes to control the camera module, which performs all the functions raspivid
and raspistill
support.
See http://picamera.readthedocs.org for additional documentation and lots of useful examples.
Getting ready
The Raspberry Pi camera module should be connected and installed as detailed in the previous section.
In addition, we will also need to install the Python 3 Pillow Library (the details of how to do this have been covered in the Displaying photo information in an application recipe in Chapter 3, Using Python for Automation and Productivity).
Now, install picamera
for Python 3 using the following command:
sudo apt-get install python3-picamera
How to do it…
Create...