GithubHelp home page GithubHelp logo

mjunaidi / opencv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from patternconsulting/opencv

0.0 1.0 0.0 39.42 MB

OpenCV Java bindings packaged with native libraries, seamlessly delivered as a turn-key Maven dependency.

License: Other

opencv's Introduction

OpenCV 2.4.9 (packaged by Pattern)

Build Status

OpenCV Java bindings packaged with native libraries, seamlessly delivered as a turn-key Maven dependency.

Usage

Project

Pattern's OpenCV package is added to your project as any other dependency.

<project>
  
  <!-- ... -->
  
  <dependencies>
    
    <!-- ... -->
    
    <dependency>
      <groupId>nu.pattern</groupId>
      <artifactId>opencv</artifactId>
      <version>2.4.9-7</version>
    </dependency>
    
    <!-- ... -->
    
  </dependencies>
  
  <!-- ... -->
  
</project>
// ...

libraryDependencies += "nu.pattern" % "opencv" % "2.4.9-7"

// ...

API

Typically, using the upstream OpenCV Java bindings involves loading the native library as follows:

static {
  System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
}

Fortunately, this is unchanged except for one caveat. To use the native libraries included with this package, first call nu.pattern.OpenCV.loadShared().

This call will—exactly once per class loader—first attempt to load from the system-wide installation (exactly as if System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME); were called without any preceding steps). If that fails, the loader will select a binary from the package appropriate for the runtime environment's operating system and architecture. It will write that native library to a temporary directory (also defined by the environment), add that directory to java.library.path. This involves writing to disk, so consider the implications. Temporary files will be garbage-collected on clean shutdown.

This approach keeps most clients decoupled from Pattern's package and loader. As long as this is done sufficiently early in execution, any library using the OpenCV Java bindings can use the usual load call as documented by the OpenCV project.

There are, however, cases where Java class loaders are frequently changing (e.g., application servers, SBT projects, Scala worksheets), and spurious attempts to load the native library will result in JNI errors. As a partial work-around, this package offers an alternative API, nu.pattern.OpenCV.loadLocal(), which—also exactly once per class loader—extracts the binary appropriate for the runtime platform, and passes it to System#load(String). Ultimately, this may eventually load the library redundantly in the same JVM, which could be unsafe in production. Use with caution and understand the implications.

It's recommended developers using any JNI library read further:

Debugging

Java logging is used to produce log messages from nu.pattern.OpenCV.

Rationale

Developers wishing to use the Java API for OpenCV would typically go through the process of building the project, and building it for each platform they wished to support (e.g., 32-bit Linux, OS X). This project provides those binaries for inclusion as a typical dependency in Maven, Ivy, and SBT projects.

Apart from testing, this package deliberately specifies no external dependencies. It does, however, make use of modern Java APIs (such as Java NIO).

Contributing

Producing native binaries is the most cumbersome process in maintaining this package. If you can contribute binaries for the current version, please make a pull request including the build artifacts and any platform definitions in nu.pattern.OpenCV.

Support

The following platforms are supported by this package:

OS Architecture
OS X x86_32
OS X x86_64
Linux x86_64
Linux x86_32

If you can help create binaries for additional platforms, please see notes under Contributing.

Credits

This package is maintained by Michael Ahlers.

Acknowledgements

opencv's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.