-
Notifications
You must be signed in to change notification settings - Fork 81
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
error with v4l2ctl focus settings (Logitech C920) #96
Comments
Hey there, First of all, as I do not own this camera it is hard to reproduce for me, which makes it impossible to fix. But...
these to lines already tell you what is going on here. These Logitech Cams (C920, C922, C930e) are known to have issues in firmware and there where several tries fron linux kernel devs to workaround those issues. The camera simply refuses to set those parameters at runtime. Currently those parameters are set before ustreamer starts, and the "brokenfocus" fix already tries to re-set those values after ustreamer is started. But if the camera wont let you set these values, for what ever reason, it fails which is intended. So its hard to say but I cant help you here, simply because I need the exact same model and firmware of your cam to reproduce and develop a workaround. Maybe @zellneralex has an idea here. |
No I have no other idea. We would need to have that cam to do further investigations. @KwadFan is v4l2ctl: focus_automatic_continuous=0,focus_absolute=30 maybe the problem here. |
So, @dmnkhhn |
I have the same C920. Had the exact same issue. Changing focus_auto=0 to focus_automatic_continuous=0 solved it for me. |
Thank you for this, it has solved my problem! |
This also fixed it for me, thank you. For the next person here, there is no spacing in the config file, i.e. v4l2ctl: focus_automatic_continuous=0,focus_absolute=20 Also interesting, I have been running 2 of these cameras for 12+ months without issue, something changed recently to have caused this to begin crashing. |
My experience with the C920 camera is that the firmware in the camera refuses to set the exposure and focus values if the corresponding feature is configured to be automatic. This includes the case where one command line tries to change those features from auto to manual mode and adjust the value at the same time. Results can vary over time in a session if you've managed to change the mode beforehand after which the value setting is likely to take. Before moving to Klipper+crowsnest I had to run two distinct commands in v4l2-ctl --set-ctrl=auto_exposure=1,focus_automatic_continuous=0,white_balance_automatic=0,power_line_frequency=1
v4l2-ctl --set-ctrl=exposure_time_absolute=200,focus_absolute=40,white_balance_temperature=4395 I can't find any way in One interesting side note is that the
|
V4L2 Control: Parameter 'focus_automatic_continuous=0' not available for '/dev/video0'. Skipped. Not an option for me |
it seems to fail to apply when done to quickly. it works perfectly when edited in the shell. and never falters till I restart the Pi |
There is no "option" if v4l2-ctl does not list that parameter for your device crowsnest/libs/v4l2_control.sh Line 47 in 20ed6a8
|
As you can see here crowsnest/libs/v4l2_control.sh Line 41 in 20ed6a8
It sets the values in a for loop, so each paramater after another. You could try to add a sleep state but it will delay its startup anyways. So, there is not much I can do if the Firmware is simply to slow to except settings in a small time frame. Besides, that for all users that are not affected by it have to wait even unnecessary longer to come up. I cant test changes because I do not own any Logitech Cams. So feel free to add a PR with a fix. |
None of the above methods of solving this problem helped me, so I went ahead and found a way in which they add a file to the directory /etc/udev/rules.d/99-video-c920.rules, but the configurations described there also did not apply. I searched again and found this archlinux I checked the device id and replaced it with the necessary parameters and hooray, everything worked for me! I hope this method will help someone) |
For anyone coming from google this may not be just a C920 issue. I have a C615 and had the exact same issue, along with the same solution. This started happening after a dist-upgrade on the klipper host - so I'm guessing either the v4l2 binary changed or the driver interface. In any case - wanted to share that this solution may work for other Logitech cameras |
Thanks for reporting, the funny thing is I do nothing other than udev rule ^^ Will think about implementing a custom_script thingy. Hold up, will take time... |
How did you made the changes? Could you please direct me on the right way? |
This is the cam section of my crowsnest.conf file, specifically pay attention to the last line: [cam 1] enable_rtsp: false Play around with |
Came here to create a report but it looks like people are finding the same thing I did. Setting focus_absolute however is ignored when set on the same line in crowsnest: If I manually run from SSH: The camera comes into focus perfectly! pi@mainsailos:~ $ sudo v4l2-ctl --device=/dev/video0 -c focus_automatic_continuous=0 I am guessing this is where crowsnest is dying. It's not able to turn off autofocus and THEN set a focal distance, it's trying to set a focal distance and disable autofocus simultaneously. |
Hi, After reading this thread I've changed the settings on Crowsnest to: but the trick was to use multiples of 17 for the focus_absolute (actually is what is suggested in crowsnest.log: "min=0 max=255 step=17 default=51 value=51 flags=inactive"), so using eg. 55 does not work, and returns the broken focus message. |
For the C920 my log reveals the following: It looks like a step size of 5 . I was not having issues related to step size though and my final value would be 55 if it functioned. If there was some way to send multiple commands sequentially or with delay with crowsnest I think the problem could be solved that simply for many. |
I'm not ready to submit a PR with a fix yet, but I have some more information about the issue and an approach that fixed it for me.
First, this issue isn't specific to Logitech cameras. I'm using this camera and having the same issue trying to set the focus in one line via Here's what I see happening: In ustreamer.sh it starts up ustreamer via the run_ustreamer function (each function call in its own thread) for each configured camera, and then calls the run_mjpg() {
local cams
v4l2_control
cams="${1}"
for instance in ${cams} ; do
run_ustreamer "${instance}" &
done
blockyfix
brokenfocus
return
} The issue is that I added some logging output to
Without the One approach is to ensure that at least one ustreamer process has actually started before calling brokenfocus: run_mjpg() {
local cams
v4l2_control
cams="${1}"
for instance in ${cams} ; do
run_ustreamer "${instance}" &
done
# Wait for at least one ustreamer process to start
while ! pgrep -f "ustreamer" > /dev/null; do
log_msg "Waiting for ustreamer process to start..."
sleep 0.2
done
blockyfix
brokenfocus
return
} "It works on my machine" but I'm focused on getting one camera to work with ustreamer. This may not work properly when multiple cameras are configured, or if any ustreamer process is running outside of Crowsnest.
Additional ideas:
|
Good to see that someone is working on this and having some good ideas on doing so😄❤️
This should be considered for a fix. I have already seen quite some setups with two cams with one or more Logitech cams. So only checking for one instance can make problems there.
Just ignore such a case. You cannot achieve a satisfying solution for all edge cases. The chances of someone running ustreamer and Crowsnest simultaneously should be considered pretty low or equal to zero.
I don't think this would be possible. Have a look at the last few lines of ustreamer.sh. There it starts the streamer and if it fails it will log an error. So for this you would need some completely different method of catching an error with the streamer. Currently it's checking if line 76 & 77 are "finished". If they are finished there is a problem with the streamer and the streamer process failed.
This might be the best solution for this. We already did some testing on detecting running streaming instances for some other thing. It seems like we have forgotten about So overall the code you attached seems already very promising and we would be happy about a PR with the support for multiple instances. |
The added wait state also works on my machine and I can now set focus_absolute value for my random webcam (Microsoft®_LifeCam_HD-6000). Thank you! |
Not working here, apparently the brokenfocus function is never executed and so my focus is never set, and always ends up returning to the webcam's default focus, I never get the message WARN: Detected 'brokenfocus' device |
@Obagunceiro What is not working for you? The "fix" provided by jwyse? The |
Both aren't working, the fix doesn't work and probably in my case it's because the function isn't called, and I searched all over the internet, tried to make small changes myself to solve the issue But without success, as this issue is still open, I thought I could try to discuss it here too, and considering that I believe the root of the problem is something else, I opened another issue, containing all the details that I think are important in principle about this new problem. |
The function is called, as you can see in your log. Just at the moment of the function call it's still the value it got set too. So for this "fix" to work for you, you might need to increase the delay. But I won't give any support on this, as it's not my code. I can assure you that we will try to fix this in future. |
Hi. need help setting up focus value. `User Controls
Camera Controls
` I have such option, but when setting: Could you pelase help guide me throu changes in the file you mentiond ? where is this file ? |
@Adblu please don't ask for help in any issues. If you want some help, join our Discord or use our GitHub discussions. But before you go to get help read everything in this message. As this code modification isn't official, we don't give support on it, and I don't reocmmend to do it, if you cannot even find the file it's in on your own. |
The parameter `focus_auto` is no longer working. When we run: v4l2-ctl --device /dev/web-c920 --set-ctrl=focus_auto=0 We get: unknown control 'focus_auto' It seems that the parameter is now named `focus_automatic_continuous`. See mainsail-crew/crowsnest#96
The parameter `focus_auto` is no longer working. When we run: v4l2-ctl --device /dev/web-c920 --set-ctrl=focus_auto=0 We get: unknown control 'focus_auto' It seems that the parameter is now named `focus_automatic_continuous`. See mainsail-crew/crowsnest#96
FWIW, the fix by @jwyse worked for me too. It's a no-name 8MP auto focus camera in the narrow "Angrycam" format from Amazon. |
FWIW, I made use of gcode_shell_command and created a little ecosystem that automatically sets focus after startup (which is what wasn't working for me) and it also creates a macro with focus value parameter that you can send from the console. If you're interested: |
What happened
If I use the examples from the manual to control my Logitech C920 Camera I get this:
With this line in my config I get this output in the log:
Maybe a firmware update changed those parameters?! The (newly?) available controls are:
If I update my configuration and set
v4l2ctl: focus_automatic_continuous=0,focus_absolute=30
, which works when setting it manually from the command line, the following appears in my log:Now crowsnest will start again, but it gets the same error and it goes on repeat and after a short while the Pi is almost overheating.
TL;DR
As soon as I set the focus parameter (new or old) the
brokenfocus
device warning comes up and crowsnest continuously restarts.What did you expect to happen
I would expect the
v4l2ctl
setting to work properly with the updated parameters for my Logitech C920How to reproduce
v4l2-ctl -d /dev/video0 --list-ctrls
focus_automatic_continuous
parameter to0
focus_absolute
parameter to something between 0 and 250Additionally you could set those parameters from the command line to see if they work at all:
v4l2-ctl -d /dev/video0 -c focus_automatic_continuous=0
v4l2-ctl -d /dev/video0 -c focus_absolute=125
Additional information
The text was updated successfully, but these errors were encountered: