mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Don't crash if libcamera fails to load (#2498)
This commit is contained in:
@@ -63,7 +63,14 @@ public class LibcameraGpuSettables extends VisionSourceSettables {
|
||||
|
||||
videoModes = new HashMap<>();
|
||||
|
||||
sensorModel = LibCameraJNI.getSensorModel(configuration.matchedCameraInfo.path());
|
||||
LibCameraJNI.SensorModel tempSensorModel;
|
||||
try {
|
||||
tempSensorModel = LibCameraJNI.getSensorModel(configuration.matchedCameraInfo.path());
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
logger.error("Unable to load libcamera JNI", e);
|
||||
tempSensorModel = LibCameraJNI.SensorModel.Disconnected;
|
||||
}
|
||||
sensorModel = tempSensorModel;
|
||||
|
||||
if (sensorModel == LibCameraJNI.SensorModel.IMX219) {
|
||||
// Settings for the IMX219 sensor, which is used on the Pi Camera Module v2
|
||||
|
||||
@@ -146,11 +146,15 @@ public class LibcameraGpuFrameProvider extends FrameProvider {
|
||||
|
||||
@Override
|
||||
public boolean checkCameraConnected() {
|
||||
String[] cameraNames = LibCameraJNI.getCameraNames();
|
||||
for (String name : cameraNames) {
|
||||
if (name.equals(settables.getConfiguration().getDevicePath())) {
|
||||
return true;
|
||||
try {
|
||||
String[] cameraNames = LibCameraJNI.getCameraNames();
|
||||
for (String name : cameraNames) {
|
||||
if (name.equals(settables.getConfiguration().getDevicePath())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
// libcamera failed to load; ignored
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user