Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback for the new camera-streamer based webcam stack #2

Closed
foosel opened this issue Feb 22, 2023 · 203 comments
Closed

Feedback for the new camera-streamer based webcam stack #2

foosel opened this issue Feb 22, 2023 · 203 comments

Comments

@foosel
Copy link
Member

foosel commented Feb 22, 2023

👉 Latest image & feedback ticket can be found here 👈


OctoPi 1.0.0 is out, and I also have a new camera stack for you all to test!

Over the course of the past two weeks I've been setting up a CustoPiZer build script to swap the mjpg-streamer/webcamd combo on OctoPi that currently only supports the old legacy camera stack with a new camera-streamer and systemd based setup that supports libcamera (think RPiCam v3 as well as newer Arducams on top of the old ones). Some systemd magic takes care of camera detection, hotplug and even multicam support (successfully tested with two USB cameras and one RPiv3cam).

You can find the image here: https://github.com/OctoPrint/OctoPi-UpToDate/releases/tag/1.0.0-1.8.7-20230309160428. Image last updated on 2023-03-09 @ 16:50UTC!

Some first config docs are available here: https://faq.octoprint.org/camera-streamer-config

And finally, this is the source tree used for the build: https://github.com/OctoPrint/OctoPi-UpToDate/tree/camera-streamer

Please note

This image needs to be flashed to your SD card, wiping it in the process. So if you want to keep anything on there, make a backup first! You can also create an OctoPrint backup, download that, flash, restore from backup. There's no way to update to the contents of this image without a full reflash.

I hope to be able to merge this into the OctoPi-UpToDate main branch ASAP, after which it will become part of the OctoPi image distributed on the download page and RPi Imager, but some testing from others would certainly help here 🙂

Please provide feedback on your experience with this image in this ticket, whether things work for you or not. Make sure to at least include the following:

  • Everything working?
  • Pi model
  • used cameras
  • in case of issues: related logs (journalctl -u camera-streamer\* | pb and share the generated paste.octoprint.org URL)
@GitIssueBot
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/pi-camera-v3-imx-chipset-based-cameras-not-working/49022/101

@Draknars
Copy link

Draknars commented Feb 23, 2023

1: Everything working?

Bear in mind I am a total beginner and that just got my 3D Printer couples of days ago, but this image work perfectly for me. I was even able to seemlessly restore the backup of the default version I just had finished setting up yesterday. So far so good !

2: Pi model

Raspberry Pi 3 Model B Plus 1Gb (Rev 1.3)

3: Used Camera

Using the new Pi Camera V3 and the quality is amazing, I'm not even sure if my 200$ webcam is better than that. the autofocus is very responsive. I may play more with the settings but i've pluged the following in the libcamera.conf and it worked like a charm :

PORT=8080
WIDTH=1920
HEIGHT=1080
FRAMERATE=30
OPTIONS='-camera-options="AfMode=2" -camera-options="AfRange=2"'

Now I just need to print a mount for it...

I will be back if I encounter any issues or to report back on the stability, @foosel anything I should be looking for?

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

Mostly looking for data on first run experience and longer term stability 😊👍 Glad to hear it's looking great so far 🥳

@cp2004
Copy link
Member

cp2004 commented Feb 23, 2023

Some thoughts I did have....

Is it worth making the webcam streaming stuff something that can be updated in-place?

Mainly because this is relatively new, and there's a fair chance that we might find bugs or camera-streamer itself gets updated to fix issues. I guess updating camera-streamer itself would require a re-compile which could be harder to do (esp. on a Pi Zero, some issues were reported there with memory). But the scripts could change easily.

I know it would add additional complexity to something that I think should stay as simple as possible (to avoid chance for issues), but I could imagine that a small script could download a set of files from GH and overwrite them, maybe only if explicitly called with camera-streamer-control update for example.

Something that popped into my head, maybe worth a consideration for the future & try and prioritize getting this out for better camera support sooner rather than later. Interested to know thoughts.

Another point is what the logs look like. I'll give it a full poke at the weekend, but one of the most helpful parts of webcamd.log is to list the available devices, when it is in 'auto' mode to know whether a user's camera is properly connected, and I was wondering if this does a similar thing in it's logs? & it would be good to make the systeminfo bundle pick up these logs like it does webcamd through the Pi support plugin.

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

Is it worth making the webcam streaming stuff something that can be updated in-place?

Compiling this on-device for an update is definitely not going to be a good experience, it already takes quite long on CI, and even a few minutes on my beefier dev machine. I've been wondering if it might be possible to have a pre-compiled distribution available, but I'm worried about issues with dynamic linking, so this would probably have to be a static build. Actually something to look into in any case though because that would allow us to speed up the image build a TON again.

but one of the most helpful parts of webcamd.log is to list the available devices, when it is in 'auto' mode to know whether a user's camera is properly connected, and I was wondering if this does a similar thing in it's logs?

Currently not, but that's something that could be added. We have a bunch of systemd units to look out for now, camera-streamer, camera-streamer-libcamera, camera-streamer-usb@<name> and camera-streamer-usb-<name>.path. I guess adding some command camera-streamer-control status or something like that to output some information (basically libcamera & usb status, plus detected configurations), and have that become part of the systeminfo bundle might be helpful, on top of the logs?

it would be good to make the systeminfo bundle pick up these logs like it does webcamd through the Pi support plugin.

That's still on my TODO list actually, though so far without an actual issue on the tracker. Changed that: OctoPrint/OctoPrint-PiSupport#14

@b-morgan
Copy link

My LulzBot TAZ 6 printer is connected to an RPi 3B with an RPi camera V2 currently running OctoPi 0.18 and OctoPrint 1.8.6. It's not clear from the comments so far that this camera is supported by the new stack. I'd be happy to test it if you think it should work.

I also have an RPi 4B with an RPi camera V3 but no printer running a pre-release build of OctoPi 1.0.0. I will try the new image on this system and report back.

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

It should be supported, so please, test if possible.

Also edited the post up there to hopefully make that clearer.

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

To quickly cover a discussion point raised by "thecoda" under the configuration guide (where I'll remove it soon due to that being the wrong place):

Definitely a step in the right direction, though I think we're going to need some community work on camera-streamer to happen too.

For one thing I'm going to seriously miss the ability to rotate the image 180° if that's not supported, this is enough of a blocker that it almost prevented me from trying 1.0.0 at all. It also needs systemd unit files for both the HQ and v3 pi cameras to get optimal performance from these devices, both of which I imagine will be widely used.

To address these points:

I'm going to seriously miss the ability to rotate the image 180° if that's not supported

That is supported by adding -camera-vflip=1 -camera-hflip=1 to the OPTIONS (yes, both together indeed has the same result as a rotation by 180 degrees). Now also documented more clearly. What isn't supported as far as I can see is rotating by 90 or 270 degrees, but I can't say I expect there ever was much use of that to begin with (and if push comes to shove THAT can still be done within OctoPrint itself).

It also needs systemd unit files for both the HQ and v3 pi cameras to get optimal performance from these devices, both of which I imagine will be widely used.

It doesn't need more systemd files for that, that's why there are user-configurable conf files in the mix here, that come preconfigured to work with the majority of possible hardware out there. What we need are good examples for these, and the configuration guide will be a good place for sharing these.

@sergon2000
Copy link

sergon2000 commented Feb 23, 2023

1: Everything working?

Not able to see the video stream. Octopi works fine, I could restore a previous backup but no video stream. It says "Webcam stream loading" on the Control tab.
I realized the file /boot/camera-streamer/lib-camera.conf was not there so I created it with the following lines:

PORT=8080
WIDTH=1920
HEIGHT=1080
FRAMERATE=30

It still didn't work after restarting the raspberry.
Am I missing something? Thanks.

2: Pi model

Raspberry Pi 4 (2 GB)

3: Used Camera

Using the new Pi Camera V3 Wide NoIR.

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

I realized the file /boot/camera-streamer/lib-camera.conf was not there

It's supposed to be called /boot/camera-streamer/libcamera.conf, without a dash. Was that missing as well? If so, are you sure you flashed the right image, as in, the one linked above?

Can you please provide the output of libcamera-hello --list-cameras and also share the output of journalctl --boot -u camera-streamer-libcamera as well as journalctl --boot -u camera-streamer?

@sergon2000
Copy link

I realized the file /boot/camera-streamer/lib-camera.conf was not there

It's supposed to be called /boot/camera-streamer/libcamera.conf, without a dash. Was that missing as well? If so, are you sure you flashed the right image, as in, the one linked above?

Sorry, you were right... I flashed octopi-1.0.0-1.8.6-20230222095002 (instead of octopi-1.0.0-1.8.6-20230222114422), now both the video stream and snapshots work perfectly fine!

@b-morgan
Copy link

b-morgan commented Feb 23, 2023

First test on my RPi 4B... I used Raspberry Pi Imager 1.7.3 with the ...4422 image (verified with MD5) and changed the hostname to rpi4b (as octopi is being used by my other system). It appears that the hostname didn't get set. WiFi didn't get setup either.

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

How did you modify the hostname? octopi-hostname.txt as well as octopi-password.txt iirc had issues on the first boot with OctoPi 1.0.0 in general, that's not specific to this webcam stack modification, so if you did it through that, that would explain it. Noticed this during RC3 but decided to classify it as boy l not that critical since it works on any following boots.

@b-morgan
Copy link

I set the hostname, password, and WiFi settings in the RPi Imager. All of those settings failed. I believe they worked with the default Raspberry Pi OS image I have on another SD card.

I attached an HDMI monitor and a USB keyboard and used raspi-config to change the hostname and pi password. I edited /boot/octopi-wpa-supplicant.txt but that isn't working for WiFi. Without a network connection, there is little else I can do.

I'll see if I can find an ethernet cable.

@b-morgan
Copy link

This is pretty annoying every time I reboot: "A stop job is running for camera-streamer (20s / 1min 30s)". It finishes after the 1min 30s).

@b-morgan
Copy link

With an ethernet cable I was able to connect to the OctoPrint UI and finish the first time setup. The RPi V3 camera appears to be working.

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

This is pretty annoying every time I reboot: "A stop job is running for camera-streamer (20s / 1min 30s)". It finishes after the 1min 30s).

Ah, shoot, I thought that was caused by a bug I fixed since I could no longer reproduce it. Wasn't able to narrow it down to a specific setup either (too many variations the past two weeks), so now I know I should try to debug this against a v3 module. Thank you!

@b-morgan
Copy link

Any suggestions on how to fix the WiFi setup? I'm not going to attempt to test my RPi 3B / RPi camera V2 configuration unless I solve this problem. An ethernet cable is pretty much out of the picture as well.

You mention hotplug so I guess I should ask, if I take this SD card I've built for the RPi 4B / RPi camera V3, change the hostname (so DHCP server doesn't get confused) and move it to the RPi 3B, will it detect the V2 camera and configure it (properly to be determined 😄)?

@foosel
Copy link
Member Author

foosel commented Feb 23, 2023

Currently not, all I can say is that raspi imager worked just fine here so far with this. Actually even am now using the very same way to provision the images in my testrig (firstrun.sh) and this image wouldn't be there is that hadn't worked.

Would be interesting to know if you have the same issues with the stock 1.0.0, since this is something that definitely wasn't touched here either.

Has anyone else here seen issues with WiFi provisioning? 🤔

But to your second question, yes, it should

@sergon2000
Copy link

Has anyone else here seen issues with WiFi provisioning? 🤔

I also used RPi Imager to initially set up the WiFi credentials with no issue.

@paulmaunders
Copy link

