A new camera stack for OctoPi

Have you tried camera-streamer? It is an independent project that is being used by OctoPrint on the OctoPi images. It has full support for the CSI cameras.

Another possibility is ustreamer. It appears to have support for the Raspberry Pi cameras as well.

Yea, looked at camera-streamer both the upstream version and in the OctoPi branch. It seems to be a major project to integrate and I wanted to avoid that work if there was an easier option (like a docker image or a single command installer script). The amount of work Gina has put in, and the length of time it's been in beta, suggests using the unstream version is far from straightforward.

It is not enough just to support CSI. The Pi people made a huge breaking change to CSI camera support. For a time, they had 'legacy support', then earlier this year they released the Camera Module 3 which does not work in legacy mode. That broke a lot of older camera software. Thanks for the ustreamer tip. It does look like it might support the new cameras, but it does not look much easier to work with than camera-streamer.

I'm willing to get into cloning from Git and compiling if forced to, but from experience it always ends up being at least a days frustrating work and with a 50% success probability at best!

restreamer maybe, I've used it in with OctoPrint with some success for both directly attached cameras and rtsp cameras.

You don't have to compile anything, and there's example service files that come with camera-streamer. I don't think it should be that difficult to install yourself based on the instructions available.

And just to chime in on this - remember that I have to create a setup that works out of the box, ideally without any human intervention necessary (think config files) for the majority of people out there, including error resilience (e.g. someone just plugged the USB camera out and back in, things should recover) and ease of config if needed (read: config files available on boot partition that can be accessed in thumb stick mode, everything bootstrapped based on those).

Your run of the mill manual install doesn't need any of that, you set up things ONCE for YOUR particular setup and that's it.

However, things would probably be no longer in beta if we didn't have seen some stability issues with camera-streamer:

If you don't access the stream within an hour or so after starting the webcam server, it seems to enter a weird state, and that's a bit of a show stopper. So while that's being worked on upstream, things will stay in beta.

Just an FYI, this new Camera Stack branch of OctoPi did not work with my camera. This was on a Raspberry Pi 3B+ and the camera is an Arducam 5MP OV5647 Camera Module with Motorized IR-CUT Filter.

This setup worked fine with an older version of OctoPi, and still works with the newest OctoPi branch without the new camera stack.

When I first installed the new branch with the new camera stack, this camera worked for a few minutes, but it kept freezing and locking up the image. Then after a few minutes it just completely stopped showing any image whatsoever from the camera. The motorized IR cut continued to work though (I could hear it clicking when I sent the command to toggle the IR cut filter).

At first when it quit working entirely I thought maybe I had damaged the ribbon cable when I was working on the printer (removing the Pi board to access the SD card to upgrade the system to the newest branch), so I ordered a new cable, but that didn't fix it.

Once I went back and installed the newest version of OctoPi WITHOUT the new camera branch, it started working just fine again.

If you are willing to help, provide details regarding "did not work", i.e. a systeminfo bundle and any other details. It would ultimately benefit the entire OctoPrint community. If possible, use a second microSD card so you can easily switch.

Ok will do. Give me a few days and ill get back here with a systeminfo upload. Just waiting on a MicroSD card extension cable to arrive, as my Pi is installed inside my ender 3 and requires tearing apart the machine to access the sd card in the Pi to swap it each time and then reinstalling all the parts to test it. So I ordered a MicroSD card extension cable to relocate the card slot outside to make things easier from now on.

Ok, I've reinstalled the New Camera Stack version of Ocroprint and I've attached a systeminfo bundle to this post. This was taken immediately after installing the new version and restoring my backup.

The camera has not completely quit working yet like it did last time, but it is glitching out right away like it did last time. Here is a short YouTube clip of the glitching webcam stream so you can see what I mean by glitching: https://youtu.be/rFi8g9GJ6qk

Again, for reference, this camera is the Arducam 5MP OV5647 Camera Module with Motorized IR-CUT Filter.

I will continue running this build of Octoprint for a while and upload another systeminfo bundle when/if the camera completely stops working again on this build.

octoprint-systeminfo-20231102183106.zip (20.8 KB)

curious if you've adjusted the width and height to the maximum available your camera is able to produce (2592x1944)? might need to play around with the OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2"' part too. Looking at notes for libcamera on the camera-streamer docs...

  • for libcamera the --camera-type=libcamera --camera-format=YUYV (better image quality) or --camera-format=YUV420 (better performance)

I apologize if the question has already been asked but is it possible to somehow enable the features relating to libcamera in an existing installation of Octoprint (installed by hand on a raspberry)?

Just in case anyone (or me in the future) needs to know how to flip or rotate the camera image horizontally, vertically or both on the new v3 camera module... add this ( --camera-hflip=1 --camera-vflip=1 ) to the end of the default file below. Notice: this is not --camera-options, it is camera-hflip, etc but it is on the same line.

/boot/camera-streamer/libcamera.conf


# The port on which the webcam server for the camera should listen on. If you have only
# one camera, leave at 8080. If you have more, change to 8081, 8082, etc. The primary
# camera will be considered the one with 8080.
PORT=8080

# The resolution to request on the camera sensor. Defaults to 1280x720.
WIDTH=1920
HEIGHT=1080

# The height to use for the video stream. Defaults to 720.
VIDEO_HEIGHT=720

# The height to use for the snapshots. Defaults to 1080.
SNAPSHOT_HEIGHT=1080

# The framerate to set on the camera. Defaults to 15fps.
FRAMERATE=15

# Additional options. By default enables continuous auto focus (if possible).
OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2" --camera-hflip=1 --camera-vflip=1'```

After days with this guide How to Control your Raspberry Pi Camera using a web UI I got a working interface for interacting with Pi Camera Modul V3 on RPi 5. Very, very happy! :stuck_out_tongue_winking_eye: