Code Monkey home page Code Monkey logo

pizero-webcam-tutorial's Introduction

pizero-webcam-tutorial

A step-by-step tutorial for setting up a Raspberry Pi Zero W computer as a webcam

OctoPrint is the leading web software for controlling 3D printers, created/maintained by Gina Häußge

OctoPi is a Raspberry-specific distro of OctoPrint, maintained by Guy Sheffer

mjpg-streamer is a fork of a popular streaming service as maintained by Jackson Liam

Overview

Although a standard OctoPi installation seems to work fine with a single camera (Raspberry Pi 3), adding a second webcam can sometimes add to the complexity. Adding a webcam to an OctoPi install on a Raspberry Pi Zero or Zero W is asking too much of the single core processor; it's best to offload this work if possible.

Using the approach here, it should be possible to build a dedicated Raspberry Pi Zero W—based webcam. In theory, you could have several views of your 3D printer and include them within the OctoPrint web interface to offer different viewpoints of the work being accomplished.

Installation

  1. Visit the downloads page to get the latest Raspbian Stretch Lite image
  2. Use Etcher to burn this image to a 4GB microSD card that you've installed in your workstation, noting that it should automatically eject the card when finished
  3. Remove and re-insert the microSD card so that it's mounted again
  4. Using Finder or the Terminal program, create a new /Volumes/boot/wpa_supplicant.conf file. Add a line with country=US so that it indicates your own country code then add the following at the end of the file (editing with your own zone/password information but keeping the quotation marks).
country=US

network={
    ssid="your_SSID"
    psk="your_PSK"
    key_mgmt=WPA-PSK
}

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Additionally, create an empty file in /Volumes/boot called ssh.

 5. Use Finder's eject feature to safely eject the microSD card, removing it and putting it into the Raspberry Pi Zero W computer

 6. Install the Raspberry Pi—based webcam with the micro ribbon cable

 7. Power the Raspberry Pi Zero W with a 5V micro USB adapter or USB cable, noting the activity of the onboard LEDs

 8. Remote into the computer by running ssh [email protected] using raspberry as the default password

 9. Remotely on the Raspberry, run sudo raspi-config to:

  • change the hostname to something like picam1 under the 2 Network Options -> N1 Hostname section
  • change the default password to something you can remember under the 1 Change User Password section
  • change the localisation settings to minimally update the wi-fi country code and timezone but also the locale information and the keyboard layout
  • change the bootup options to log in automatically to the console under the 3 Boot Options -> B1 Desktop / CLI -> B2 Console Autologin option
  • change the Interfacing Options -> P1 Camera to enable it
  • select Advanced Options -> A1 Expand Filesystem
  • choose Finish

 10. Having rebooted after that session, note that the hostname and (optionally) the password would have changed as you remote back into the Raspberry with ssh [email protected], for example

 11. Remotely, run sudo apt-get update as well as the following command

 12. sudo apt-get upgrade -y

 13. sudo apt-get install git -y

 14. sudo apt-get install cmake libjpeg8-dev -y

 15. cd ~

 16. git clone https://github.com/jacksonliam/mjpg-streamer.git

 17. cd mj*/mj*

 18. make

 19. sudo make install

 20. Run sudo nano /etc/rc.local and add this before the exit command:

cd /home/pi/mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH="$(pwd)"
./mjpg_streamer -i "input_raspicam.so" -o "output_http.so -w ./www"

 21. Run sudo reboot and wait two minutes

 22. Try http://picam1.local:8080 and http://picam1.local:8080/?action=stream

Main page screenshotStream screenshot

Follow-up

From here, you may want to install the MultiCam plugin to take advantage of your external webcam, as hosted by a Raspberry Pi Zero W computer.

--

Description Version Author Last Update
pizero-webcam-tutorial v1.0.1 OutsourcedGuru June 18, 2018
Donate Cryptocurrency
eth-receive btc-receive
Ethereum Bitcoin

pizero-webcam-tutorial's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pizero-webcam-tutorial's Issues

Create a service instead of using rc.local

I prefer making an easily restartable service to help with tuning resolution/framerate options
My config is similar to this:

Filename: mjpg_streamer.service
Location: /lib/systemd/system/

Contents:

[Unit]
Description=MJPG Streaming Service
After=network.target

[Service]
Type=simple
WorkingDirectory=/home/pi
ExecStart=/home/pi/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -o "/usr/local/lib/mjpg-streamer/output_http.so -w /home/pi/mjpg-streamer/mjpg-streamer-experimental/www" -i "/usr/local/lib/mjpg-streamer/input_raspicam.so -x 1280 -y 720 -fps 41 -quality 40 -ex sports -ifx none -mm average"
ExecStop=/bin/kill -SIGINT $MAINPID
StandardOutput=journal
StandardError=inherit
SyslogIdentifier="mjpg_streamer"
Restart=always
RestartSec=1
User=root

[Install]
WantedBy=multi-user.target

Link by running: sudo ln -s /lib/systemd/system/mjpg_streamer.service /etc/systemd/system/mjpg_streamer.service
Refresh systemd: sudo systemctl daemon-reload
Enable service: sudo systemctl enable mjpg_streamer
Start service for the first time: sudo systemctl start mjpg_streamer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.