If you are a lucky owner of a Pi Camera for your Raspberry, you can create some intresting stuff with it.
One of my next posts i'll show you some application that involve Pi Camera but in this post i'll show you some command that you need to learn to start using you camera.
What you need is:
- Pi Camera (check it on amazon)
- A good subject for your photos...
Ok let's go. First you need to enable your pi camera from your raspberry. So inside your raspberry
Menu -> Preferences -> Raspberry PI Configuration
and the enable it
Ok, now you are ready to start with your camera.
Create a new python script and import modules:
from picamera import PiCamera, Color
from time import sleep
we import sleep module too because we add a wait time to allow camera time to give sense of light level.
And now we can take our first shoot:
camera = PiCamera()
sleep(5)
camera.capture('/home/pi/Desktop/firstShoot.jpg')
if we want to record a video with our camera
camera.start_recording('/home/pi/Desktop/video.h264')
sleep(5)
camera.stop_recording()
PiCamera module expose some usefull API you can use to handle your camera.
For example you can rotate your camera view:
# Camera Rotation
camera.rotation = 90
sleep(5)
camera.capture('/home/pi/Desktop/image_rotate_90.jpg')
camera.rotation = 180
sleep(5)
camera.capture('/home/pi/Desktop/image_rotate_180.jpg')
camera.rotation = 270
sleep(5)
camera.capture('/home/pi/Desktop/image_rotate_270.jpg')
camera.rotation = 0
sleep(5)
camera.capture('/home/pi/Desktop/image_rotate_0.jpg')
you can change resolution for your image:
# Take photo with max resolution
camera.resolution = (2592, 1944)
sleep(5)
camera.capture('/home/pi/Desktop/max.jpg')
you can add text to your photos
# Add text to photo
camera.annotate_text_size = 50
camera.annotate_background = Color('blue')
camera.annotate_foreground = Color('yellow')
camera.annotate_text = "Hello world!"
sleep(5)
camera.capture('/home/pi/Desktop/text.jpg')
- none
- negative
- solarize
- sketch
- denoise
- emboss
- oilpaint
- hatch
- gpen
- pastel
- watercolor
- film
- blur
- saturation
- colorswap
- washedout
- posterise
- colorpoint
- colorbalance
- cartoon
- deinterlace1
- deinterlace2
and you can activate them with:
camera.image_effect = 'colorswap'
sleep(5)
camera.capture('/home/pi/Desktop/colorswap.jpg')
changing the name of the effect you want use
There is the possibility to set camera exposure:
camera.exposure_mode = 'beach'
sleep(5)
camera.capture('/home/pi/Desktop/beach.jpg')
and you can choose one of among those settings:
- off
- auto
- night
- nightpreview
- backlight
- spotlight
- sports
- snow
- beach
- verylong
- fixedfps
- antishake
- fireworks
and now what happens to our wonderfull t-rex from jurassic park film
camera.awb_mode = 'sunlight'
sleep(5)
camera.capture('/home/pi/Desktop/sunlight.jpg')
and possibilities are:
- off
- auto
- sunlight
- cloudy
- shade
- tungsten
- fluorescent
- incandescent
- flash
- horizon
Camera module has a lot of very intresting settings that you can use for your photo and video. I suggest to you to read this documentation.
Remember to close your camera with:
camera.close()
Very very simple to use!
Stay tuned for next tutorial!!
Commenti
Posta un commento