Loading...
 

Firmware/Software

Raspberry Pi Camera IP Webcam

morreale Tuesday 18 of August, 2020
I purchased a Raspberry Pi infrared camera module (Digikey part number: 1597-1423-ND) to turn my Raspberry Pi model B+ into a webcam. I wanted something that could see in the dark at the time I purchase the camera module late last year. When I realized that a webcam would be useful with Skype, Webex, Google Meet, Discord, and Zoom meetings, webcams and cameras in general went mostly out of stock due the stay at home orders to combat COVID-19.

The Raspberry Pi camera module uses the 5 megapixel OV5647 sensor. The camera module includes two IR LEDs. According to the Raspberry Pi website this is a version 1 camera.

Rpi Camera V1

The OV5647 sensor data sheet indicates that the camera provides the following formats. I've only managed to get the 640 x 480 resolution to works so far. The CPU utilization is 90% at this resolution and may indicate that a Model B+ may not be able to stream higher resolutions.

Mode Resolution Aspect Ratio Frame Rate FoV Binning
1920x1080  16:9  1 - 30  Partial None
2592x1944  4:3  1 - 15  Full None
2592x1944  4:3  1/6 - 1  Full None
1296x972  4:3  1 - 42  Full 2x2 
1296x730  16:9  1 - 49  Full 2x2 
640x480  4:3  42 - 60  Full 4x4 
640x480  4:3  60 - 90  Full 4x4 


Raspberry Pi Camera Module webpage provides useful information on using the Raspberry Pi Camera.

Raspberry Pi Webcam Setup


The article How to setup a Raspberry Pi Security Camera Livestream has some missing info so I could not follow it. I used Build a Raspberry Pi Webcam Server in Minutes instead and the steps below are a summary of the article. To begin, update the Raspberry Pi, and install motion and libjpeg62.

sudo apt-get update sudo apt-get upgrade sudo apt-get install motion sudo apt-get install libjpeg62


Modify /etc/motion/motion.conf with the following changes. Motion.conf has a lot of parameters so make a back up copy before making any changes just in case.

daemon on stream_localhost off # Turn these off if motion freezes picture_output off movie_output off # The default setting changed to 1296x730 for a 16x9 aspect ratio # and a higher image resolution. stream_maxrate 100 # default 100 framerate 49 # default 100 width 640 # default 640 height 480 # default 480


Motion is very sensitive to width and height settings. If they are not correct then there is no output. High resolutions setting produce a long lag in changes of motion.

Modify /etc/default/motion

start_motion_daemon=yes


Add the video driver sudo modprobe bcm2835-v4l2

Edit /etc/modulesand add bcm2835-v4l2 to the end of the file.

The following command can be used find out the status of the camera. v4l2-ctl -V

Test motion with the following command sudo motion -n -c /etc/motion/motion.conf

Use the following commands to start and stop the motion service.

sudo service motion start sudo service motion stop


Test the Raspberry Pi Camera


Use ifconfig -a to determine the IP address of the Raspberry Pi. It should be a static IP address. If the Raspberry Pi IP address is set using DHCP, then set an IP reservation in your router to keep the IP address from changing.

Test the Raspberry Pi camera with your browser using its IP address and the port 8081. The URL would look like https://192.168.XXX.YYY:8081, for example.

Connect the Raspberry Pi Camera to OBS


To add the Raspberry Pi camera as a source in Open Broadcaster Software (OBS), selected Media Sources in the Sources block, and uncheck the Local File box. Add the IP address for the Raspberry Pi camera to the Input field https://192.168.XXX.YYY:8081). Check Use hardware decoding when available, and Show nothing when playback ends. Click okay and size the image as desired.

The Lamp-pod


I used my desk lamp as a makeshift tripod so that I could demonstrate hardware while on a video chat. The lamp-pod works, but it has a lot of limitations. I had to remove the LED light bulb to make the assembly light enough for the springs to hold up the lamp. Lifting the lamp changes the height and the angle of the camera at the same time. My camera module mount is fixed so I need to move objects on the desk to get them back in frame. To make the camera easier to position, the camera mount needs to be changed to be moveable to compensate for the angle introduced by raising and rotating the lamp arm. Also, there video lags by many seconds making it hard to position object precisely. The IR camera works well in low or with no visible light, but isn't good for my applications. It would be better for security applications.

Rpi Ip Cam 01

Rpi Ip Cam 02