Surveillance Camera with Raspberry Pi
This example shows how to use Raspberry Pi™ hardware board and an Android™ device to build a surveillance camera.
In this example you will learn how to create Simulink® models that stream video captured on a Raspberry Pi hardware board to an Android device. A USB camera attached to a servo motor connected to the Raspberry Pi board captures the raw video. The generated Android app displays the video captured from Raspberry Pi board. In the Android app, you also have a slider to control the camera angle, a button to inverses the video image, a button to detect the edge and a slider to adjust the brightness of the video image.
Complete the Raspberry Pi LED Control example
Raspberry Pi board
(Optional) Servo motor (tested with TowerPro SG-5010)
(Optional) Battery pack (4 AA Battery pack for TowerPro SG-5010)
(Optional) Breadboard and jumper wires
Task 1 - Set up Hardware
In this task, you will set up a servo motor(optional) and USB web camera with Raspberry Pi board.
1. (If you don't have a servo motor, skip this step.) Secure USB camera on the shaft of the servo motor and secure the servo motor on a surface.
2. Plug the USB interface of USB web camera into the USB port of Raspberry Pi board
3. (If you don't have a servo motor, skip this step.) Wire the servo motor as shown in the simplified circuit diagram below. For the servo motor and battery pack, read the specification of your servo motor and install battery pack properly. Make sure to connect the ground of battery pack to the ground of Raspberry Pi board. Improper installation of the servo motor and battery pack will damage Raspberry Pi board. In the circuit schematic below, the servo motor control line is connected to GPIO 18 pin.
Task 2 - Configure Simulink Models
In this task you will configure models for Raspberry Pi hardware and Android device.
Assume that Simulink Support Package for Raspberry Pi Hardware is installed and the hardware network connection between Raspberry Pi board and your Android device are set up. Otherwise, refer to Raspberry Pi LED Control example for setup steps.
1. Open the Android model. Double click the UDP Send block and update the Remote IP address parameter with your Raspberry Pi IP address.
2. Open the Raspberry Pi model. Double-click Video Send Subsystem, update UDP Send Red, UDP Send Blue and UDP Send Green blocks with the IP address of your Android device. If you have a servo motor, double click Standard Servo Write and update Minimum pulse duration and Maximum pulse duration based on your servo motor.
Task 3 - Run Simulink Models on Raspberry Pi hardware and Android device
1. On the Hardware tab of the Raspberry Pi Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start.
2. On the Hardware tab of the Android Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start.
3. Observe the image captured from Raspberry Pi board display on the screen. Slide the Camera Pan Angle and observe the change of camera angle. Slide the Brightness Level and observe the brightness change. Press Image Inversion button to invert image color. Press Edge Detection button to detect edges.
Other Things to Try
Add more functionalities to surveillance camera, such as
Add motion sensor in Raspberry Pi hardware to trigger video only when motion detected.