Skip to content
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

How can I disable auto exposure and set exposure time? #33

Closed
mzahana opened this issue Apr 7, 2024 · 10 comments
Closed

How can I disable auto exposure and set exposure time? #33

mzahana opened this issue Apr 7, 2024 · 10 comments

Comments

@mzahana
Copy link

mzahana commented Apr 7, 2024

Hi @christianrauch

The auto exposure is not working apropriately on my camera and the image keeps flickering. I would like to disable auto exposure and set exposure time myself. Are there parameters that I can use to do that?

Thanks

@mzahana
Copy link
Author

mzahana commented Apr 7, 2024

I tried to get the range of values of the ExposureTime parameter and this is what I got

ros2 param describe camera ExposureTime
Parameter name: ExposureTime
  Type: integer
  Description: Integer32 scalar range {13}..{0}
  Constraints:
    Min value: 13
    Max value: 0

The min/max values don't make sense to me.

I tried to set this parameter to a value of 5 in a launch file, and this is the output I got from the node log

Component constructor threw an exception: parameter 'ExposureTime' could not be set: Parameter {ExposureTime} doesn't comply with integer range.

@christianrauch
Copy link
Owner

If your camera has an option for auto-exposure that is exposed via libcamera, you should be able to get/set AeEnable:

ros2 param set /camera AeEnable false

I have a "Camera Module v1" (OV5647) and I can see a similar inconsistency with min/max values:

$ ros2 param describe /camera ExposureTime
Parameter name: ExposureTime
  Type: integer
  Description: Integer32 scalar range {134}..{0}
  Constraints:
    Min value: 134
    Max value: 0

@christianrauch
Copy link
Owner

I managed to build arm64 packages of version 0.1 and 0.2 of libcamera that include the cam executable for testing: ros-humble-libcamera.zip

The versions show me the following controls:

libcamera 0.1:

[0:14:34.472322511] [1176]  INFO Camera camera_manager.cpp:284 libcamera v0.0.0+24-01d93012
[0:14:34.576984288] [1177]  INFO RPI vc4.cpp:390 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media0 and ISP device /dev/media1
Using camera /base/soc/i2c0mux/i2c@1/ov5647@36 as cam0
Control: AwbEnable: [false..true]
Control: ColourGains: [0.000000..32.000000]
Control: AwbMode: [0..7]
Control: Saturation: [0.000000..32.000000]
Control: AeEnable: [false..true]
Control: ExposureTime: [0..66666]
Control: AeMeteringMode: [0..3]
Control: AeExposureMode: [0..3]
Control: NoiseReductionMode: [0..4]
Control: AeConstraintMode: [0..3]
Control: ExposureValue: [-8.000000..8.000000]
Control: Sharpness: [0.000000..16.000000]
Control: AnalogueGain: [1.000000..16.000000]
Control: ScalerCrop: [(0, 0)/0x0..(65535, 65535)/65535x65535]
Control: Brightness: [-1.000000..1.000000]
Control: Contrast: [0.000000..32.000000]
Control: FrameDurationLimits: [33333..120000]

libcamera 0.2:

[0:20:31.793620382] [1337]  INFO Camera camera_manager.cpp:284 libcamera v0.0.0+26-2b3d8f7c
[0:20:31.928932537] [1338]  WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:20:31.937727452] [1338]  INFO RPI vc4.cpp:401 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media0 and ISP device /dev/media1
Using camera /base/soc/i2c0mux/i2c@1/ov5647@36 as cam0
Control: AwbEnable: [false..true]
Control: ColourGains: [0.000000..32.000000]
Control: StatsOutputEnable: [false..true]
Control: NoiseReductionMode: [0..4]
Control: FrameDurationLimits: [33333..120000]
Control: AeFlickerPeriod: [100..1000000]
Control: AeConstraintMode: [0..3]
Control: Saturation: [0.000000..32.000000]
Control: AeExposureMode: [0..3]
Control: AwbMode: [0..7]
Control: AeEnable: [false..true]
Control: ExposureValue: [-8.000000..8.000000]
Control: AnalogueGain: [1.000000..16.000000]
Control: AeFlickerMode: [0..1]
Control: Brightness: [-1.000000..1.000000]
Control: Contrast: [0.000000..32.000000]
Control: ExposureTime: [0..66666]
Control: HdrMode: [0..4]
Control: ScalerCrop: [(0, 0)/0x0..(65535, 65535)/65535x65535]
Control: AeMeteringMode: [0..3]
Control: Sharpness: [0.000000..16.000000]

In both cases, the ExposureTime is reported with the range [0..66666]. The values reported by the node therefore do not make sense.

@christian-nils
Copy link
Contributor

christian-nils commented Apr 25, 2024

You should be able to set AeEnable to false when starting the camera now using #39. Regarding the wrong value range for the ExposureTime control, I have reported the issue to rpicam-apps (raspberrypi/rpicam-apps#673) and they said that they will look into it. It seems to be caused by libcamera.

@christianrauch
Copy link
Owner

You should be able to set AeEnable to false when starting the camera now using #39. Regarding the wrong value range for the ExposureTime control, I have reported the issue to rpicam-apps (raspberrypi/rpicam-apps#673) and they said that they will look into it. It seems to be caused by libcamera.

Thanks a lot for investigating this with the standard libcamera apps and reporting this upstream. If this already happens with the default apps, then there is nothing we can do here except waiting for a new release with a bug fix.

The remaining question for me would be if this issue is also present in the 0.1 version. Otherwise, I would revert back to the 0.1 version of the libcamera package until a fix has been released. @christian-nils Do you have a way to test different versions of libcamera?

@christian-nils
Copy link
Contributor

Unfortunately, I have only a RPi5 setup at the moment so libcamera v0.1.0 won't work as RPi5 support was introduced later.

@christian-nils
Copy link
Contributor

christian-nils commented Apr 26, 2024

It seems that they found the fix for the bug, see raspberrypi/rpicam-apps#673 (comment). I applied the patch and I get a reasonable range now:

root@microvision:~/ws# ros2 param describe /camera ExposureTime
Parameter name: ExposureTime
  Type: integer
  Description: Integer32 scalar range {60}..{674181621}
  Constraints:
    Min value: 60
    Max value: 674181621

@christianrauch
Copy link
Owner

Is there anything that can be done in the node to prevent that issue? If not, I would close this issue.

@christian-nils
Copy link
Contributor

I would tend to believe that this is out of the node's scope, yes.

@christianrauch
Copy link
Owner

I would tend to believe that this is out of the node's scope, yes.

Ok. Then I am closing this issue and hope the problem gets solved with libcamera 0.3.

@christianrauch christianrauch closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants