Difference between revisions of "Raspberry Pi: Camera"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) (Created page with "== Camera setup == Setup == Bash == {| class="wikitable" |- ! Command !! Action |- | raspistill || Capturing still ph...") |
Rafahsolis (talk | contribs) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Camera setup == | == Camera setup == | ||
| − | + | [https://www.raspberrypi.org/help/camera-module-setup/ Setup] | |
| + | |||
| + | == Permissions == | ||
| + | Create a group with permission tu use the camera, and add the user that will be using it: | ||
| + | <nowiki> | ||
| + | # echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' \ | ||
| + | > > /etc/udev/rules.d/10-vchiq-permissions.rules | ||
| + | # usermod -a -G video pi</nowiki> | ||
| + | Reboot. | ||
| + | |||
| + | Set paths: | ||
| + | edit $HOME/.bashrc, add: | ||
| + | |||
| + | add: | ||
| + | <nowiki> | ||
| + | export PATH=$PATH:/opt/vc/bin | ||
| + | export LD_LIBRARY_PATH=$LD_LIBRARYPATH:/opt/vc/lib</nowiki> | ||
| + | |||
== Bash == | == Bash == | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 14: | Line 31: | ||
| raspiyuv || Capturing still photographs and generating raw unprocessed image files | | raspiyuv || Capturing still photographs and generating raw unprocessed image files | ||
|} | |} | ||
| + | |||
| + | == Python == | ||
| + | First install the python-picamera | ||
| + | <nowiki> | ||
| + | sudo apt-get update | ||
| + | sudo apt-get install python-picamera</nowiki> | ||
| + | |||
| + | == Usage == | ||
| + | <source lang="python"> | ||
| + | # Import module | ||
| + | import picamera | ||
| + | |||
| + | # Create an instance | ||
| + | camera = picamera.PiCamera() | ||
| + | |||
| + | # Take a picture | ||
| + | camera.capture('image.jpg') | ||
| + | |||
| + | # Horizontal/Vertical flip | ||
| + | camera.hflip = True | ||
| + | camera.vflip = True | ||
| + | |||
| + | # Start/Stop preview | ||
| + | camera.start_preview() | ||
| + | camera.stop_preview() | ||
| + | |||
| + | # Camera Settings | ||
| + | camera.brightness = 70 #Defoult is 50 | ||
| + | |||
| + | # Other settings default values: | ||
| + | camera.sharpness = 0 | ||
| + | camera.contrast = 0 | ||
| + | camera.brightness = 50 | ||
| + | camera.saturation = 0 | ||
| + | camera.ISO = 0 | ||
| + | camera.video_stabilization = False | ||
| + | camera.exposure_compensation = 0 | ||
| + | camera.exposure_mode = 'auto' | ||
| + | camera.meter_mode = 'average' | ||
| + | camera.awb_mode = 'auto' | ||
| + | camera.image_effect = 'none' | ||
| + | camera.color_effects = None | ||
| + | camera.rotation = 0 | ||
| + | camera.hflip = False | ||
| + | camera.vflip = False | ||
| + | camera.crop = (0.0, 0.0, 1.0, 1.0) | ||
| + | |||
| + | |||
| + | # Video recording | ||
| + | camera.start_recording('video.h264') | ||
| + | sleep(5) | ||
| + | camera.stop_recording() | ||
| + | </source> | ||
| + | |||
| + | [http://picamera.readthedocs.org/ python-picamera documentation] | ||
Latest revision as of 19:15, 9 April 2015
Camera setup[edit]
Permissions[edit]
Create a group with permission tu use the camera, and add the user that will be using it:
# echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' \ > > /etc/udev/rules.d/10-vchiq-permissions.rules # usermod -a -G video pi
Reboot.
Set paths: edit $HOME/.bashrc, add:
add:
export PATH=$PATH:/opt/vc/bin export LD_LIBRARY_PATH=$LD_LIBRARYPATH:/opt/vc/lib
Bash[edit]
| Command | Action |
|---|---|
| raspistill | Capturing still photographs with the camera module |
| raspivid | Capturing video with the camera module |
| Time-lapse | Taking pictures at regular intervals and stitching them together in to a video |
| raspiyuv | Capturing still photographs and generating raw unprocessed image files |
Python[edit]
First install the python-picamera
sudo apt-get update sudo apt-get install python-picamera
Usage[edit]
# Import module
import picamera
# Create an instance
camera = picamera.PiCamera()
# Take a picture
camera.capture('image.jpg')
# Horizontal/Vertical flip
camera.hflip = True
camera.vflip = True
# Start/Stop preview
camera.start_preview()
camera.stop_preview()
# Camera Settings
camera.brightness = 70 #Defoult is 50
# Other settings default values:
camera.sharpness = 0
camera.contrast = 0
camera.brightness = 50
camera.saturation = 0
camera.ISO = 0
camera.video_stabilization = False
camera.exposure_compensation = 0
camera.exposure_mode = 'auto'
camera.meter_mode = 'average'
camera.awb_mode = 'auto'
camera.image_effect = 'none'
camera.color_effects = None
camera.rotation = 0
camera.hflip = False
camera.vflip = False
camera.crop = (0.0, 0.0, 1.0, 1.0)
# Video recording
camera.start_recording('video.h264')
sleep(5)
camera.stop_recording()