mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-01 02:41:42 +00:00
Fix NPE changing camera quirks then calibrating (#1660)
Closes https://github.com/PhotonVision/photonvision/issues/1659
This commit is contained in:
@@ -85,6 +85,7 @@ public class USBCameraSource extends VisionSource {
|
||||
} else {
|
||||
// Camera is likely to work, set up the Settables
|
||||
settables = createSettables(config, camera);
|
||||
logger.info("Created settables " + settables);
|
||||
|
||||
if (settables.getAllVideoModes().isEmpty()) {
|
||||
// No video modes produced from settables, disable the camera
|
||||
@@ -160,7 +161,15 @@ public class USBCameraSource extends VisionSource {
|
||||
var oldConfig = this.cameraConfiguration;
|
||||
var oldCamera = this.camera;
|
||||
|
||||
// Re-create settables
|
||||
var oldVideoMode = this.settables.getCurrentVideoMode();
|
||||
this.settables = createSettables(oldConfig, oldCamera);
|
||||
|
||||
// And update FrameStaticProps
|
||||
settables.setVideoMode(oldVideoMode);
|
||||
|
||||
// Propogate our updated settables over to the frame provider
|
||||
((USBFrameProvider) this.usbFrameProvider).updateSettables(this.settables);
|
||||
}
|
||||
|
||||
private void printCameraProperaties() {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class USBFrameProvider extends CpuImageProcessor {
|
||||
private final CvSink cvSink;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
private final VisionSourceSettables settables;
|
||||
private VisionSourceSettables settables;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public USBFrameProvider(CvSink sink, VisionSourceSettables visionSettables) {
|
||||
@@ -60,4 +60,8 @@ public class USBFrameProvider extends CpuImageProcessor {
|
||||
public String getName() {
|
||||
return "USBFrameProvider - " + cvSink.getName();
|
||||
}
|
||||
|
||||
public void updateSettables(VisionSourceSettables settables) {
|
||||
this.settables = settables;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user