From 7b8326beb14ed5beca0cab4007976704e4f73309 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 28 Dec 2023 10:42:52 -0500 Subject: [PATCH] Use exposure_time_absolute if present (#1079) --- .../org/photonvision/vision/camera/USBCameraSource.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/photon-core/src/main/java/org/photonvision/vision/camera/USBCameraSource.java b/photon-core/src/main/java/org/photonvision/vision/camera/USBCameraSource.java index a2f2911431..66b0a4fff7 100644 --- a/photon-core/src/main/java/org/photonvision/vision/camera/USBCameraSource.java +++ b/photon-core/src/main/java/org/photonvision/vision/camera/USBCameraSource.java @@ -22,6 +22,7 @@ import edu.wpi.first.cscore.UsbCamera; import edu.wpi.first.cscore.VideoException; import edu.wpi.first.cscore.VideoMode; +import edu.wpi.first.cscore.VideoProperty.Kind; import java.util.*; import java.util.stream.Collectors; import org.photonvision.common.configuration.CameraConfiguration; @@ -29,6 +30,7 @@ import org.photonvision.common.logging.LogGroup; import org.photonvision.common.logging.Logger; import org.photonvision.common.util.TestUtils; +import org.photonvision.common.util.math.MathUtils; import org.photonvision.vision.frame.FrameProvider; import org.photonvision.vision.frame.provider.FileFrameProvider; import org.photonvision.vision.frame.provider.USBFrameProvider; @@ -210,6 +212,12 @@ public void setExposure(double exposure) { camera.getProperty("raw_exposure_time_absolute").set(scaledExposure); camera.getProperty("raw_exposure_time_absolute").set(scaledExposure); + } else if (camera.getProperty("exposure_time_absolute").getKind() != Kind.kNone) { + // Seems like the name changed at some point in v4l? set it instead + var prop = camera.getProperty("exposure_time_absolute"); + var exposure_manual_val = + MathUtils.map(Math.round(exposure), 0, 100, prop.getMin(), prop.getMax()); + prop.set((int) exposure_manual_val); } else { scaledExposure = (int) Math.round(exposure); logger.debug("Setting camera exposure to " + scaledExposure);