FormerLurker / Octolapse

Stabilized timelapses for Octoprint
GNU Affero General Public License v3.0
634 stars 99 forks source link

Parameters not applied at boot, nor at print start with PI4 and Logitech C920 #676

Open deejay2 opened 3 years ago

deejay2 commented 3 years ago

If this is a feature request describe it here

Request

Version of Octolapse

Octolapse Version: 0.4.1

Version of OctoPrint

OctoPrint Version: 1.5.3

When you ran into the problem, did you have diagnostic logging enabled?

Diagnostic Logging was Enabled: No

What were you doing when the problem occurred

1) I'm booting the Pi. 2) I'm going to the dashboard to see my webcam stream 3) I see my parameters are not applied 4) I start a print 5) I see my parameters are not applied 6) I go in Octoprint's "Image preferences" and click "Apply All Settings Now" 7) I see my parameters are applied.

Note that in "Custom image preferences", I have all 3 options checked to apply preferences at every possible moments.

What should have happened?

Preferences should be applied right after boot.

What happened instead?

The image doesn't appear with my parameters applied (out of focus, too bright..)

Operating System running OctoPrint and Octolapse

OS Name: OctoPI Os Version: 0.18.0

Printer model & used firmware incl. version

Printer Model: _REPLACE_THISPRINTER_MODEL_GOES_HERE Printer Firmware Version: _REPLACE_THISPRINTER_FIRMWARE_VERSION_GOES_HERE

Browser and version of browser, operating system running browser

Browser: _REPLACE_THISBROWSER_VERSION_GOES_HERE Browser OS: _REPLACE_THISBROWSER_OS_GOES_HERE

Link to the gcode file you were printing when the problem occurred

Link to Gcode File: _REPLACE_THISGCODE_FILE_LINK_GOES_HERE

Link to settings.json

Link to settings.json with all passwords removed: https://gist.github.com/deejay2/a12719fbbe3d910d7174881bffcdb779

Link to plugin_octolapse.log

Link to plugin_octolapse.log: https://gist.github.com/deejay2/1a7fb13726466dced88102a16b0059bb

Link to octoprint.log

Link to octoprint.log: https://gist.github.com/deejay2/7af8bcd18d5182e0a51f8280b66a127d

Link to contents of Javascript console in the browser

Link to javascript console output: _REPLACE_THISLINK_GOES_HERE

Screenshots and/or videos of the problem:

Screenshot/Video Links: _REPLACE_THISLINKs_GO_HERE

Please consider becoming a patron

If you like this project, please support my work by becoming a patron, and consider adding a 'star' to the repository. It takes a lot of time and effort to maintain the project and respond to issues. The cost of test prints, software, cameras, printer parts, etc. can quickly add up, so every bit helps.

You can find various videos and tutorials by subscribing to my Youtube channel. You can also follow me on Twitter.

FormerLurker commented 3 years ago

Please attach your settings.json file. Looks like your pi is refusing the connection for some reason. do you have any fancy proxy or security added? Also, are you using the loopback address (127.0.0.1) for your webcam?

deejay2 commented 3 years ago

Nothing fancy added.. I added the settings.json link.

Yes I'm using 127.0.0.1:8080 as camera base address.

deejay2 commented 3 years ago

Maybe this can help?

pi@octopi:~ $ dmesg |grep uvc [ 5.325040] uvcvideo: Found UVC 1.00 device HD Pro Webcam C920 (046d:082d) [ 5.347416] usbcore: registered new interface driver uvcvideo [ 23.146378] uvcvideo: Failed to query (SET_CUR) UVC control 6 on unit 1: -32 (exp. 2).

deejay2 commented 3 years ago

I may be wrong but since it's working when clicking Apply settings, I guess it's an issue with the camera initialization or something causing delay before anything can access it...

Unfortunately I don't really know how to debug this :/ Does anybody else have a PI 4 8GB with C920 Pro on Octopi 0.18.0 ?

Does octolapse get any feedback when trying to apply settings? If so, maybe it could run a loop like one try per 10 seconds until successful?

FormerLurker commented 3 years ago

Makes sense, except why doesn't it work at the start of a print?

Darkknight33 commented 3 years ago

Came here because I'm seeing this issue too. The control panel has the right settings, but needs to be manually changed at least once to correctly apply the focus correctly after a reboot.

aeridus commented 3 years ago

I'm getting the same exact issue, with OctoPrint Version 1.6.0 and Octolapse Version 0.4.1. I have a C920S. Any time the Pi reboots, the settings do not apply either on OctoPrint start or starting a 3d print. I have to move the slider and hit Apply before the focus changes before every first print after reboot, and of course save to keep it set.

aeridus commented 3 years ago

It does seem like focus is properly retained when it's just OctoPrint restarting, so the issue is specific to the Pi 4 rebooting.

FormerLurker commented 3 years ago

OK, I just got a pi 4, so I will give it a go. The only thing I can think of is that there is a race condition at startup that doesn't happen with a Pi3 or below. Either Octoprint is starting up faster than it used to, or mjpgstreamer is starting slower (or both).

The funny think is I added a retry for this feature (apply settings on boot). It is supposed to try to apply the settings, wait on failure, retry, then double the wait and try again. This happens for, I believe, 2 minutes total.

Will let you know what I come up with.

mapotter99 commented 3 years ago

I have a Pi 4B 4GB and a C920. I'm new to ALL of this... 3D printing, Raspberry Pi, Linux, you name it. But I've learned a ton!

I'm able to enable custom image preferences. When I go to change the camera settings, "switch to custom page" fails, which I find odd, considering @FormerLurker uses a C920 in his video.

I'm hoping this related, but if not, feel free to move this somewhere else. Thanks! :-)

FormerLurker commented 3 years ago

So, my initial testing went OK on the pi 4. I think there must be a firmware change on newer c920s, so I'll just need a copy of input.json from your camera to see what the deal is. Navigate to http://{IP_OF_PI}/webcam/input.json, paste the results to gist.github.com, and drop a link in here. That should allow me to get the detection working.

aeridus commented 3 years ago

So, my initial testing went OK on the pi 4. I think there must be a firmware change on newer c920s, so I'll just need a copy of input.json from your camera to see what the deal is. Navigate to http://{IP_OF_PI}/webcam/input.json, paste the results to gist.github.com, and drop a link in here. That should allow me to get the detection working.

https://gist.github.com/aeridus/ce8a3eae92e47e7bf131f2228e6aa8e1

Mine is the C920S which has newer hardware compared to the C920, if that makes any difference.

FormerLurker commented 3 years ago

Mine is the C920S

It apparently DOES make a difference. I'll get that updated. Note that the page you are getting will contain 100% of the functionality, it just won't have the nice UX I added, which just makes it easier to use.