Libcamera-vid w/IMX462 doesn't adjust negative ev values

While testing the IMX462 low light camera on an rPi3a with libcamera-vid I notice that negative EV (exposure compensation values) have no effect. E.g., libcamera-vid --ev -2 ... seems to show no effect. Positive values do have an effect. Using an official rPi V2 camera the negative EV values do work. Can you confirm that this is a bug somewhere in your driver or software?

By looking at the code of libcamera, the ev option does not support negative values.

image

image

Interesting… Looks like libcamera-vid and libcamera-still don’t care about that definition :laughing:
Using an official rPi V2 camera I ran:

libcamera-still --ev 0 --width 640 --height 480 --rotation 180 -o ev0.jpg
libcamera-still --ev 2 --width 640 --height 480 --rotation 180 -o ev2.jpg
libcamera-still --ev -2 --width 640 --height 480 --rotation 180 -o evn2.jpg

The results:
ev0.jpg
ev0
ev2.jpg
ev2
evn2.jpg (n==negative)
evn2

So --ev -2 definitely works as expected. Using an IMX462 I couldn’t reproduce this (I can’t try right now 'cause the camera is mounted outside and it’s too dark).

You can try to open the debug log:
export LIBCAMERA_LOG_LEVELS=RPiAgc:DEBUG

We can confirm whether it has the correct settings.

I did a couple more experiments this time using the arducam IMX462:

libcamera-still --ev 0 --width 640 --height 480 --rotation 180 -o ev0.jpg
libcamera-still --ev 2 --width 640 --height 480 --rotation 180 -o ev2.jpg
libcamera-still --ev -2 --width 640 --height 480 --rotation 180 -o evn2.jpg
libcamera-still --ev -6 --width 640 --height 480 --rotation 180 -o evn6.jpg

Here are the results I get:
ev0.jpg:
ev0
ev2.jpg:
ev2
evn2.jpg:
evn2
and evn6.jpg:
evn6

I don’t know about you, but I can’t make out any real difference between 0, +2, and -2. The ev -6 image is clearly darker. I hadn’t gone as far as -6 before and so hadn’t seen this. It’s clearly very dark at the moment, maybe in daylight the results are better, but if my earlier tests were accurate, then I don’t believe so…

In terms of debug output, it does print what I’d expect (this is for the ev -6 case):

[82:28:46.387628712] [11018]  INFO IPARPI raspberrypi.cpp:637 Request ctrl: ExposureValue = -6.00000

I don’t know where the exposure is calculated, but so far it seems to me that it’s not working all that well.

BTW: thanks a lot for your great support! It’s very appreciated!

I also didn’t see a noticeable difference.

I’m not sure about the problem here, because the software (libcamera) seems to be the same, and the exposure is completely controlled by software. .

As far as I know, the exposure is controlled in the IPA, i.e., what’s in https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/ipa-v0.01/ipa_rpi.tar.xz
As far as I understand, Arducam took the open source IPA from rPi, modified it, and provides the above closed-source version. Looks like it doesn’t do EV correctly?

In fact, we did not change the original ipa code, we just added the code to read information from the device…

Hi
Dont know if this thread is still valid but it seems related.
I am having also problems setting the --ev to negative values with libcamera-vid. Although it is with the AR0234 camera. Positive values seem to take, but when going into negatives it stays at --ev 0 (default).

I tested a fresh raspberry pi image with a stock camera module V3 and there it takes the negative values. Any hint on how I could use negative --ev settings on the AR0234 cam?

(if I should make a new thread, I am happy to do so :wink: )

goam

@goam

It shouldn’t be.

Can you tell me the SKU number of your camera?

The only numbers I can see are on the PCB “UC-788 Rev.B” and “PY078 v2.0 R” on the Sensor cable.
Same for both cameras I have her

Found it on the manual: B0353

@goam

I did some tests with the same camera as you.
everything seems to be fine.

normal


ev=-2

ev=2

Can you describe your results in detail?
Also give me some information by the way.

dpkg -l | grep libcamera
uname -a

Hi
Here are the infos

ii  libcamera-apps                       0.0.12                           arm64        libcamera-apps
ii  libcamera-dev                        0.0.12                           arm64        libcamera
Linux zero1 5.15.84-v8+ #1613 SMP PREEMPT Thu Jan 5 12:03:08 GMT 2023 aarch64 GNU/Linux

I use libcamera-vid for testing, but I guess this should be the same?

libcamera-vid -t 0 --inline --width 1920 --height 1080 --framerate 30 --bitrate 8000000 --denoise off -n -o udp://<IP>:Port

I tested your setup and really, in a more controlled environment the settings do take:

But as soon as I go outdoor and there is more light the minus --ev values do not seem to take any more…weird

I can still force a darker picture with the --shutter command. So I know that there would be shorter shutter speeds available to capture less light.

I also tested this side by side to a stock camera module V3 wide, and there it does work.

@goam

Because the outdoors are too bright, the exposure time is already the lowest, and it can’t be darker.

Thanks for your input…
But I think the AR0234 cam is better than you give it credit for.

I did some further testing and found something interesting:
I already knew that you can lower the light intake by using --shutter. So I went out to compare shutter speeds with EV settings.

The --ev 0 and --ev-5 are the same as usual and looks identical to --shutter 100.
--shutter 50 makes the video one stop darker as it is half the exposure time.

Is it possible that --ev only takes shutter settings as low as --shutter 100 for its calculations? It certainly looks like it. And if so, would it be possible to adjust that?

I tested --shutter 50 and --shutter 25 and it would give me the 1 or 2 stops I would need for my usecase in the outdoors, if --ev could use them. And with my changing light conditions I am somewhat forced to use EV settings instead of just using fixed shutter speeds.
Also I mean, the other way would be: “Only use this camera if not too bright…” :wink: jk

Any insights?

@goam

amazing.
This is indeed a very interesting phenomenon.

Thank you for not giving up on exploring just following my conclusions.

I’m going to dig into that.
Please wait for my reply.

@goam

Researched it again.
Adjusting --ev, only adjusts the gain but does not affect the exposure.
If --ev is reduced, but the effect does not change, it means that the gain has been reduced to the minimum.

If you want to lower the brightness in this scene, you can use --shutter to control it

Thanks a lot for digging into this again. I did not know that --ev only adjusts the gain.
I learned something new again, which I guess is also good!
Of course I hoped for an easier answer…but it is what it is :grin:

The alternative now is to change the light intake with a more complicated ND and IR filter setup which I feared a little.
But now that I have to go all out anyways, is there more info on the AR0234 sensor available? Like native ISO and the ISO mapping to the gain values in libcamera?

Would be much appreciated!
Goam

@goam

You can look at the official documentation, there are many introductions.