Update camera path if matched camera path doesn't match saved path

Improves stability when cameras change USB ports.
This commit is contained in:
Chris Gerth
2020-11-28 08:24:30 -06:00
committed by GitHub
parent 2ae750f00f
commit 308e108953

View File

@@ -217,7 +217,7 @@ public class VisionSourceManager {
if (cameraInfo != null) {
logger.debug("Matched the config for " + config.baseName + " to a physical camera!");
detectedCameraList.remove(cameraInfo);
cameraConfigurations.add(config);
cameraConfigurations.add(mergeInfoIntoConfig(config, cameraInfo));
}
}
@@ -246,6 +246,15 @@ public class VisionSourceManager {
return cameraConfigurations;
}
private CameraConfiguration mergeInfoIntoConfig(CameraConfiguration cfg, UsbCameraInfo info) {
if (!cfg.path.equals(info.path)) {
logger.debug("Updating path config from " + cfg.path + " to " + info.path);
cfg.path = info.path;
}
return cfg;
}
private List<VisionSource> loadVisionSourcesFromCamConfigs(List<CameraConfiguration> camConfigs) {
List<VisionSource> usbCameraSources = new ArrayList<>();
camConfigs.forEach(configuration -> usbCameraSources.add(new USBCameraSource(configuration)));