Giter Site home page Giter Site logo

bytedeco / sbt-javacv Goto Github PK

View Code? Open in Web Editor NEW
90.0 8.0 14.0 50 KB

Start using OpenCV in your JVM project in just 1 line, no separate compiling, installing OpenCV, or fussing with your system required

License: MIT License

Scala 25.07% Java 74.93%
javacv opencv-java sbt-plugin scala computer-vision

sbt-javacv's Introduction

SBT-JavaCV

Join the chat at https://gitter.im/bytedeco/sbt-javacv Maven Central Build Status

Makes it easy to start playing around with OpenCV (via JavaCV) in Scala without having to compile or install OpenCV on your own.

Configures the following dependencies in your project:

  • JavaCV
  • JavaCPP
  • JavaCPP Presets

Usage

In your project/plugins.sbt:

addSbtPlugin("org.bytedeco" % "sbt-javacv" % version)

See the Maven badge for latest version.

Customisation

By default, this plugin will download the appropriate binaries for the platform of the computer currently running SBT, you can modify this by setting it to another platform (for example, if you want to compile JARs to be run on other platforms)

javaCppPlatform := "android-arm"

For more details, see the SBT-JavaCPP plugin

Also, this plugin only pulls in opencv JavaCPP preset by default. If you wish to add more, use the javaCppPresetLibs settings key and use ++= to append more (if you do not use append, you will end up wiping out the ones this plugin appends by default):

javaCppPresetLibs ++= Seq(
  "ffmpeg" -> "3.4.1"
)

Note when upgrading from versions < 1.16:

As of JavaCPP 1.4 videoinput is only available for windows, so it's not included by default since sbt-javacv 1.16. If you need it, you can add it just like any other JavaCPP preset:

javaCppPresetLibs ++= Seq(
  "videoinput" -> "0.200"
)

sbt-javacv's People

Contributors

gitter-badger avatar lloydmeta avatar sbrunk avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-javacv's Issues

update to 1.2

Please, update preset loading to 1.2 (it is 1.1 right now)

Getting an error trying to include ffmpeg

when I add this line to my build.sbt
javaCppPresetLibs ++= Seq("ffmpeg" -> "2.8.1")

I get this error refreshing the sbt project:
error sbt.ResolveException: unresolved dependency: org.bytedeco.javacpp-presets#ffmpeg;2.8.1-1.2: not found
[error] Total time: 5 s, completed Sep 29, 2016 4:35:35 PM
See complete log in C:\Users\Dave.IntelliJIdea2016.2\system\log\sbt.last.log

Include path of binaries creating an error

With version 1.10 (sbt-opencv) w're getting (2 developer different machines) the following error regarding the including of the binaries.

com.google.inject.CreationException: Unable to create injector, see the following errors:
[info] 
[info] 1) Error injecting constructor, java.lang.UnsatisfiedLinkError: no jniopencv_face in java.library.path
[info]   at library.GenderRecognition.<init>(GenderRecognition.scala:109)
[info]   at Module.configure(Module.scala:21) (via modules: com.google.inject.util.Modules$OverrideModule -> Module)
[info]   while locating library.GenderRecognition
[info] 
[info] 1 error
[info]   at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466)
[info]   at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
[info]   at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
[info]   at com.google.inject.Guice.createInjector(Guice.java:96)
[info]   at com.google.inject.Guice.createInjector(Guice.java:84)
[info]   at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
[info]   at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
[info]   at org.scalatestplus.play.OneAppPerTest$class.newAppForTest(OneAppPerTest.scala:71)
[info]   at FaceDetectionTest.newAppForTest(FaceDetectionTest.scala:11)
[info]   at org.scalatestplus.play.OneAppPerTest$class.withFixture(OneAppPerTest.scala:88)
[info]   ...
**[info]   Cause: java.lang.UnsatisfiedLinkError: no jniopencv_face in java.library.path**
[info]   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
[info]   at java.lang.Runtime.loadLibrary0(Runtime.java:870)
[info]   at java.lang.System.loadLibrary(System.java:1122)
[info]   at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:727)
[info]   at org.bytedeco.javacpp.Loader.load(Loader.java:502)
[info]   at org.bytedeco.javacpp.Loader.load(Loader.java:419)
[info]   at org.bytedeco.javacpp.opencv_face.<clinit>(opencv_face.java:13)
[info]   at library.GenderRecognition.<init>(GenderRecognition.scala:21)
[info]   at library.GenderRecognition$$FastClassByGuice$$53415250.newInstance(<generated>)
[info]   at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
[info]   ...
[info]   Cause: java.lang.UnsatisfiedLinkError: /private/var/folders/td/9xc91ttn3bx5m0f0wr7bh9900000gn/T/javacpp45557842528326/libjniopencv_face.dylib: dlopen(/private/var/folders/td/9xc91ttn3bx5m0f0wr7bh9900000gn/T/javacpp45557842528326/libjniopencv_face.dylib, 1): Library not loaded: @rpath/libopencv_objdetect.3.1.dylib
[info]   Referenced from: **/private/var/folders/td/9xc91ttn3bx5m0f0wr7bh9900000gn/T/javacpp45557842528326/./libopencv_face.3.1.dylib**
[info]   Reason: image not found
[info]   at java.lang.ClassLoader$NativeLibrary.load(Native Method)
[info]   at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
[info]   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
[info]   at java.lang.Runtime.load0(Runtime.java:809)
[info]   at java.lang.System.load(System.java:1086)
[info]   at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:710)
[info]   at org.bytedeco.javacpp.Loader.load(Loader.java:502)
[info]   at org.bytedeco.javacpp.Loader.load(Loader.java:419)
[info]   at org.bytedeco.javacpp.opencv_face.<clinit>(opencv_face.java:13)
[info]   at library.GenderRecognition.<init>(GenderRecognition.scala:21)