paulmaunders commented Feb 24, 2023

I've just had a go with the new image, and it looks like the Raspberry Pi Camera Module 3 is working for me! I've not tried a timelapse yet, but I can see it in the preview. Autofocus and white balance all seems to be working great!

I manually configured the wifi settings in octopi-wpa-supplicant.txt

Here are the steps I took in case it's helpful for anyone...

Hardware:

  • Raspberry Pi 4 Model B 8GB.
  • Raspberry Pi Camera Module 3.
  • MacBook Air for image writing.

Steps:

## WPA/WPA2 secured
network={
  ssid="put SSID here"
  psk="put password here"
}
  • Save the file, unmount the SD card, install it in your Pi and then power on the Pi.
  • Access OctoPrint via http://octopi.local/ configure the necessary settings, or restore backup.
  • Finally, test the webcam is working at http://octopi.local/#control

Screenshot 2023-02-24 at 11 43 41

@b-morgan
Copy link

After writing the 4422 image on the SD card, I checked/copied the firstrun.sh file in /boot. I inserted the image in my RPi 4B and powered it on. The hostname, password, and WiFi credentials were not set. I shutdown from my attached keyboard, moved the SD card back to my desktop, and firstrun.sh was still in /boot. Since the last line or so is "rm -f /boot/firstrun.sh", I am assuming that firstrun.sh didn't get executed.

Next I'll try the 5002 image which should be the official 1.0.0 version.

@b-morgan
Copy link

Using the exact same steps with 5002 image was successful (i.e. firstrun.sh was executed and deleted). I'm using the same SD card for both images and I compared the firstrun.sh files from both with the only difference being the (I assume hashed) password for the user Pi.

@GitIssueBot
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/arducam-autofocus-camera-not-working/50019/5

@foosel
Copy link
Member Author

foosel commented Feb 24, 2023

@b-morgan I honestly have no clue what's going on there, because as I said that is exactly the kind of configuration approach I used for provisioning myself for probably now hundreds of times while creating the new camera stuff to begin with, and I didn't have an issue even once. And from the comments up there it looks like it works for others as well.

This is honestly baffling to me, especially since the modifications made here literally don't touch this, even OctoPi's build script doesn't touch this.

@b-morgan
Copy link

Just for the hell of it I switched to a different SD card (64gb->32gb) and it worked! Previous card still has the 1.0.0 release on it and it works as well. Now to try the change hostname and boot on my RPi 3B connected to my real printer!

@b-morgan
Copy link

Success of sorts. The camera works but the resolution is way different than it was before. I'll have to figure out what my old settings were and see if I can duplicate that image. I guess I should re-image the SD card and try from scratch just to verify (but I'm not moving my keyboard and monitor so it better work 😃 )

@TrainorEC
Copy link

Kind of works. Using a Raspberry Pi camera module 3 wide angle version. Image quality is clear, but does not seem to be picking up the full wide angle field of view. Appears to be showing a regular field of view. I initially had this issue with RC3 build, but can't remember what was the fix that allowed to get wide angle field of view. I'm still messing with settings.

Besides the the field of view issue. Everything else seems to be stable.

Using:
Raspberry Pi 4b
Raspberry Pi Camera Module 3 Wide

@GitIssueBot
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/arducam-streaming-for-octo-and-obico/50789/1

@GitIssueBot
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/add-support-for-raspberry-pi-camera-v3/49052/7

@davidsbright
Copy link

Everything working fine: Absolutely
Pi model: Pi 4 Model B 8GB RAM
used camera: Raspberry Pi V3, 75° angle, NoIR

I downloaded the files and flashed the Raspberry and everything worked fine,
I didn't change anything because the default settings worked perfectly
If I'll ever change anything and/or customize something I'll make sure to post the files.

In case anyone is curious, yes you can use the "AWM 20624 80C 60V VW-1" longer cables used for the V2 with the V3 so you are not stuck with a 15 cm stock cable hehe.
Thank you again for this post!

