GithubHelp home page GithubHelp logo

octoprint-libcamera's Introduction

octoprint-libcamera

This repository is a demonstration of how I was able to use a libcamera Raspberry Pi camera (ArduCam 16MP Autofocus Camera) with OctoPrint.

Why Not Official Instructions?

https://www.arducam.com/docs/cameras-for-raspberry-pi/raspberry-pi-libcamera-guide/autofocus-camera-solution-using-on-octopi/

The official instructions from ArduCam for using libcamera with OctoPrint involve:

  • Downloading a nightly build of OctoPi
  • Installing the IMX519 kernel driver
  • Replacing the system version of mjpg_streamer with a custom version
  • Replacing the system version of webcamd with a custom version

I did not like this approach for several reasons:

  • I would rather use a stable build of OctoPi for controlling something as sensitive and potentially dangerous as a 3D printer
  • The changes made to the OctoPi image are not trivially reversible
  • Upgrading OctoPi can lead to undefined behavior (e.g. mjpg_streamer is replaced during an upgrade)

Raspbian Bullseye

Instead of starting with an OctoPi image, I opted to use the official 64-bit version of Raspbian Buster and run mjpg_streamer and OctoPrint in separate containers.

mjpg_streamer

mjpg_streamer was the most difficult part of this project to get working. The Dockerfile used to get mjpg_streamer running is under mjpg_streamer/Dockerfile.

The key components to note about this Dockerfile are:

  • The raspbian package repository is added so that libcamera-dev can be installed, which is needed to compile mjpg_streamer
  • All inputs and outputs other than input_libcamera and output_http are removed.
    • This is partially to reduce compile time, but mostly to remove the OpenCV dependency. Installing libopencv-dev involves downloading almost an entire gigabyte of dependencies!
  • I was lazy and used --privileged to pass all devices through to the container in docker-compose.yaml. This is not safe and probably not what you want to do.
    • Do as I say, not as I do.
  • I also mounted /run/udev to the container in read-only mode. This was based on comments in kbingham/libcamera#35

octoprint

I used the official OctoPrint image here. Things to note:

  • I used --privileged here again to pass through devices to OctoPrint. Again, don't do this.
  • I mounted a couple of other volumes to get the NavbarTemp plugin to recognize and read the Pi's SoC temperature.
    • /proc/cpuinfo:/proc/cpuinfo:ro
    • /usr/bin/vcgencmd:/usr/bin/vcgencmd:ro
    • /usr/lib/aarch64-linux-gnu/libvcos.so.0:/usr/lib/aarch64-linux-gnu/libvcos.so.0:ro
    • /usr/lib/aarch64-linux-gnu/libvchiq_arm.so.0:/usr/lib/aarch64-linux-gnu/libvchiq_arm.so.0:ro

octoprint-libcamera's People

Contributors

ruiqimao avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

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.