Fix videomode is null (#1513)

There is a weird edge case at least with arducam/broken arducams/used
arducams where cscore will see it when pv starts but not be able to
connect to it. If we always read out the "current" video mode instead of
null when it is disconnected things will work. If the camera is
disconnected while we try to change the video mode when we get the
current video mode it will tell us what we wanted to set it to. Then
when the camera reconnects it will be in that video mode.
This commit is contained in:
Cameron (3539)
2024-10-31 23:13:36 -04:00
committed by GitHub
parent 37aaa49b32
commit d7a7610917

View File

@@ -240,7 +240,8 @@ public class GenericUSBCameraSettables extends VisionSourceSettables {
@Override
public VideoMode getCurrentVideoMode() {
return camera.isConnected() ? camera.getVideoMode() : null;
return camera
.getVideoMode(); // This returns the current video mode even if the camera is disconnected
}
@Override
@@ -250,7 +251,7 @@ public class GenericUSBCameraSettables extends VisionSourceSettables {
logger.error("Got a null video mode! Doing nothing...");
return;
}
camera.setVideoMode(videoMode);
if (camera.setVideoMode(videoMode)) logger.debug("Failed to set video mode!");
} catch (Exception e) {
logger.error("Failed to set video mode!", e);
}