Closed ilirosmanaj closed 1 month ago
Yes, I'm afraid you can only have one tuning file per type of camera. In fact, it's a limitation down in the libcamera API and is something we've long wanted to remove. You may have more luck if you run the cameras in separate processes - might be an option for you?
I run the cameras through a Flask API which gets invoked at specific endpoints. Not sure if multiprocessing (created from within the app) would be something that could help us here - need to check how the synchronization between the two cameras would work, since they more or less need to capture at the same time and there are some information exchanged (e.g. we want to use the same Lens position on both cameras, and this lens depends on the user specifications on the request).
@davidplowman, from your Yes, I'm afraid you can only have one tuning file per type of camera
response. What does type of camera actually mean here? These two are different in hardware and also have different tunning files - but maybe you're referring to something else
@davidplowman any updates on the above maybe?
Sorry, I thought I'd replied but obviously not. As long as your cameras load different tuning files by default, then you can in principle overwrite them and have your own tuning file for those cameras. In this context, anything with a different sensor counts as different, for example "imx219", "imx477" and so on. I think "imx296" and "imx296 mono" count as different because the camera module is programmed to know which it is. Ditto "imx708" and "imx708 wide", again because I believe it's programmed into the module.
What cameras are you wanting to use? Can you say anything about what you want to tune differently?
Thanks for the reply @davidplowman.
I use imx708_wide
and imx708_wide_noir
cameras. The only setting that I want to tune differently are the exposure ones (the exposure and gain ranges, together with the autoexposure tunning parameters).
I'm not sure that "noir" counts as different. But your life may be much easier if you just define two exposure modes which are the ones you want. One is still called "normal" and the other "short", but the name doesn't matter. Simply use set_controls
to set one camera to "normal", and the other to "short". Could that work?
Potentially yes, that is a very good idea. Let me try that and will get back to you
@davidplowman, that worked, thank you very much.
This, however, doesn't let me choose different AutoExposure algorithm parameters per camera type. This is what I have now:
ae_settings = Picamera2.find_tuning_algo(tuning, "rpi.agc")
ae_settings["exposure_modes"]["normal"] = {
"shutter": [2500, 3000, 3500, 4000, 4500],
"gain": [2.5, 3.0, 4.0, 5.0, 6.0]
}
ae_settings["exposure_modes"]["short"] = {
"shutter": [2000, 2500, 3000, 3500, 3700],
"gain": [2.0, 2.5, 3.0, 3.5, 3.7]
}
ae_settings["startup_frames"] = 2
ae_settings["convergence_frames"] = 3
ae_settings["desaturate"] = 0
ae_settings["base_ev"] = 1.5
ae_settings["speed"] = 1
Any ideas?
Hi again, I'm not even sure I'd try to fiddle with the tuning file at all. I'd be tempted to try
from picamera2 import Picamera2
from libcamera import controls
# ...
cam0 = Picamera2(0)
cam1 = Picamera2(1)
# ...
cam0.set_controls({'AeExposureMode': controls.AeExposureModeEnum.Normal})
cam1.set_controls({'AeExposureMode': controls.AeExposureModeEnum.Custom})
where you can simply edit all the tuning files to have the "normal" and "custom" modes that you want.
This suggestion helped actually: https://github.com/raspberrypi/picamera2/issues/1094#issuecomment-2291461591
So closing this issue for me.
Given an RPI that has two cameras (RGB and IR Camera), how can both of these be loaded with different tunning file settings?
Describe what it is that you want to accomplish I have a real time application and needs both of these cameras running simultaneously, the RGB camera and the IR camera. However, I need to apply different exposure ranges for these cameras auto-exposure run.
Currently, whichever camera I initialize first, it sticks with the tunning file of this camera for both cameras.
From the initialization of the Picamera, I see this:
This means we only have one tunning file environment variable being exported for libcamera, which is probably the reason why we cannot have two tunning files.
Additional context
A sample to reproduce is here:
If I use this order of initialization:
If I use the other order:
So the exposure range is not being respected in these.