Raspberry Pi Camera Module Quick Setup
This tutorial will cover the Raspberry Pi Camera Module Quick Setup with step by step instructions. The first thing you should do is follow the Raspberry Pi PiCamera hardware installation found here. Basically just make sure the blue tape is facing away from the USB portion of the Raspberry Pi.
Note: This tutorial assumes that you are able to connect to your Raspberry Pi via SSH and that you have a camera module. If you would like to setup SSH please visit this tutorial.
1. Enable Camera
Run the following commands
Choose Option 5, enable camera. Then you will have to reboot.
2. Project Directory and camera testing
By default, the Pi Camera will save to the current working directory. We are going to go through a few of the tests for video and image capture.
cd /home/pi mkdir picam && cd picam nano image.py
3. Taking a still image
The image.py file will just be used for testing image capturing capabilities with your Raspberry Pi. In order to use the Python functions provided to us by the Pi Cam driver, you must have import picamera at the top of your python file.
import picamera camera = picamera.PiCamera() camera.capture('image.jpg')
This will save a file called ‘image.jpg’ in our project directory.
4. Brightness Testing
If you are connected to an external monitor through your raspberry pi you can use this script to test the brightness levels. You should see a preview of what your camera is seeing on your external monitor.
import picamera from time import sleep camera = picamera.PiCamera() camera.start_preview() for i in range(100): camera.brightness = i sleep(0.1) camera.stop_preview()
5. Taking video
cd /home/pi/picam nano video.py
The video.py file will be used for testing video capturing capabilities with your Raspberry Pi. In order to use the Python functions provided to us by the Pi Cam driver, you must have import picamera at the top of your python file. Paste this into the video.py file.
import picamera from time import sleep camera = picamera.PiCamera() camera.vflip = True camera.hflip = True camera.brightness = 60 camera.start_recording('video.h264') sleep(5) camera.stop_recording()
This will save a file called ‘video.h264’ in our project directory.
Purchase the Raspberry Pi Camera Module through Amazon below.