not working on macos x

Added the addSbtPlugin("org.bytedeco" % "sbt-javacv" % "1.17")

Got

Caused by: java.lang.UnsatisfiedLinkError: no opencv_java343 in java.library.path

when calling

System.loadLibrary(Core.NATIVE_LIBRARY_NAME)

Not working on Windows 10

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: putMemberOffset
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1083)
    at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:637)
    at org.bytedeco.javacpp.Loader.load(Loader.java:492)
    at org.bytedeco.javacpp.Loader.load(Loader.java:409)
    at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:344)
    at org.bytedeco.javacpp.Loader.load(Loader.java:464)
    at org.bytedeco.javacpp.Loader.load(Loader.java:409)
    at org.bytedeco.javacpp.opencv_imgcodecs.<clinit>(opencv_imgcodecs.java:13)
    at opencv2_cookbook.chapter01.Ex2MyFirstGUIApp$.opencv2_cookbook$chapter01$Ex2MyFirstGUIApp$$openImage(Ex2MyFirstGUIApp.scala:130)
    at opencv2_cookbook.chapter01.Ex2MyFirstGUIApp$$anon$2$$anonfun$1.apply$mcV$sp(Ex2MyFirstGUIApp.scala:55)
    at scala.swing.Action$$anon$2.apply(Action.scala:65)
    at scala.swing.Action$$anon$1.actionPerformed(Action.scala:83)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6525)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6290)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2278)
    at java.awt.Window.dispatchEventImpl(Window.java:2739)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:719)
    at java.awt.EventQueue$4.run(EventQueue.java:717)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

More details.

Its creating a directory at C:\Users\philip\AppData\Local\Temp\javacpp105687008440412

It downloads these files

msvcp120.dll
msvcr120.dll
opencv_core300.dll
opencv_imgproc300.dll
jniopencv_core.dll

I think it fails on jniopencv_core.dll

The exception is thrown on this line

tempFile.deleteOnExit();

In file Loader.java

Automatically resolve latest version ?

An idea came up to look up the latest JavaCV version on Maven Central and use that as javaCVVersion. This is possible, but should be a bit better thought out to help with the following assumptions:

  1. it assumes the ability to connect to Maven Central for the query
  2. should probably have a fallback to a default version if querying fails
  3. assumes that the user is ok with arbitrarily using the latest version, which can cause major compilation or runtime issues

java.lang.UnsatisfiedLinkError: no jniopencv_videoio in java.library.path due to java.lang.UnsatisfiedLinkError: ... (libgtk-x11-2.0.so.0)

Hi,

I'm running scala (compiled using sbt) app that uses several OpenCV's functionalities. Eventually I managed to run some of them, but I still encounter the following exception:

Name: java.lang.NoClassDefFoundError
Message: Could not initialize class org.bytedeco.javacpp.opencv_objdetect$CascadeClassifier
StackTrace:

Notes:

  1. My project/plugins.sbt file looks like this:
logLevel := Level.Warn
resolvers += Resolver.sonatypeRepo("releases")
addSbtPlugin("org.bytedeco" % "sbt-javacv" % "1.12")
  1. My build.sbt looks like this:
name := "..."
version := "1.0"
scalaVersion := "2.11.8"
javaCppPresetLibs ++= Seq("opencv" -> "3.1.0", "ffmpeg" -> "3.1.2")
javaCppPlatform := Seq("linux-x86_64")
  1. I'm coding+debugging on Windows machine where everything runs smoothly. Then I tried adding the linux-x86_64 platform to the build.sbt as in (2) and use sbt-assembly to package my linux-ready jar. I uploaded that jar into my linux cluster, then cloned the 3.1.0 version of opencv from https://github.com/Itseez/opencv and ran cmake, make and make install.

  2. Finally, in scala, this piece of code works great (uses org.bytedeco.javacpp.opencv_imgcodecs & org.bytedeco.javacpp.opencv_imgproc):

import org.bytedeco.javacpp.BytePointer
import org.bytedeco.javacpp.opencv_core.{Mat, _}
import org.bytedeco.javacpp.opencv_imgcodecs._
import org.bytedeco.javacpp.opencv_imgproc._
import org.bytedeco.javacpp.opencv_objdetect.CascadeClassifier
 
val bytes = ByteBuffer.wrap( /* some Byte array */ )
val imgCvMat = cvDecodeImageM(cvMat(1, bytes .array().length, CV_8UC1, new BytePointer(bytes )))
val imgMat = cvarrToMat(imgCvMat)

while this code:

val faceCascade = new org.bytedeco.javacpp.opencv_objdetect.CascadeClassifier( /* path to xml of classifier configuration */ )

fails with the following exception:

java.lang.UnsatisfiedLinkError: no jniopencv_videoio in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:784)
at org.bytedeco.javacpp.Loader.load(Loader.java:586)
at org.bytedeco.javacpp.Loader.load(Loader.java:503)
at org.bytedeco.javacpp.opencv_videoio.(opencv_videoio.java:14)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.bytedeco.javacpp.Loader.load(Loader.java:558)
at org.bytedeco.javacpp.Loader.load(Loader.java:503)
at org.bytedeco.javacpp.opencv_objdetect$CascadeClassifier.(opencv_objdetect.java:566)
... 52 elided
Caused by: java.lang.UnsatisfiedLinkError: /home/hadoop/.javacpp/cache/mlageinf.jar/org/bytedeco/javacpp/linux-x86_64/libjniopencv_videoio.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:767)
... 60 more

Note that theeres a missing libgtk-x11-2.0.so.0 - and I can't figure out what to do here

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.