Difference between revisions of "Raspberry Pi: Camera V2"
Line 1: | Line 1: | ||
== Summary == | == Summary == | ||
This documentation is about the usage of the Raspberry Pi | This documentation is about the usage of the Raspberry Pi Module Camera V2. It describes basic usage via the Shell and advanced usage with Python programming. | ||
== Requirements == | == Requirements == | ||
Line 11: | Line 11: | ||
== Installation == | == Installation == | ||
Firstly you have to Plug in The Camera | Firstly you have to Plug in The Camera Module with the Ribbon Cable. Then you have to allow the usage of the Camera interface: | ||
sudo raspi-config | sudo raspi-config | ||
Line 21: | Line 21: | ||
== Shell usage == | == Shell usage == | ||
Rasbian already supplies pre-installed shell scripts for the | Rasbian already supplies pre-installed shell scripts for the camera module usage. The is one for Capturing Image <code>raspistill</code> and one for capturing video <code>raspivid </code>. | ||
=== Capturing images === | === Capturing images === | ||
Line 43: | Line 43: | ||
raspivid -o ./video.h264 | raspivid -o ./video.h264 | ||
h264 is a | h264 is a video codec that is compatible with almost every device that can play video. The pi camera can also output mp4 files. For further information use | ||
raspivid --help | raspivid --help | ||
Line 51: | Line 51: | ||
=== Taking and exporting stills === | === Taking and exporting stills === | ||
The library uses the <code>start_preview()</code> and <code>stop_preview()</code> to start and end the preview on the screen with out capturing a photograph. The delay is used to frame the shot. It is also | The library uses the <code>start_preview()</code> and <code>stop_preview()</code> to start and end the preview on the screen with out capturing a photograph. The delay is used to frame the shot. It is also possible to project the preview for a long amount if time while taking multiple photos with a different implementation. Then the <code>capture(Filename)</code> function captures the photo and saves it to the defined directory with the following filename. There are multiple possible image formats by using one of the corresponding filenames: <code>'.jpeg'</code>,<code>'.png'</code>,<code>'.gif'</code>,<code>'.bmp'</code>,<code>'.yuv'</code>,<code>'.rgb'</code>,<code>'.rgba'</code>,<code>'.bgr'</code>, or <code>'.bgra'</code> | ||
from picamera import PiCamera | from picamera import PiCamera |
Revision as of 12:00, 14 October 2020
Summary
This documentation is about the usage of the Raspberry Pi Module Camera V2. It describes basic usage via the Shell and advanced usage with Python programming.
Requirements
- Hardware: Raspberry Pi
- Operating system: Rasbian
- Interpreter: Python or Python3
Installation
Firstly you have to Plug in The Camera Module with the Ribbon Cable. Then you have to allow the usage of the Camera interface:
sudo raspi-config
-> Interfacing Options -> Camera -> Enable it
Shell usage
Rasbian already supplies pre-installed shell scripts for the camera module usage. The is one for Capturing Image raspistill
and one for capturing video raspivid
.
Capturing images
The simplest way to take is py entering the following command:
raspistill -o ./image0.jpg
You can easily adjust the pixel height and with by using the -w
and -h
parameters like this:
raspistill -o ./image1.jpg -w 640 -h 480
For advanced use its suggested to read the output of the following command:
raspistill --help
Capturing video
To capture a video you need to use the raspivid
command like this
raspivid -o ./video.h264
h264 is a video codec that is compatible with almost every device that can play video. The pi camera can also output mp4 files. For further information use
raspivid --help
Python Usage
As well as for all Raspberry accessories, the camera module also comes with a really good python library for both taking still and capturing videos. On the following paragraph I will only cover taking images for the full documentation read the picamera.readthedocs.io documentation.
Taking and exporting stills
The library uses the start_preview()
and stop_preview()
to start and end the preview on the screen with out capturing a photograph. The delay is used to frame the shot. It is also possible to project the preview for a long amount if time while taking multiple photos with a different implementation. Then the capture(Filename)
function captures the photo and saves it to the defined directory with the following filename. There are multiple possible image formats by using one of the corresponding filenames: '.jpeg'
,'.png'
,'.gif'
,'.bmp'
,'.yuv'
,'.rgb'
,'.rgba'
,'.bgr'
, or '.bgra'
from picamera import PiCamera from time import sleep camera = PiCamera() camera.start_preview() sleep(5) camera.capture('./image.jpg') camera.stop_preview()
Used Hardware
Rasperry Pi Camera Modul V2, 8MP