From c5ae3173022fe71b2f5f94b0fcea2145be889305 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 16 Feb 2024 15:26:04 -0500 Subject: [PATCH] Update VisionSourceManager.java --- .../vision/processes/VisionSourceManager.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java b/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java index 376a9591d9..81d3ab8aab 100644 --- a/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java +++ b/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java @@ -234,7 +234,6 @@ private final Predicate getCameraMatcher( boolean checkVidPid, boolean checkBaseName, boolean checkPath) { - if (checkUSBPath && savedConfig.getUSBPath().isEmpty()) { logger.debug( "WARN: Camera has empty USB path, but asked to match by name: " @@ -319,7 +318,20 @@ public List matchCameras( logger.info("Matching by usb port & name & USB VID/PID..."); cameraConfigurations.addAll( matchCamerasByStrategy(detectedCameraList, unloadedConfigs, true, true, true, false)); - } else logger.debug("Skipping matchByPathAndName, no configs or cameras left to match"); + } else + logger.debug("Skipping match by usb port/name/vid/pid, no configs or cameras left to match"); + + // On windows, the v4l path is actually useful and tells us the port the camera is physically + // connected to which is neat + if (Platform.isWindows()) { + if (detectedCameraList.size() > 0 || unloadedConfigs.size() > 0) { + logger.info("Matching by windows-path & USB VID/PID only..."); + cameraConfigurations.addAll( + matchCamerasByStrategy(detectedCameraList, unloadedConfigs, false, true, true, true)); + } else + logger.debug( + "Skipping matching by windiws-path/name/vid/pid, no configs or cameras left to match"); + } if (detectedCameraList.size() > 0 || unloadedConfigs.size() > 0) { logger.info("Matching by usb port & USB VID/PID..."); @@ -335,12 +347,6 @@ public List matchCameras( matchCamerasByStrategy(detectedCameraList, unloadedConfigs, false, true, true, false)); } else logger.debug("Skipping match by base-name/viid/pid, no configs or cameras left to match"); - - if (detectedCameraList.size() > 0 || unloadedConfigs.size() > 0) { - logger.info("Matching by v4l-path & USB VID/PID only..."); - cameraConfigurations.addAll( - matchCamerasByStrategy(detectedCameraList, unloadedConfigs, false, true, false, true)); - } else logger.debug("Skipping matchByName, no configs or cameras left to match"); } else logger.info("Skipping match by filepath/vid/pid, disabled by user"); if (detectedCameraList.size() > 0) { @@ -373,7 +379,6 @@ private List matchCamerasByStrategy( boolean checkVidPid, boolean checkBaseName, boolean checkPath) { - List ret = new ArrayList(); List unloadedConfigsCopy = new ArrayList(unloadedConfigs);