From 1e4e491b100683d1494309dfc06245509d312cf7 Mon Sep 17 00:00:00 2001 From: yunica Date: Sun, 20 Nov 2022 00:05:18 -0500 Subject: [PATCH] improve setup opencv --- README.md | 2 +- build.gradle.kts | 2 +- .../JosmMagicWand/MainJosmMagicWandPlugin.java | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2d90d4b..4ed9b4e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ This functionality allows you to merge several geometries into one, the geometri ## Requirements -- Java JDK 11. +- Java JDK 11+. - JOSM 18193 or higher. ## Extra options diff --git a/build.gradle.kts b/build.gradle.kts index bc35e4f..cc26613 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "org.openstreetmap.josm.plugins.devseed.JosmMagicWand" -version = "1.0-SNAPSHOT" +version = "1.1" java { toolchain { diff --git a/src/org/openstreetmap/josm/plugins/devseed/JosmMagicWand/MainJosmMagicWandPlugin.java b/src/org/openstreetmap/josm/plugins/devseed/JosmMagicWand/MainJosmMagicWandPlugin.java index 60d001a..ef7ca89 100644 --- a/src/org/openstreetmap/josm/plugins/devseed/JosmMagicWand/MainJosmMagicWandPlugin.java +++ b/src/org/openstreetmap/josm/plugins/devseed/JosmMagicWand/MainJosmMagicWandPlugin.java @@ -12,7 +12,7 @@ import org.openstreetmap.josm.gui.MapFrame; import org.openstreetmap.josm.plugins.Plugin; import org.openstreetmap.josm.plugins.PluginInformation; -import org.opencv.core.Core; +import org.openstreetmap.josm.tools.Logging; import javax.swing.*; @@ -31,8 +31,18 @@ public static LatLon eastNorth2latlon(EastNorth p) { public MainJosmMagicWandPlugin(PluginInformation info) { super(info); - nu.pattern.OpenCV.loadShared(); - System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + try { + System.out.println(Double.parseDouble(System.getProperty("java.specification.version"))); + if (Double.parseDouble(System.getProperty("java.specification.version")) >= 12) { + nu.pattern.OpenCV.loadLocally(); + } else { + nu.pattern.OpenCV.loadShared(); + } + } catch (Exception e) { + Logging.error(e.getMessage()); + throw new RuntimeException(e); + } + JMenu jToolmenu = MainApplication.getMenu().toolsMenu; jToolmenu.addSeparator(); MainMenu.add(jToolmenu, new MergeSelectAction());