From 08a51fd23759f8a40becb38ef2a003c84732521f Mon Sep 17 00:00:00 2001 From: Banks T <btrout.dhrs@gmail.com> Date: Wed, 6 Jan 2021 17:27:01 -0500 Subject: [PATCH] Limit PS3Eye to 100FPS (#218) This helps prevent running in to USB bandwidth issues with multiple PS3Eyes. --- .../java/org/photonvision/vision/camera/CameraQuirk.java | 4 +++- .../java/org/photonvision/vision/camera/QuirkyCamera.java | 2 +- .../org/photonvision/vision/camera/USBCameraSource.java | 6 ++++++ .../test/java/org/photonvision/vision/QuirkyCameraTest.java | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/photon-server/src/main/java/org/photonvision/vision/camera/CameraQuirk.java b/photon-server/src/main/java/org/photonvision/vision/camera/CameraQuirk.java index ed801646fc..fe5043f13e 100644 --- a/photon-server/src/main/java/org/photonvision/vision/camera/CameraQuirk.java +++ b/photon-server/src/main/java/org/photonvision/vision/camera/CameraQuirk.java @@ -21,5 +21,7 @@ public enum CameraQuirk { /** Camera settable for controllable image gain */ Gain, /** For the Raspberry Pi Camera */ - PiCam + PiCam, + /** Cap at 100FPS for high-bandwidth cameras */ + FPSCap100 } diff --git a/photon-server/src/main/java/org/photonvision/vision/camera/QuirkyCamera.java b/photon-server/src/main/java/org/photonvision/vision/camera/QuirkyCamera.java index 85aba16377..737585f281 100644 --- a/photon-server/src/main/java/org/photonvision/vision/camera/QuirkyCamera.java +++ b/photon-server/src/main/java/org/photonvision/vision/camera/QuirkyCamera.java @@ -25,7 +25,7 @@ public class QuirkyCamera { private static final List<QuirkyCamera> quirkyCameras = List.of( - new QuirkyCamera(0x2000, 0x1415, CameraQuirk.Gain), // PS3Eye + new QuirkyCamera(0x2000, 0x1415, CameraQuirk.Gain, CameraQuirk.FPSCap100), // PS3Eye new QuirkyCamera(-1, -1, "mmal service 16.1", CameraQuirk.PiCam) // PiCam (via V4L2) ); diff --git a/photon-server/src/main/java/org/photonvision/vision/camera/USBCameraSource.java b/photon-server/src/main/java/org/photonvision/vision/camera/USBCameraSource.java index efc6b18de3..e7327b27e2 100644 --- a/photon-server/src/main/java/org/photonvision/vision/camera/USBCameraSource.java +++ b/photon-server/src/main/java/org/photonvision/vision/camera/USBCameraSource.java @@ -194,6 +194,12 @@ public HashMap<Integer, VideoMode> getAllVideoModes() { } } + if (cameraQuirks.hasQuirk(CameraQuirk.FPSCap100)) { + if (videoMode.fps > 100) { + continue; + } + } + videoModesList.add(videoMode); // We look for modes with the same height/width/pixelformat as this mode diff --git a/photon-server/src/test/java/org/photonvision/vision/QuirkyCameraTest.java b/photon-server/src/test/java/org/photonvision/vision/QuirkyCameraTest.java index 00b2e69a5c..45517ee029 100644 --- a/photon-server/src/test/java/org/photonvision/vision/QuirkyCameraTest.java +++ b/photon-server/src/test/java/org/photonvision/vision/QuirkyCameraTest.java @@ -28,6 +28,7 @@ public class QuirkyCameraTest { public void ps3EyeTest() { HashMap<CameraQuirk, Boolean> ps3EyeQuirks = new HashMap<>(); ps3EyeQuirks.put(CameraQuirk.Gain, true); + ps3EyeQuirks.put(CameraQuirk.FPSCap100, true); for (var q : CameraQuirk.values()) { ps3EyeQuirks.putIfAbsent(q, false); }