Skip to content

Commit e949152

Browse files
committed
added conditional removal of linux32 dirs from path for arm devices
1 parent 91ff4be commit e949152

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎src/gab/opencv/OpenCV.java‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public class OpenCV {
105105
private PImage inputImage;
106106

107107
private boolean nativeLoaded;
108+
private boolean isArm = false;
108109

109110
public CascadeClassifier classifier;
110111
BackgroundSubtractorMOG backgroundSubtractor;
@@ -400,8 +401,7 @@ private void initNative(){
400401
path = nativeLibPath + "macosx" + bitsJVM;
401402
}
402403
if (PApplet.platform == PConstants.LINUX) { //platform Linux
403-
// attempt to detect arm architecture
404-
boolean isArm = false;
404+
// attempt to detect arm architecture
405405
if (osArch.contains("arm")) {
406406
System.out.println("OS Architecture contains ARM");
407407
isArm = true;
@@ -443,7 +443,16 @@ private void initNative(){
443443
private void addLibraryPath(String path) throws Exception {
444444
System.out.println("Adding libarary path: " + path);
445445
String originalPath = System.getProperty("java.library.path");
446-
System.setProperty("java.library.path", path + System.getProperty("path.separator") + originalPath);
446+
447+
// If this is an arm device running linux, Processing seems to include the linux32 dirs in the path,
448+
// which conflict with the arm-specific libs. So we remove the linux32 segments from the path:
449+
if (isArm) {
450+
if (originalPath.indexOf("linux32") != -1) {
451+
originalPath = originalPath.replaceAll(":[^:]*?linux32", "");
452+
}
453+
}
454+
455+
System.setProperty("java.library.path", originalPath +System.getProperty("path.separator")+ path);
447456

448457
//set sys_paths to null
449458
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");

0 commit comments

Comments
 (0)