mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-25 01:41:40 +00:00
Disable auto focus on USB cameras by default (#487)
* Disable auto focus on USB cameras by default * Remove extra log * Implement camera quirk for auto focus * Spotless apply
This commit is contained in:
@@ -27,5 +27,7 @@ public enum CameraQuirk {
|
||||
/** Separate red/blue gain controls available */
|
||||
AWBGain,
|
||||
/** Will not work with photonvision - Logitec C270 at least */
|
||||
CompletelyBroken
|
||||
CompletelyBroken,
|
||||
/** Has adjustable focus and autofocus switch */
|
||||
AdjustableFocus,
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ public class QuirkyCamera {
|
||||
new QuirkyCamera(0x825, 0x46D, CameraQuirk.CompletelyBroken), // Logitec C270
|
||||
new QuirkyCamera(0x2000, 0x1415, CameraQuirk.Gain, CameraQuirk.FPSCap100), // PS3Eye
|
||||
new QuirkyCamera(
|
||||
-1, -1, "mmal service 16.1", CameraQuirk.PiCam) // PiCam (via V4L2, not zerocopy)
|
||||
-1, -1, "mmal service 16.1", CameraQuirk.PiCam), // PiCam (via V4L2, not zerocopy)
|
||||
new QuirkyCamera(0x85B, 0x46D, CameraQuirk.AdjustableFocus) // Logitech C925-e
|
||||
);
|
||||
|
||||
public static final QuirkyCamera DefaultCamera = new QuirkyCamera(0, 0, "");
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
package org.photonvision.vision.camera;
|
||||
|
||||
import edu.wpi.first.cameraserver.CameraServer;
|
||||
import edu.wpi.first.cscore.CvSink;
|
||||
import edu.wpi.first.cscore.UsbCamera;
|
||||
import edu.wpi.first.cscore.VideoException;
|
||||
import edu.wpi.first.cscore.VideoMode;
|
||||
import edu.wpi.first.cscore.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
@@ -65,11 +62,23 @@ public class USBCameraSource extends VisionSource {
|
||||
} else {
|
||||
// Normal init
|
||||
setLowExposureOptimizationImpl(false);
|
||||
disableAutoFocus();
|
||||
usbCameraSettables = new USBCameraSettables(config);
|
||||
usbFrameProvider = new USBFrameProvider(cvSink, usbCameraSettables);
|
||||
}
|
||||
}
|
||||
|
||||
void disableAutoFocus() {
|
||||
if (cameraQuirks.hasQuirk(CameraQuirk.AdjustableFocus)) {
|
||||
try {
|
||||
camera.getProperty("focus_auto").set(0);
|
||||
camera.getProperty("focus_absolute").set(0); // Focus into infinity
|
||||
} catch (VideoException e) {
|
||||
logger.error("Unable to disable autofocus!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setLowExposureOptimizationImpl(boolean lowExposureMode) {
|
||||
if (cameraQuirks.hasQuirk(CameraQuirk.PiCam)) {
|
||||
// Case, we know this is a picam. Go through v4l2-ctl interface directly
|
||||
|
||||
Reference in New Issue
Block a user