From 8e2cc51f95c5c9489f5028a3beef30df22d0f384 Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Sun, 11 Aug 2024 11:55:36 -0400 Subject: [PATCH] [cscore] Try loading debug OpenCV if release version fails (#6928) On some Linux systems, installing the OpenCV package will actually install a debug version with a d postfix. Try loading that version if the first load attempt failed. --- .../java/edu/wpi/first/cscore/OpenCvLoader.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cscore/src/main/java/edu/wpi/first/cscore/OpenCvLoader.java b/cscore/src/main/java/edu/wpi/first/cscore/OpenCvLoader.java index c3bf916f3e..d6df2eec92 100644 --- a/cscore/src/main/java/edu/wpi/first/cscore/OpenCvLoader.java +++ b/cscore/src/main/java/edu/wpi/first/cscore/OpenCvLoader.java @@ -46,7 +46,13 @@ public final class OpenCvLoader { RuntimeLoader.loadLibrary(Core.NATIVE_LIBRARY_NAME); } catch (IOException ex) { ex.printStackTrace(); - System.exit(1); + try { + // Try adding a debug postfix + RuntimeLoader.loadLibrary(Core.NATIVE_LIBRARY_NAME + "d"); + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } } libraryLoaded = true; } @@ -70,7 +76,13 @@ public final class OpenCvLoader { if (libraryLoaded) { return; } - RuntimeLoader.loadLibrary(Core.NATIVE_LIBRARY_NAME); + try { + RuntimeLoader.loadLibrary(Core.NATIVE_LIBRARY_NAME); + } catch (IOException e) { + e.printStackTrace(); + // Try adding a debug postfix + RuntimeLoader.loadLibrary(Core.NATIVE_LIBRARY_NAME + "d"); + } libraryLoaded = true; }