Video Streaming Camera with Raspberry Pi

Live streaming video cameras can be used for security or personal purposes. A variety of webcams, camcorders, DSLRs and mirrorless cameras for streaming live video are a vailable in the market. You want to own one too but can’t afford it! Don’t worry, we will help you build one yourself at less than Rs 2000.

Today, in this DIY project, we are going to make a live streaming camera that can be accessed over Wi-Fi. The best part of this project is that you can view the video live streaming on multiple devices like computer, tablet and phones. You can also move its camera lens wirelessly for wide-angel views. Another interesting thing is that you can set this camera in a motion detection mode to enable it to take picture or record video when motion is detected. However, you may experience video lag depending on the Wi-Fi network.

Fig 1. Prototype

We can make this project by applying two methods, which will be explained below.
Setting Raspberry Pi for camera

First, you have to set up the Raspberry Pi for camera interface. Open the terminal and run this command “sudo raspi-config”. Then you will get a blue colour window with several options. Select the “Interfacing” option and enable the camera interface. (Refer Fig 2,3,4).

Fig 2. Configuration of Raspberry Pi

Fig 3. Setting interfaces

Fig 4. Setting Camera

Now, your Raspberry Pi is ready for camera interface, meaning you can start streaming camera video over Wi-Fi. You can archive this using the following two methods.

Streaming Camera Video using VLC player.

In the first method, we are going to stream the camera video using VLC player. To do this, first open the terminal window and type the following command to install VLC on your Raspberry Pi.

“Sudo apt-get install vlc”

After the successful installation, you can stream your camera video using the following command

 “raspivid -o – -t 0 -n | cvlc -vvv stream:///dev/stdin –sout ‘#rtp{sdp=rtsp://:8554/}’ :demux=h264”

To obtain the output of the video streamed by the camera, connect your PC or phone to the same Wi-Fi network on which Raspberry Pi is connected. Next open the VCL player, then go on stream menu and paste the url.

rtsp://ip address of your pi:8554/


Now, open the text editor and put the following code in it

And save it as cam.py and whenever you want to live stream a video, run this program.
Streaming Video Using Motion

Open the terminal and run the following command to install motion  “sudo apt-get install motion”

Then setup setting to run the camera server continuously on background

“sudo nano /etc/default/motion”

 start_motion_daemon=yes

Then make some changes in motion config as described below (Refer Fig 5).

Run this command

“sudo nano /etc/motion/motion.conf”

Do these changes according to your need

Stream_port=8081

Stream quality 50 # set the quality according to your need

# Allow motion to run the daemon we’ve set earlier
daemon on

# set the framerate of the stream (100 for higher quality)
framerate 100

# set the width and height of your video
width 640
height 480

# control de port 8080 by default
webcontrol_port 8080

# careful! don’t set the stream_port just like the webcontrol port

When you done with the above setting, save and exit the config file using key “CTRL + X”. Then hit the Y key and then press enter.

To start camera video streaming, open the terminal and run this command

“sudo service motion start”

“Sudo motion”

Now, connect your PC and Raspberry Pi on the same network. After that open any web browser and type the following url



https:// ip address of your raspberry pi:8081

Now you can get the camera video streaming on your web browser.

Fig 5.Configration of motion

Cam video output either over HDMI or RCA composite

If you want to get video output like other surveillance cameras on RCA composite or on HDMI without any video lag, then create the following python code and run that code to get Raspberry Pi camera video on your TV screen.



Giving movement to camera

Create a python program as in code snippet below and run the code for movement of servo motor.



As you have completed the setting and software part, it’s time to put together the whole stuff in an enclosure.

First connect the servo motor to Raspberry Pi pins as illustrated below

Motor PWM signal pin (Orange colour wire) to Raspberry Pi GPIO

Servo motor VCC  to   5V power supply

GND to Power supply GND

Raspberry Pi GND to Servo Motor GND

Now, put the Raspberry Pi in camera case and fix everything according to the pics shown below –

Fig 6. Raspberry pi cover.

Fig 7. Raspberry pi inside case

Fig 8 Solder the wires to GPIO pinouts

Fig 9. Mount the Raspberry pi case over servo motor



Author : Ashwini Kumar Sinha Sourced By : EFY

0 comments:

Post a Comment