@flipside101

This comment was marked as off-topic.

@Nevio024

This comment was marked as off-topic.

@davidsbright
Copy link

I don't know if this can help but this is what i have done:
First make absolutely sure that the cable is well connected to the board and the camera, and in the RIGHT slot, i've seen many cases that since there are similar camera slots people messed it up, but it can happen, and checking it out doesn't take too much time.
I had the v3 module already connected to the raspberry, i flashed the zip file from this post and made sure that
"Enable SSH" was active
"Configure Wireless LAN" was active as well.
Flashed the sd card, then put it in the raspberry and after a while the raspberry started and loaded the octoprint.
If you need any help with other steps let me know

@ayufan
Copy link

ayufan commented Mar 28, 2023

@Nevio024 @flipside101 Start with adding to /boot/config.txt the dtoverlay=imx519. If you have AF version it will not have auto-focus yet, but lets ensure that this works first.

@Nevio024
Copy link

I don't know if this can help but this is what i have done:
First make absolutely sure that the cable is well connected to the board and the camera, and in the RIGHT slot, i've seen many cases that since there are similar camera slots people messed it up, but it can happen, and checking it out doesn't take too much time.
I had the v3 module already connected to the raspberry, i flashed the zip file from this post and made sure that
"Enable SSH" was active
"Configure Wireless LAN" was active as well.
Flashed the sd card, then put it in the raspberry and after a while the raspberry started and loaded the octoprint.
If you need any help with other steps let me know

Cables are plugged in right. I used SSH a few times and for SSH you need wifi anyways. You need to install some special drivers (https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Quick-Start-Guide/ scroll down until you see imx519). Do I just install the image and then do the commands written there?

@Nevio024
Copy link

@Nevio024 @flipside101 Start with adding to /boot/config.txt the dtoverlay=imx519. If you have AF version it will not have auto-focus yet, but lets ensure that this works first.

Is this the only thing I need to add to get it to work? And in what order do I need to install everything? Is it necessary to install the special drivers? (https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Quick-Start-Guide/)

@foosel
Copy link
Member Author

foosel commented Mar 28, 2023

For the sake of not having this ticket drown in hardware specific discussions, can y'all please take this "how do I get Arducam to run" to the community forums please? 😅 You are welcome to link back to here to make things easier discoverable.

@ayufan
Copy link

ayufan commented Mar 28, 2023

@Nevio024 Not, if you have FF camera. If you have AF, you not only need to install their drivers, but also recompile camera-streamer.

@Nevio024
Copy link

Nevio024 commented Mar 28, 2023

@Nevio024 Not, if you have FF camera. If you have AF, you not only need to install their drivers, but also recompile camera-streamer.

I have the camera with autofocus, but I'm fine if it doesn't work. What do I need to do?

@Nevio024
Copy link

For the sake of not having this ticket drown in hardware specific discussions, can y'all please take this "how do I get Arducam to run" to the community forums please? 😅 You are welcome to link back to here to make things easier discoverable.

👍
Where do I find the thread?

@GitIssueBot
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/discussing-the-new-camera-streamer-based-webcam-stack-for-octopi-currently-in-development/50866/1

@foosel
Copy link
Member Author

foosel commented Mar 28, 2023

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/discussing-the-new-camera-streamer-based-webcam-stack-for-octopi-currently-in-development/50866/1

There.

@Nevio024
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:
https://community.octoprint.org/t/discussing-the-new-camera-streamer-based-webcam-stack-for-octopi-currently-in-development/50866/1

There.

Thanks!

@foosel
Copy link
Member Author

foosel commented Mar 28, 2023

FYI, raspberrypi/linux#5390 is currently blocking the new build. I'm trying to see if there's a workaround.

@Nevio024
Copy link

@ayufan @ianez1109 This is a link to my post in the forum: https://community.octoprint.org/t/discussing-the-new-camera-streamer-based-webcam-stack-for-octopi-currently-in-development/50866/2?u=nevio_024

