mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-23 01:21:40 +00:00
Hard-code picam resolutions (#366)
* Hard-code picam resolutions * Address review comment
This commit is contained in:
@@ -174,7 +174,19 @@ public class USBCameraSource extends VisionSource {
|
||||
videoModes = new HashMap<>();
|
||||
List<VideoMode> videoModesList = new ArrayList<>();
|
||||
try {
|
||||
var modes = camera.enumerateVideoModes();
|
||||
VideoMode[] modes;
|
||||
if (cameraQuirks.hasQuirk(CameraQuirk.PiCam)) {
|
||||
modes =
|
||||
new VideoMode[] {
|
||||
new VideoMode(VideoMode.PixelFormat.kBGR, 320, 240, 90),
|
||||
new VideoMode(VideoMode.PixelFormat.kBGR, 640, 480, 90),
|
||||
new VideoMode(VideoMode.PixelFormat.kBGR, 960, 720, 60),
|
||||
new VideoMode(VideoMode.PixelFormat.kBGR, 1280, 720, 45),
|
||||
new VideoMode(VideoMode.PixelFormat.kBGR, 1920, 1080, 20),
|
||||
};
|
||||
} else {
|
||||
modes = camera.enumerateVideoModes();
|
||||
}
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
var videoMode = modes[i];
|
||||
|
||||
@@ -234,24 +246,6 @@ public class USBCameraSource extends VisionSource {
|
||||
sortedList.remove(badIdx);
|
||||
}
|
||||
|
||||
// Filter bogus modes on picam
|
||||
if (cameraQuirks.hasQuirk(CameraQuirk.PiCam)) {
|
||||
sortedList.removeIf(
|
||||
it ->
|
||||
(it.width == 1296
|
||||
&& it.height == 730
|
||||
&& it.pixelFormat == VideoMode.PixelFormat.kBGR)
|
||||
|| (it.width == 1296
|
||||
&& it.height == 972
|
||||
&& it.pixelFormat == VideoMode.PixelFormat.kBGR)
|
||||
|| (it.width == 2592
|
||||
&& it.height == 1944
|
||||
&& it.pixelFormat == VideoMode.PixelFormat.kBGR)
|
||||
|| (it.width == 160
|
||||
&& it.height == 120
|
||||
&& it.pixelFormat == VideoMode.PixelFormat.kBGR));
|
||||
}
|
||||
|
||||
for (VideoMode videoMode : sortedList) {
|
||||
videoModes.put(sortedList.indexOf(videoMode), videoMode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user