Skip to content

Commit

Permalink
Use exposure_time_absolute if present (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Dec 28, 2023
1 parent ebac32c commit 7b8326b
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
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;
import org.photonvision.common.configuration.ConfigManager;
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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7b8326b

Please sign in to comment.