Hello, i bought an china cam From Amazon, the cam has an Autofocus which works good enough on windows, but every time I restart the Printer it doesn't focus my Printbed but the Background, it doesn't even focuses something else. if i unplug it, put it in my PC, focus the Printer, and plug it back in the printer it uses the Focus from windows, but if i restart the printer its unfocused again. I use Crowsnest.conf, deactivating the Autofocus via v4l2ctl doesn't work
#Cam has Autofocus but it doesnt focus and i cant deactivate it
50 messages · Page 1 of 1 (latest)
[05/05/23 20:14:30] crowsnest: V4L2 Control: Parameter 'focus_auto=0' not available for '/dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._USB_camera_000000000001-video-index0'. Skipped.
[05/05/23 20:14:30] crowsnest: V4L2 Control: Parameter 'focus_absolute=32' not available for '/dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._USB_camera_000000000001-video-index0'. Skipped.```
Please send your whole crowsnest log
As this part only tells me that you cannot control it with the parameter you try to use
The only parameters available through v4l2 are
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=64 step=1 default=32 value=32
saturation 0x00980902 (int) : min=0 max=128 step=1 default=64 value=64
hue 0x00980903 (int) : min=-40 max=40 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=0 value=1
gamma 0x00980910 (int) : min=72 max=500 step=1 default=72 value=72
gain 0x00980913 (int) : min=0 max=100 step=1 default=0 value=0
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=2 value=2
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=6 step=1 default=2 value=2
backlight_compensation 0x0098091c (int) : min=0 max=2 step=1 default=1 value=1
```Without knowing your exact cam it's hard to say if it's maybe just a driver thing that windows can focus and linux can't.
The restart will most likely reset the settings stored on the cam and therefore setting the focus into the distance.
Is there an way to disable the Autofocus?
Doesn't seem like v4l2 can do it. Can you send a link to the cam? Maybe I can find something on the product site
Some cameras will behave in a simliar way to the Logitech C920 where depending on what is set on V4l2 when it is first called the autofocus setting will be reported as if it simply isn't available on the camera despite that not being the case. Trying V4L2 focus_automatic_continuous = 0 instead in the crowsnest configuration may solve it but if not try running v4l2-ctl --set-ctrl=focus_auto=0,focus_absolute=0 manually from the terminal or as a last resort setting up the V4L2 resolution ,framerate and focusabsolute within the udev rule may do it in a similar way to the Prusa https://gist.github.com/ndoo/d34762aabb060a1f40848450dab7c1e7
If none of those work then it may literally just be that the camera doesn't support it but it's been a problem people have run into with various rebranded cameras so I'd expect one of them to work. I nearly replaced my C920 before I got this fixed
Doing it within crowsnest is the easiest solution obviously but it sounds like by that stage V4L2 has decided that function simply isn't available when I'd be surprised if it wasn't
crowsnest.conf I should say
Also worth noting that BTT didn't include the graphics driver in the kernel for the Allwinne in the CB1, it was mainly used in Android TV boxes for Kodi etc so hardware decoding and encoding of x264 is something that the board can do but I'm not holding my breath for BTT fixing it themselves. Maybe not a problem if an mjpeg stream from crowsnest is all you want but I think once updates start coming in for the camera streaming and more CB1s are in use it will become an issue, hopefully BTT won't wait for the users to fix it for them though
Ive used v4l2ctl: focus_auto=0,focus_absolute=32 in my crowsnest config which didnt worked, do you mean i should insert V4L2 focus_automatic_continuous = 0 in the terminal or in crowsnest?
Try replacing it with v42l-ctl focus_automatic_continuous in crowsnest.conf on its own first, then try it from a terminal to see what the error is. you might need to stop the croswsnest process if it’s using the resource already (it may not release it correctly which is a v4l2 problem rather than crowsnest, giving the same error or “resource busy” There’s a few other things to try but I’d need to look at my config to get it, once the camera is set up by any process using v4l2 it can get locked until reboot, and depending on the settings used this can cause it to report that specific settings aren’t supported when they are, problem is these might be being picked up by whatever dev rule rhe cb1 is using for that camera which can be fixed but is a bit more fiddly to fix. I’d need to check my crowsnest log log too to see if it has trouble seeing the camera so many times before finding it but I’d say it’s almost certainly a v4l2 problem which has always had things like this happen since I’ve used it
And bad focus is usually exactly the symptom of it
One thing to try if you have a spare sd too is install the minimal OS from btt, then update but don’t install Klipper etc, the. Try the v4l2 commands from a terminal. That’s how I was able to test the camera did actually work on the cb1 and focus settings could be set correctly
From there you can set up a local webcam stream and test it on VLC on another machine on the network but I can give you the command to to it if needed ,it’s annoying but I’m pretty sure it should be fixable, just narrowing it down can be a bit if trial and error
I’ll check my config in the morning and let you know if that’s cool, it may well not be doable but it’s just so close to problems I’ve had and seen others have that I think it should be fixable. V4l2 I always expect to have to troubleshoot when its used anywhere with usb cams
From the console
with v42l-ctl focus_automatic_continuous in crowsnest
Sorry I've got caught up with work stuff so haven't been able to dedicate as much time as I usually would to tinkering with the printers, I do think this should be fixable though
Have you been able to set focus manually at all?
No, except if I put it on my Win PC, Focus it and put it back in the printer, than it's focused but if I restart it resets
if you ssh onto the CB1 and run "v4l2-ctl -d /dev/video0 --list-ctrls" what does it say? Logitech firmware does that wonder is it a direct clone
'''biqu@BTT-CB1:~$ v4l2-ctl -d /dev/video0 --list-ctrls
User Controls
brightness 0x00980900 (int) : min=0 max=255 step=1 default=128 value=128
contrast 0x00980901 (int) : min=0 max=255 step=1 default=32 value=32
saturation 0x00980902 (int) : min=0 max=255 step=1 default=53 value=53
hue 0x00980903 (int) : min=-180 max=180 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=180 max=250 step=1 default=180 value=180
gain 0x00980913 (int) : min=0 max=255 step=1 default=0 value=0
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=2 value=2
white_balance_temperature 0x0098091a (int) : min=2770 max=6550 step=1 default=4000 value=3522 flags=inactive
sharpness 0x0098091b (int) : min=0 max=255 step=1 default=0 value=0
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=0 value=0
Camera Controls
auto_exposure 0x009a0901 (menu) : min=0 max=3 default=3 value=3
exposure_time_absolute 0x009a0902 (int) : min=1 max=-1 step=1 default=166 value=1000 flags=inactive
exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=0'''
Nothing with autofocus
is v4l-utils installed or can you install it on the CB1? I've mine shut down atm so can't check, there's some debug tools that you might be able to use to force it but really it sounds like a firmware issue that might be more trouble to fix than it is worth, the Logitech cameras that it appears to be a clone of do this but the functionality could well be missing entirely from the webcam
the firmware in the logitech ones has gotten worse over time so I'd imagine the clone type cameras are the same
opening the camera up and modifying it to fix the focus would probably do it as well but it'd be like cracking a walnut with a sledgehammer
that was my first thought, just bridge the chip for the focus, then it occurred to me that i have absolutely no plan what i'm looking for in there😂
I would just switch to one of the Pi cameras if it were me tbh, shame the CB1 doesn't support them but the fact that there is so much stock of the Pi 4 at Pimorani makes me wonder if we really are getting back to normal availability at last
I have an pi cam and it worked on my Marlin setup with an raspi 3b but on the cb1 it doesnt worked
One thing that might be worth doing is uninstalling crowsnest just to see if there is any difference in what V4L2 reports
This won't help anyhting. Only thing you could try instead would be to disable legacy camera stack
Crowsnest doesn't do anything except for enabling legacy camera stack but it doesn't deactivate it on uninstall
The camera that's a clone of is quite particular as to what it will and won't do depending on what happens during boot
Everything else of crowsnest are just scripts to call some executables
It's the timing of those executables being called that I'd be checking, problems like this are why I rarely use the C920
Then just disable the crowsnest service and don't uninstall it
Disabling it first would be a better idea for sure. Also the image that BTT provide with Klipper etc preinstalled I wouldn't use, the minimal-OS version then install with Kiauh is the one that got the C920 working for me on the CB1
Legacy camera stack is for Pi boards isn't it?
Yes, but it could be possible that it makes some problems with other cams too
We don't know why that happens
Yeah anything even remotely related to camera functionality is worth testing, it's possible that since it looks very much like a Logitech clone the firmware is a bit crap
But knowing clones what it can do and what it reports it can do could be two different things entirely
The C920 I've only now got working reliably since I changed to powering the CB1 from pins on the SKR Rat rather than usb-c so that might even be worth a go but there's a point where just replacing the camera with one reported as working correctly makes more sense
I'd be sprised if BTT didn't come up with a camera that works with the CB1 without lots of fiddling about. a rebranded endoscope or something similar. But the fact this issue is so similar to what I had with the Logitech camera makes me think it could be an inherited bug from their firmware
what does v4l2-ctl --all give you? I'm currently messing about with my Logitech connected to the CB1 but it's such a pain that I might just put it back on the Pi 2 B or Pi Zero 2 , either that or or set up a docker on the server to do it. The lack of documentation on the CB1 doesn't help at all, I managed to get a Pi 4 today so when/if I have it that will be taking over