Skip to content

Commit d7a7610

Browse files
authored
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.
1 parent 37aaa49 commit d7a7610

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/GenericUSBCameraSettables.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ public void setGain(int gain) {
240240

241241
@Override
242242
public VideoMode getCurrentVideoMode() {
243-
return camera.isConnected() ? camera.getVideoMode() : null;
243+
return camera
244+
.getVideoMode(); // This returns the current video mode even if the camera is disconnected
244245
}
245246

246247
@Override
@@ -250,7 +251,7 @@ public void setVideoModeInternal(VideoMode videoMode) {
250251
logger.error("Got a null video mode! Doing nothing...");
251252
return;
252253
}
253-
camera.setVideoMode(videoMode);
254+
if (camera.setVideoMode(videoMode)) logger.debug("Failed to set video mode!");
254255
} catch (Exception e) {
255256
logger.error("Failed to set video mode!", e);
256257
}

0 commit comments

Comments
 (0)