Skip to content

Commit

Permalink
Adding arch/linux binaries for Raspberry Pi
Browse files Browse the repository at this point in the history
  • Loading branch information
adambenhamo committed Jul 15, 2017
1 parent 6ea1c62 commit 6ce3db9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ target
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.m2e.core.prefs
opencv/**
.metadata/
15 changes: 10 additions & 5 deletions src/main/java/nu/pattern/OpenCV.java
Expand Up @@ -24,6 +24,8 @@ public class OpenCV {

private final static Logger logger = Logger.getLogger(OpenCV.class.getName());



static enum OS {
OSX("^[Mm]ac OS X$"),
LINUX("^[Ll]inux$"),
Expand Down Expand Up @@ -64,7 +66,8 @@ public static OS getCurrent() {

static enum Arch {
X86_32("i386", "i686", "x86"),
X86_64("amd64", "x86_64");
X86_64("amd64", "x86_64"),
ARMv8("arm");

private final Set<String> patterns;

Expand Down Expand Up @@ -111,7 +114,7 @@ public TemporaryDirectory() {
public Path getPath() {
return path;
}

public TemporaryDirectory deleteOldInstancesOnStart() {
Path tempDirectory = path.getParent();

Expand Down Expand Up @@ -330,6 +333,9 @@ private static Path extractNativeBinary(final OS os, final Arch arch) {
case X86_64:
location = "/nu/pattern/opencv/linux/x86_64/libopencv_java320.so";
break;
case ARMv8:
location = "/nu/pattern/opencv/linux/ARMv8/libopencv_java320.so";
break;
default:
throw new UnsupportedPlatformException(os, arch);
}
Expand Down Expand Up @@ -363,7 +369,7 @@ private static Path extractNativeBinary(final OS os, final Arch arch) {

final InputStream binary = OpenCV.class.getResourceAsStream(location);
final Path destination;

// Do not try to delete the temporary directory on the close if Windows
// because there will be a write lock on the file which will cause an
// AccessDeniedException. Instead, try to delete existing instances of
Expand All @@ -373,7 +379,7 @@ private static Path extractNativeBinary(final OS os, final Arch arch) {
} else {
destination = new TemporaryDirectory().markDeleteOnExit().getPath().resolve("./" + location).normalize();
}

try {
logger.log(Level.FINEST, "Copying native binary to \"{0}\".", destination);
Files.createDirectories(destination.getParent());
Expand All @@ -387,4 +393,3 @@ private static Path extractNativeBinary(final OS os, final Arch arch) {
return destination;
}
}

Binary file not shown.

0 comments on commit 6ce3db9

Please sign in to comment.