Plug the camera module into the designated port of your Raspberry Pi. Then enable the camera via raspi-config. There are many tutorials on how to do this. We don’t want to bore you.
Install picamera library for Python 3: sudo apt-get install python3-picamera
Write and save the following in a python file: sudo nano pitest.py
import picamera from time import sleep camera = picamera.PiCamera() camera.capture('image.jpg') #taking a picture and save it in image.jpg camera.start_preview() camera.vflip = True #vertical flip if you have your cam turned upside down like ours camera.hflip = True #horizontal flip if you have your cam turned upside down like ours camera.brightness = 60 #video recording camera.start_recording('video.h264') sleep(5) camera.stop_recording()
Run it: sudo python3 camtest.py
Simple and awesome right?!
Now you can combine it with pan & tilt kit and mjpg streamer for basic surveillance cam project.
Further reading:
- http://picamera.readthedocs.org/en/release-1.0/recipes1.html
- https://www.raspberrypi.org/picamera-pure-python-interface-for-camera-module/
(Visited 1,181 times, 1 visits today)