Objective: Build a video surveillance camera on Raspberry Pi
Step 1: Connect the Camera Module to your Raspberry Pi device
Step 2: Install python library pi-camera using:
sudo apt-get install python-picamera
Step 3: In Raspberry Pi Configuration Settings under Preferences, make sure the Camera and SSH options are enabled.
It is also recommended that you change your default system password in settings.
Step 4: Test the camera module by running the following python script:
import picamera from time import sleep camera = picamera.PiCamera() camera.vflip=True camera.start_preview(fullscreen=True) sleep(30) camera.stop_preview()
The above python script should display the video stream from your Pi camera on the monitor or TV screen directly connected to your Raspberry Pi device through HDMI cable.
Step 5: Download and install the app RaspiCam Remoteon your mobile phone.
Step 6: Get your Raspberry Pi device's IP address using ifconfig command
Normally, the IP address looks like 192.168.1.XXX
Step 7: Connect to your Pi camera remotely from your mobile phone, with the RaspiCam Remote app. Unless you have changed the default options in raspi-config settings, username = pi, password = raspberry, and port = 22.
Step 8: Done! Watch the live video stream coming from your Raspberry Pi's camera on your mobile phone.
Note: If you have downloaded vnc-server on your Raspberry Pi, you can connect to your Raspberry Pi device remotely from your laptop with VNC Viewer. However, due to display overlap issues, the camera stream will not be visible on remote computer.
Step 9: Record videos to watch later.
import picamera from time import sleep camera = picamera.PiCamera() camera.vflip=True camera.resolution = (640,480) camera.start_recording('output-video.h264') sleep(60) camera.stop_recording()
The above python script will record 1 min video and save it in file output-video.h264
Next Steps: Add some code on your Raspberry Pi for motion detection or face recognition using the OpenCV library!