/servocam

A simple web interface for viewing and controlling a Raspberry Pi camera with servos

Primary LanguagePython

Motion Servo Camera

A simple web interface for viewing and controlling a Raspberry Pi camera with servos

gif of pan tilt camera

Hardware Requirements

Software Requirements

Software Install

Clone repo to correct location on pi

git clone https://github.com/se1exin/servocam.git ~/servocam

cd ~/servocam

Install system dependencies

sudo apt update && sudo apt install motion nginx python3 python3-pip

Enable Raspberry Pi Camera

sudo raspi-config

Go to Interfacing Options > Camera > Yes. Exit out to save and then reboot the pi.

Setup motion

Edit the motion conf file.

sudo nano /etc/motion/motion.conf

Make the following changes to improve framerate, enable remote access, and run on boot:

  • daemon on
  • width 640
  • height 480
  • framerate 10
  • locate_motion_mode off
  • ffmpeg_output_movies off
  • stream_motion off
  • stream_maxrate 10
  • stream_localhost off
  • webcontrol_port 0
sudo nano /etc/default/motion

Change start_motion_daemon=no to start_motion_daemon=yes

Enable the motion systemd daemon

sudo systemctl enable motion

Make sure permissions are correctly set on the motion log file

sudo chown -R motion: /var/log/motion

Reboot and check camera is available at http://raspberrypi:8081 after the pi has booted.

Install python dependencies

# Run inside this repo/directory

sudo pip3 install -r requirements.txt

Setup Gunicorn

sudo cp gunicorn.service /etc/systemd/system/gunicorn.service
sudo systemctl daemon-reload
sudo systemctl enable gunicorn
sudo systemctl start gunicorn

Setup nginx

sudo mv /etc/nginx/sites-available/default_old
sudo cp nginx-site.conf /etc/nginx/sites-available/default
sudo systemctl enable nginx
sudo systemctl restart nginx

Reboot

Everything should now be installed. Reboot.

sudo reboot

The interface should be available at http://raspberrypi

Resources