I'd be really glad, if you could help me there.

@foosel
Copy link
Member Author

foosel commented Mar 28, 2023

New image is out (found a workaround for the blocker mentioned above), see #3 for info and feedback.

Closing this ticket as it has become unwieldy, will now create a new one for each test image.

@PanMan88
Copy link

1: Is everything working? YES

libcamera.conf set to:
PORT=8080
WIDTH=1920
HEIGHT=1080
VIDEO_HEIGHT=720
SNAPSHOT_HEIGHT=1080
FRAMERATE=30
OPTIONS='-camera-options="AfMode=2" -camera-options="AfRange=2"'

2: Pi model
Raspberry Pi Zero 2W

3: Used Camera
Pi Camera V3

Just for interest sake, flashed the image, set it up as new then updated to the latest 1.9r3 dev for a test case and everything is still working... Great job.

@cp2004
Copy link
Member

cp2004 commented Apr 11, 2023

@PanMan88 FYI, this issue is closed & as such the build linked is outdated, the latest build can be found in #3

@YuriMri
Copy link

YuriMri commented Jun 7, 2023

Hello,
I installed latest octopi with camera stack today and I cannot find the option to crop/uncrop or to set the resolution for the camera.
It seems like I can take pics for timelapse in 3280x2464px resolution from the camera specs (I have CSI connected Raspicam v2.1).

libcamera-hello --list-cameras gives me:

Available cameras
-----------------
0 : imx219 [3280x2464] (/base/soc/i2c0mux/i2c@1/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [30.00 fps - (0, 0)/0x0 crop]
                             1640x1232 [30.00 fps - (0, 0)/0x0 crop]
                             1920x1080 [30.00 fps - (0, 0)/0x0 crop]
                             3280x2464 [30.00 fps - (0, 0)/0x0 crop]
           'SRGGB8' : 640x480 [30.00 fps - (0, 0)/0x0 crop]
                      1640x1232 [30.00 fps - (0, 0)/0x0 crop]
                      1920x1080 [30.00 fps - (0, 0)/0x0 crop]
                      3280x2464 [30.00 fps - (0, 0)/0x0 crop]

contents of my /boot/camera-streamer/libcamera.conf is

PORT=8080
WIDTH=1920
HEIGHT=1080
VIDEO_HEIGHT=720
SNAPSHOT_HEIGHT=1080
FRAMERATE=15
OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2"'

but my /?action=snapshot is in resolution 1920x1056px and /webcam/?action=stream is in 1312x736 resolution and both are CROPPED.
My timelapse came out in 1920x1056px at 60fps

When I change it to something else, like:

PORT=8080
WIDTH=3280
HEIGHT=2464
VIDEO_HEIGHT=1080
SNAPSHOT_HEIGHT=2464
FRAMERATE=15
OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2"'

my /?action=snapshot is in resolution 1920x1440px and /webcam/?action=stream is in 1472x1088 resolution and not sure if cropped (but seems much better).
My timelapse came out in 1920x1440px at 60fps

I cannot find the logic with the settings entered and outputs.
Is this a bug?

@ayufan
Copy link

ayufan commented Jun 7, 2023

@YuriMri

The HW encoder on Raspi can encode max 1920x1920. So the resolutions will always retain aspect ratio.

Those width/heights are translated into those settings. They are described in more detail in here: https://github.com/ayufan/camera-streamer/blob/master/docs/configure.md#resolution

@foosel
Copy link
Member Author

foosel commented Jun 7, 2023

I suggest to take this discussion to the current feedback ticket #6 - this one is about preview versions available from February to March, before I switched it over to individual tickets per build*.

I'm locking this and all other closed feedback tickets to not spread the discussion across multiple threads.

(* Yes, I'm aware the build number is too difficult to determine at the moment, I'm working on that)

@OctoPrint OctoPrint locked as resolved and limited conversation to collaborators Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests