Can you modify camera settings while libcamera is running?

With the older V1 and V2 standard Pi cameras, using v4l2-ctl, it was possible to modify settings (exposure, brightness, contrast, gain, etc) WHILE THE CAMERA WAS RUNNING. But other than the Arducam python script for focus adjustment, I haven’t seen a way to issue setting changes through libcamera-vid while it is already running.
Does anyone know how to do that? Is a python script the only way to modify camera settings on-the-fly? When I’m streaming, it’s nice to be able to adjust the picture quality, but I’m just not sure how to do that on this new setup.

It appears that the “v4l2-ctl” command has no usable options when running this propietary camera. They call it v4l2 compatible, but that must just be at the very lowest level.

hi, @ldwellman

Currently the sample programs in libcamera-apps do not implement runtime control.

You can try to set the control at runtime with the v4l2-ctl -c command.

With the prior cameras (V1 and V2), yes, I was able to modify parameters on-the-fly with the ‘v4l2-ctl’ command, but with this new Hawkeye 64mp camera, I cannot use the v4l2-ctl command. If you have figured out a way to do that, please explain with more details. But for me, any attempt to issue a v4l2-ctl command FAILS, as shown below:

$ v4l2-ctl -d /dev/video0 -c contrast=1
unknown control 'contrast'
$ v4l2-ctl --list-ctrls
$    <-- I get NOTHING - no usable controls available!

That’s what I meant earlier when I said “It appears that the ‘v4l2-ctl’ command has no usable options when running the proprietary camera.”

However, I see that there is the focus Python script that somehow CAN make on-the-fly changes, so at least the focus motor is controllable during video operation.

After making a few videos with this new 64mp, I have a lot more questions, but I guess I need to post them separately. I was hoping this higher quality camera would make our videos better, but so far, it’s been about equal to the older V1 camera…and I had more control over that camera to improve the video image. :frowning:

hi, @ldwellman

Sorry, due to changes in the internal framework of the new version of libcamera, it can no longer be used with the v4l2 command at the same time.

If you want to set the control at runtime, you may need to implement it yourself.Just like the python script you see for runtime control.

Should we only be using /dev/v4l-subdev0 and 1 for camera control of the 64mp camera? Because /dev/video0-n dont seem to be exposing any controls.

hi, @flor1s

Thank you for reminding. I used the following command to test it, and I can see the control information.

v4l2-ctl -d  /dev/v4l-subdev0 -l

The new Raspberry Pi system cannot obtain control information from the/dev/video0-n node.

However, when the libcamera-still command runs, it does not seem ideal using this method. libcamera-still always sets this value again.

Thanks, @yang

Sorry for hijacking the topic somewhat. Can I ask one additional question?

Is it possible to autofocus with a Python script? The only way I can get the camera to autofocus as far as I know is with libcamera-still --autofocus

Yes, autofocus can be achieved using our wrapped libcamera python library.

However, this library has some issues running with 64mp cameras, which we are working on fixing. . .

1 Like

Thank you for the information.

I should have mentioned I am using Picamera2, by the way. Maybe I should wait for your version of that.

We tested the picamera2 before and it couldn’t set autofocus.

I think we will modify picamera2 later to support all the features of our camera.

@flor1s @ldwellman

We currently find a solution that can use Python to implement autofocus and set control when running.

Edward or Yang,
I have some comments and questions –
Comment: If version 0.0.7 is already installed, it appears that you must also include the option “–allow-downgrades” when trying to install 0.0.6. Otherwise, you will get an error and it won’t downgrade.

pi@pi4:~ $ sudo apt install -y ./libcamera-apps-0.0.6-bullseye-arm64.deb
Use 'sudo apt autoremove' to remove it.
The following packages will be DOWNGRADED:
  libcamera-apps
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.
pi@pi4:~ $ dpkg --list|grep libcamera
ii  libcamera-apps                       0.0.7                            arm64        libcamera-apps
ii  libcamera-dev                        0.0.7                            arm64        libcamera

Questions:
1) For the armhf platform, you suggest installing version 0.0.6 of “libcamera-dev”, but for the arm64 platform, you suggest installing version 0.0.6 of “libcamera-apps”.
Is that correct? Or is that a typo?
2) I was already on 0.0.7 and I’m on the arm64 platform. Should I downgrade BOTH “libcamera-dev” and “libcamera-apps” in order to fix this problem? When I tried your suggestion above, it did not fix my issue – the “FocuserExample.py” program will not work.
(I have downgraded libcamera-apps to 0.0.6, but my libcamera-dev is still running 0.0.7)

pi@pi4:~ $ dpkg --list|grep libcamera
ii  libcamera-apps                       0.0.6                            arm64        libcamera-apps
ii  libcamera-dev                        0.0.7                            arm64        libcamera
pi@pi4:~ $ cd Arducam-Pivariety-V4L2-Driver/focus
pi@pi4:~/Arducam-Pivariety-V4L2-Driver/focus $ python FocuserExample.py
Traceback (most recent call last):
  File "/home/pi/Arducam-Pivariety-V4L2-Driver/focus/v4l2_utils.py", line 64, in get_device_controls_by_class
    fcntl.ioctl(fd, v4l2.VIDIOC_QUERYCTRL, queryctrl)
OSError: [Errno 25] Inappropriate ioctl for device

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Arducam-Pivariety-V4L2-Driver/focus/FocuserExample.py", line 157, in <module>
    main()
  File "/home/pi/Arducam-Pivariety-V4L2-Driver/focus/FocuserExample.py", line 152, in main
    focuser = Focuser(args.device)
  File "/home/pi/Arducam-Pivariety-V4L2-Driver/focus/Focuser.py", line 40, in __init__
    self.ctrls = v4l2_utils.get_ctrls(self.fd)
  File "/home/pi/Arducam-Pivariety-V4L2-Driver/focus/v4l2_utils.py", line 96, in get_ctrls
    for queryctrl in get_device_controls_by_class(vd, class_):
  File "/home/pi/Arducam-Pivariety-V4L2-Driver/focus/v4l2_utils.py", line 66, in get_device_controls_by_class
    assert e.errno == errno.EINVAL
AssertionError

Hi, @ldwellman

Currently, we have released version 0.0.8 of libcamera-dev and libcamera-apps, which supports autofocus control using picamera2.

Regarding the downgrade problem, you can uninstall the previous version first, and then install the lower version.

sudo apt purge libcamera-dev

And the versions of libcamera-dev and libcamera-apps need to be the same.

Currently, this python program does not work with libcamera camera stack frames.

Due to the big changes made in the new version of picamera2, we are adapting. You can follow this repository for updates.