bytedeco / javacpp-presets Goto Github PK
View Code? Open in Web Editor NEWThe missing Java distribution of native C++ libraries
License: Other
The missing Java distribution of native C++ libraries
License: Other
centos 6 x86_64
I follow this installation as i need perticular version of opencv i.e 2.4.9
http://random-tinkering.rhcloud.com/?p=68
I ran the opencv example program successfully given on above link.
Then i tried to run sample javacv program provided on following link
https://github.com/bytedeco/javacv
i add necessary jar files and libopencv_java249.so file to the sample project
import static org.bytedeco.javacpp.opencv_core.;
import static org.bytedeco.javacpp.opencv_imgproc.;
import static org.bytedeco.javacpp.opencv_highgui.*;
public class Smoother {
public static void smooth(String filename) {
IplImage image = cvLoadImage(filename);
if (image != null) {
cvSmooth(image, image);
cvSaveImage(filename, image);
cvReleaseImage(image);
}
}
}
it ran successfully on ubuntu 14 but giving this error on raspbian
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:536)
at org.bytedeco.javacpp.Loader.load(Loader.java:411)
at org.bytedeco.javacpp.Loader.load(Loader.java:354)
at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at org.bytedeco.javacpp.Loader.load(Loader.java:386)
at org.bytedeco.javacpp.Loader.load(Loader.java:354)
at org.bytedeco.javacpp.opencv_highgui.(opencv_highgui.java:13)
at javacvproj.JavacvProj.main(JavacvProj.java:31)
Caused by: java.lang.UnsatisfiedLinkError: no tbb in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:536)
at org.bytedeco.javacpp.Loader.load(Loader.java:402)
... 8 more
Java Result: 1
Using version 0.10 on Ubuntu Trusty. Everything works fine until ffmpeg/cppbuild.sh tries to compile ffmpeg, quitting with "ERROR: openssl not found". Any thoughts?
And therefore it does not load on Ubuntu 12.04. Tried to compile it on my system but that leads to SIGSEGV. Runnable example is https://github.com/jjYBdx4IL/misc/blob/master/src/test/java/jjybdx4il/javacv/examples/FFmpegTest.java at https://github.com/jjYBdx4IL/misc/ .
* java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path
* at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
* at java.lang.Runtime.loadLibrary0(Runtime.java:849)
* at java.lang.System.loadLibrary(System.java:1088)
* at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
* at org.bytedeco.javacpp.Loader.load(Loader.java:410)
* at org.bytedeco.javacpp.Loader.load(Loader.java:353)
* at org.bytedeco.javacpp.avutil.<clinit>(avutil.java:10)
* at java.lang.Class.forName0(Native Method)
* at java.lang.Class.forName(Class.java:274)
* at org.bytedeco.javacpp.Loader.load(Loader.java:385)
* at org.bytedeco.javacpp.Loader.load(Loader.java:353)
* at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
* at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
* at jjybdx4il.javacv.examples.FFmpegTest.test(FFmpegTest.java:20)
* at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
* at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
* at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
* at java.lang.reflect.Method.invoke(Method.java:606)
* at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
* at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
* at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
* at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
* at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
* at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
* at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
* at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
* at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
* at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
* at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
* at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
* at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
* at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
* at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
* at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
* at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
* at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
* at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
* at java.lang.reflect.Method.invoke(Method.java:606)
* at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
* at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
* at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
* at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
* at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
* Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp341118125695795/libjniavutil.so: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by /tmp/javacpp341118125695795/libavutil.so.52)
* at java.lang.ClassLoader$NativeLibrary.load(Native Method)
* at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
* at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
* at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
* at java.lang.Runtime.load0(Runtime.java:795)
* at java.lang.System.load(System.java:1062)
* at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:524)
* ... 39 more
saturateCastUchar(-18) returns -1, which saturateCastUchar(-18) & 0xff is 255
but in opencv c++, saturate_cast(-18) returns 0
java -cp "/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.35.x86_64/jre/lib/ext/*:" caffe train -solver ../caffe-master/examples/mnist/lenet_solver.prototxt
while running this command,
i get following error..
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:844)
at java.lang.System.loadLibrary(System.java:1051)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:536)
at org.bytedeco.javacpp.Loader.load(Loader.java:411)
at org.bytedeco.javacpp.Loader.load(Loader.java:354)
at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.bytedeco.javacpp.Loader.load(Loader.java:386)
at org.bytedeco.javacpp.Loader.load(Loader.java:354)
at org.bytedeco.javacpp.caffe$SolverParameter.(caffe.java:1704)
at caffe$2.command(caffe.java:177)
at caffe.main(caffe.java:391)
Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp4072173147710/libjniopencv_core.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /tmp/javacpp4072173147710/libjniopencv_core.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
at java.lang.Runtime.load0(Runtime.java:790)
at java.lang.System.load(System.java:1025)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:525)
... 10 more
Whether it is related to environmental issue or running isssue??
I am using Centos 6.7 with GLIBC_2.12.
Whether i need to upgrade glibc ??
Hello!
First of all - I will mention that I am new to using JNI so my problem may be a bit noobish.
I am trying to get tesseract to work on Android. I am using a Windows machine to develop so I decided to use precompiled libs from maven as there would be probably a lot of problems with lack of needed dependency libs.
I am using Gradle so I have added in dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile fileTree(dir: 'jniLibs', include: ['*.so'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:21.0.3'
// compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.octo.android.robospice:robospice:1.4.14'
compile 'com.octo.android.robospice:robospice-okhttp:1.4.14'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'org.bytedeco.javacpp-presets:tesseract:3.03-rc1-0.10'
compile 'org.bytedeco.javacpp-presets:tesseract:3.03-rc1-0.10:android-arm'
compile 'org.bytedeco.javacpp-presets:leptonica:1.71-0.10:android-arm'
}
Everything seems fine, tesseract is being seen, lept as well, but then:
02-20 23:24:11.812 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น No JNI_OnLoad found in /system/lib/libc.so 0x40513af8, skipping init
02-20 23:24:11.812 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น No JNI_OnLoad found in /system/lib/libm.so 0x40513af8, skipping init
02-20 23:24:11.816 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น No JNI_OnLoad found in /system/lib/libz.so 0x40513af8, skipping init
02-20 23:24:11.816 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น No JNI_OnLoad found in /system/lib/libdl.so 0x40513af8, skipping init
02-20 23:24:11.820 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น No JNI_OnLoad found in /system/lib/liblog.so 0x40513af8, skipping init
02-20 23:24:11.820 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น Trying to load lib /data/data/pl.seweryn.dariusz.pogodaicm/lib/liblept.so 0x40513af8
02-20 23:24:11.894 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น Added shared lib /data/data/pl.seweryn.dariusz.pogodaicm/lib/liblept.so 0x40513af8
02-20 23:24:11.894 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น No JNI_OnLoad found in /data/data/pl.seweryn.dariusz.pogodaicm/lib/liblept.so 0x40513af8, skipping init
02-20 23:24:11.894 5231-5231/pl.seweryn.dariusz.pogodaicm D/dalvikvm๏น Trying to load lib /data/data/pl.seweryn.dariusz.pogodaicm/lib/libjnilept.so 0x40513af8
02-20 23:24:11.949 5231-5231/pl.seweryn.dariusz.pogodaicm W/dalvikvm๏น Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/bytedeco/javacpp/lept;
02-20 23:24:11.949 5231-5231/pl.seweryn.dariusz.pogodaicm W/dalvikvm๏น Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lorg/bytedeco/javacpp/tesseract$TessBaseAPI;
02-20 23:24:11.957 5231-5231/pl.seweryn.dariusz.pogodaicm D/AndroidRuntime๏น Shutting down VM
02-20 23:24:11.957 5231-5231/pl.seweryn.dariusz.pogodaicm W/dalvikvm๏น threadid=1: thread exiting with uncaught exception (group=0x40015578)
02-20 23:24:12.000 5231-5231/pl.seweryn.dariusz.pogodaicm E/AndroidRuntime๏น FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at pl.seweryn.dariusz.pogodaicm.ActivityMain.onStart(ActivityMain.java:70)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
at android.app.Activity.performStart(Activity.java:3791)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:234)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.tesseract$TessBaseAPI.<clinit>(tesseract.java:3070)
ย ย ย ย ย ย ย ย ย ย ย ย at pl.seweryn.dariusz.pogodaicm.ActivityMain.onStart(ActivityMain.java:70)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.Activity.performStart(Activity.java:3791)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.access$1500(ActivityThread.java:117)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Handler.dispatchMessage(Handler.java:99)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Looper.loop(Looper.java:123)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.main(ActivityThread.java:3687)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invokeNative(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invoke(Method.java:507)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
ย ย ย ย ย ย ย ย ย ย ย ย at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1963]: 82 could not load needed library 'liblept.so.4' for 'libjnilept.so' (load_library[1105]: Library 'liblept.so.4' not found)
at java.lang.Runtime.loadLibrary(Runtime.java:434)
at java.lang.System.loadLibrary(System.java:554)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.lept.<clinit>(lept.java:10)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Class.classForName(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Class.forName(Class.java:234)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:385)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:353)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.tesseract$TessBaseAPI.<clinit>(tesseract.java:3070)
ย ย ย ย ย ย ย ย ย ย ย ย at pl.seweryn.dariusz.pogodaicm.ActivityMain.onStart(ActivityMain.java:70)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.Activity.performStart(Activity.java:3791)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.access$1500(ActivityThread.java:117)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Handler.dispatchMessage(Handler.java:99)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Looper.loop(Looper.java:123)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.main(ActivityThread.java:3687)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invokeNative(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invoke(Method.java:507)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
ย ย ย ย ย ย ย ย ย ย ย ย at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gnustl_static: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:429)
at java.lang.System.loadLibrary(System.java:554)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:401)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:353)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.lept.<clinit>(lept.java:10)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Class.classForName(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Class.forName(Class.java:234)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:385)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:353)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.tesseract$TessBaseAPI.<clinit>(tesseract.java:3070)
ย ย ย ย ย ย ย ย ย ย ย ย at pl.seweryn.dariusz.pogodaicm.ActivityMain.onStart(ActivityMain.java:70)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.Activity.performStart(Activity.java:3791)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.access$1500(ActivityThread.java:117)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Handler.dispatchMessage(Handler.java:99)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Looper.loop(Looper.java:123)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.main(ActivityThread.java:3687)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invokeNative(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invoke(Method.java:507)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
ย ย ย ย ย ย ย ย ย ย ย ย at dalvik.system.NativeStart.main(Native Method)
As a bit of background - I try to run the application and create a new TessBaseAPI()
on a Samsung Galaxy S1 (old but gold) with Android 2.3.3.
As I was googling around for a solution I have found some page which makes me think:
Thank you in advance.
Best Regards
I build my project by maven with dependens:
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>0.10</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>2.4.10-0.10</version>
</dependency>
And programm crashes with this trace:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
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:274)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.helper.opencv_core$AbstractCvMemStorage.<clinit>(opencv_core.java:2347)
at eu.indev_group.opencv.car_tracking.app.main(app.java:47)
Caused by: java.lang.UnsatisfiedLinkError: no opencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:401)
... 8 more
line 48:
CvMemStorage templates_storage = CvMemStorage.create();
I have this java-code from your example-page.
I set the TESSDATA_PREFIX=/usr/share/tesseract-ocr/tessdata to match my local ubuntu-installation of tesseract.
import org.bytedeco.javacpp.*;
import static org.bytedeco.javacpp.lept.*;
public class TesseractSample {
public static void main(String[] args) {
BytePointer outText;
tesseract.TessBaseAPI api = new tesseract.TessBaseAPI();
// Initialize tesseract-ocr with English, without specifying tessdata path
if (api.Init(null, "eng") != 0) {
System.err.println("Could not initialize tesseract.");
System.exit(1);
}
// Open input image with leptonica library
PIX image = pixRead(args.length > 0 ? args[0] : TesseractSample.class.getResource("/newBoard.png").getFile());
api.SetImage(image);
// Get OCR result
outText = api.GetUTF8Text();
System.out.println("OCR output:\n" + outText.getString());
// Destroy used object and release memory
api.End();
outText.deallocate();
pixDestroy(image);
}
}
It causes the JVM to crash.
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000304085203b, pid=27392, tid=139897653995264
#
# JRE version: Java(TM) SE Runtime Environment (8.0_40-b25) (build 1.8.0_40-b25)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.40-b25 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libtesseract.so.3+0x25203b] ERRCODE::error(char const*, TessErrorLogCode, char const*, ...) const+0x16b
You find the full log here: gist.github.com/FloWi/d632ed69315424348d1f
Any idea, what is wrong?
I'm completely lost in c++-land ;-)
Hi, thank you for this fantastic project. I imported the library, an it works.
I would like to use atlas blas implementation for the blas part of gsl. In c, that would mean changing the make file to link libcblas and/or atlas instead of libgslblas. However, javacpp provides the prepackaged build that ignores system's files and uses the one provided in a platform jar.
Is there a way to specify which (shared) libraries to use instead of the ones provided inside jars?
If I'd have to build javacpp's gsl manually, where should i change the libcblas setting?
For some reason, my program crashes when FrameGrabber.start() is invoked.
I'm not sure what I'm doing wrong, I'm new android programming. I've searched for similar cases. Haven't found one posted on the web yet which is similar to mine.
Any help would be greatly appreciated.
This is the code I've implemented.
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ffile);
//VideoView display = (VideoView)findViewById(R.id.videoView1);
Intent intent = getIntent();
FilePath = intent.getStringExtra("path");
//display.setVideoPath(FilePath);
FFmpegFrameGrabber vidcap = new FFmpegFrameGrabber(FilePath);
Log.i(camera.TAG, "inited");
try {
vidcap.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Once start() is invoked, exception is raised during runtime and the app crashes. The library:
05-07 10:50:52.045: E/AndroidRuntime(31417): FATAL EXCEPTION: main
05-07 10:50:52.045: E/AndroidRuntime(31417): Process: test.trackerproto, PID: 31417
05-07 10:50:52.045: E/AndroidRuntime(31417): java.lang.NoClassDefFoundError: org.bytedeco.javacpp.avcodec
05-07 10:50:52.045: E/AndroidRuntime(31417): at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:340)
05-07 10:50:52.045: E/AndroidRuntime(31417): at test.trackerproto.Saved_process.onCreate(Saved_process.java:31)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.Activity.performCreate(Activity.java:5248)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.ActivityThread.access$800(ActivityThread.java:139)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.os.Handler.dispatchMessage(Handler.java:102)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.os.Looper.loop(Looper.java:136)
05-07 10:50:52.045: E/AndroidRuntime(31417): at android.app.ActivityThread.main(ActivityThread.java:5086)
05-07 10:50:52.045: E/AndroidRuntime(31417): at java.lang.reflect.Method.invokeNative(Native Method)
05-07 10:50:52.045: E/AndroidRuntime(31417): at java.lang.reflect.Method.invoke(Method.java:515)
05-07 10:50:52.045: E/AndroidRuntime(31417): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
05-07 10:50:52.045: E/AndroidRuntime(31417): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-07 10:50:52.045: E/AndroidRuntime(31417): at dalvik.system.NativeStart.main(Native Method)
I tried executing through libraries installed by maven and I get a exception at initialization of FFmpegFrameGrabber. This is the logcat for MAVEN LIBS
05-07 11:14:29.690: E/AndroidRuntime(4112): FATAL EXCEPTION: main
05-07 11:14:29.690: E/AndroidRuntime(4112): Process: test.trackerproto, PID: 4112
05-07 11:14:29.690: E/AndroidRuntime(4112): java.lang.NoClassDefFoundError: org.bytedeco.javacv.FFmpegFrameGrabber
05-07 11:14:29.690: E/AndroidRuntime(4112): at test.trackerproto.Saved_process.onCreate(Saved_process.java:28)
05-07 11:14:29.690: E/AndroidRuntime(4112): at android.app.Activity.performCreate(Activity.java:5248)
05-07 11:14:29.690: E/AndroidRuntime(4112): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
05-07 11:14:29.690: E/AndroidRuntime(4112): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
05-07 11:14:29.690: E/AndroidRuntime(4112): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
05-07 11:14:29.690: E/AndroidRuntime(4112): at android.app.ActivityThread.access$800(ActivityThread.java:139)
05-07 11:14:29.690: E/AndroidRuntime(4112): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
I use eclipse kepler, win 8.1, javacv 0.11 and maven complier plugin 3.1
I am not sure what I did wrong! I am new at this, if I missed out on any information or presented things in wrong format, please forgive me and let me know, so that I learn. Thanks in advance for the help!
I'm basically trying to reduce the size of the binaries by disabling features I don't need.
It works perfectly fine with enabling a few encoders, but when I try to enable only the decoders as below, the error throws up.
Compile flags;
./configure --prefix=.. \
--enable-shared \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-runtime-cpudetect \
--disable-iconv \
--disable-libxcb \
--disable-opencl \
--disable-outdev=sdl \
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-postproc \
--disable-debug \
--enable-optimizations \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-debug \
--disable-mmx \
--enable-small \
--enable-libx264 \
--enable-cross-compile \
--cross-prefix="$ANDROID_BIN-" \
--ranlib="$ANDROID_BIN-ranlib" \
--sysroot="$ANDROID_ROOT" \
--target-os=linux \
--arch=arm \
--extra-cflags="-I../include/ -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-\
a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" \
--extra-ldflags="$ANDROID_ROOT/usr/lib/crtbegin_so.o -L../lib/ -L$ANDROID_CPP/libs/armeabi/ -nostdlib -Wl,--fix-c\
ortex-a8" \
--extra-libs="-lgnustl_static -lgcc -ldl -lz -lm -lc" \
--disable-symver \
--disable-programs \
--disable-encoders \
--disable-decoders \
--enable-encoder=libx264 \
`#--enable-encoder=libx264rgb` \
--enable-encoder=h264_qsv \
--enable-encoder=pcm_s16le_planar \
--enable-encoder=aac \
--enable-decoder=h264 \
--enable-decoder=nellymoser \
--enable-decoder=aac \
--enable-decoder=pcm_s16le_planar \
Error output
890-940/? D/<package>๏น Could not load the Frame Grabber
<package>.utils.ffmpeg.FrameGrabber$Exception: Failed to load class <package>.utils.ffmpeg.CVFrameGrabber
at <package>.utils.ffmpeg.CVFrameGrabber.tryLoad(CVFrameGrabber.java:168)
at <package>.utils.Helpers$1.doInBackground(Helpers.java:927)
at <package>.utils.Helpers$1.doInBackground(Helpers.java:923)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_dct_init" referenced by "libjniavcodec.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:988)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:536)
at org.bytedeco.javacpp.Loader.load(Loader.java:411)
at org.bytedeco.javacpp.Loader.load(Loader.java:354)
at org.bytedeco.javacpp.avcodec.<clinit>(avcodec.java:13)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at org.bytedeco.javacpp.Loader.load(Loader.java:386)
at <package>.utils.ffmpeg.CVFrameGrabber.tryLoad(CVFrameGrabber.java:159)
ย ย ย ย ย ย ย ย ย ย ย ย at <package>.utils.Helpers$1.doInBackground(Helpers.java:927)
ย ย ย ย ย ย ย ย ย ย ย ย at <package>.utils.Helpers$1.doInBackground(Helpers.java:923)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.AsyncTask$2.call(AsyncTask.java:292)
ย ย ย ย ย ย ย ย ย ย ย ย at java.util.concurrent.FutureTask.run(FutureTask.java:237)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
ย ย ย ย ย ย ย ย ย ย ย ย at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
ย ย ย ย ย ย ย ย ย ย ย ย at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/<package>.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/<package>.debug-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libgnustl_static.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:988)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:536)
at org.bytedeco.javacpp.Loader.load(Loader.java:402)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:354)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.avcodec.<clinit>(avcodec.java:13)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Class.classForName(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Class.forName(Class.java:309)
ย ย ย ย ย ย ย ย ย ย ย ย at org.bytedeco.javacpp.Loader.load(Loader.java:386)
ย ย ย ย ย ย ย ย ย ย ย ย at <package>.utils.ffmpeg.CVFrameGrabber.tryLoad(CVFrameGrabber.java:159)
ย ย ย ย ย ย ย ย ย ย ย ย at <package>.utils.Helpers$1.doInBackground(Helpers.java:927)
ย ย ย ย ย ย ย ย ย ย ย ย at <package>.utils.Helpers$1.doInBackground(Helpers.java:923)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.AsyncTask$2.call(AsyncTask.java:292)
ย ย ย ย ย ย ย ย ย ย ย ย at java.util.concurrent.FutureTask.run(FutureTask.java:237)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
ย ย ย ย ย ย ย ย ย ย ย ย at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
ย ย ย ย ย ย ย ย ย ย ย ย at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.Thread.run(Thread.java:818)
could I use the caffe presets for image classification?
Hi all,
I've patched the ffmpeg/cppbuild.sh script to include support for libvpx (to encode WebM videos).
Here's the gist: https://gist.github.com/beligum/f4a46aac90b807aa6907
For now, it's only implemented for linux x64, since it's the only architecture I have access to. Sources are downloaded from the official Google repo.
Enabling compilation for other platforms should be trivial.
Feel free to post feedback, follow-up or suggestions.
b.
The current code works in android but since some optional parts use awt and that triggers lots of misleading warnings and the debugger is set on hold for each awt import.
Probably would be possible either replace the helper with a version w/out the awt code or replace such code with android-specific one (Rect vs Rectangle and such).
Do you think will be possible to add preset for Caffe?
Hi, @saudet ,
I run the commandline as README.md 's Build Instructions:
mvn install --projects ,opencv,ffmpeg
got the error on ubuntu15.04-server-64bit as below :
Failed to execute JavaCPP Builder: Could not parse "libavutil/avutil.h": File does not exist -> [Help 1]
And I fix it by
mvn install -Pandroid-arm -Dplatform.root=/home/pete/Downloads/android-ndk-r10c/ --projects ,opencv,ffmpeg
Maybe the README.md 's Build Instructions should enrich?
Simple call to DescriptorExtractor.create("SURF") results in exception. Here is a sample code:
import org.bytedeco.javacpp.opencv_features2d.DescriptorExtractor;
new DescriptorExtractor().create("SURF");
Exception:
java.lang.NullPointerException: This pointer address is NULL.
at org.bytedeco.javacpp.opencv_features2d$DescriptorExtractor.create(Native Method)
....
Hi,
I'm having trouble compiling the presets for ffmpeg. Specifically regarding how enums are parsed. I downloaded the latest ffmpeg headers and also javacpp presets source code from github. The generated code cannot compile looks like mostly because the enums are not parsed correctly. For example the following line in avutil.java:
public native @ByRef AVColorSpace colorspace();
public native AVFrame colorspace(AVColorSpace colorspace);
but there's no type for AVColorSpace, instead, here's the how AVColorSpace is parsed from the header file:
/** YUV colorspace type. */
/** enum AVColorSpace */
public static final int
AVCOL_SPC_RGB = 0,
/** also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B */
AVCOL_SPC_BT709 = 1,
AVCOL_SPC_UNSPECIFIED = 2,
AVCOL_SPC_FCC = 4,
/** also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 */
AVCOL_SPC_BT470BG = 5,
/** also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above */
AVCOL_SPC_SMPTE170M = 6,
AVCOL_SPC_SMPTE240M = 7,
/** Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 */
AVCOL_SPC_YCOCG = 8,
/** ITU-R BT2020 non-constant luminance system */
AVCOL_SPC_BT2020_NCL = 9,
/** ITU-R BT2020 constant luminance system */
AVCOL_SPC_BT2020_CL = 10,
/** Not part of ABI */
AVCOL_SPC_NB = 11;
public static final int AVCOL_SPC_YCGCO = AVCOL_SPC_YCOCG;
I also attached the full generated file at this post:
https://code.google.com/p/javacpp/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=45
Thanks much for the help!
Percy
Hello guys and girlz,
I've just managed to compile Javacpp-presets from source on Windows 7. This was a major hackage so I've decided to write this short guide in order to save you a couple of days messing around with Windows and prevent some big frustrations. ๐ฅ
1. First of all, you'll need to install the following dependencies:
MSYS2: http://msys2.github.io
WARNING: please don't use MSYS from mingw.org because it's hopelessly obsolete and doesn't support 64bit targets!
Download the appropriate package for your system architecture, run it and choose the following installation path:
C:\msys64
After installation please follow the instructions given on the site in order to initialize the package manager pacman
and update system packages.
Then you'll need to install tar because it's requiered but isn't installed by default. Open the MSYS2 console from "Start" menu and type the folowing command:
pacman -S tar
Windows Platform SDK: http://www.microsoft.com/en-us/download/details.aspx?id=8279
This one is for Windows 7. You may actually need another SDK if you're running another Windows version.
MingW-w64 compiler toolset: http://mingw-w64.yaxm.org/doku.php/download
Download the installer from the above-mentioned site, run it, choose the installation path to be
C:\mingw64
and architecture = x86_64, threading model = win32, exception handling = SEH and build revision = 2.
7zip decompression package from here: http://www.7-zip.org/download.html
Please ensure that 7zip executable has been properly installed to
C:\Program Files\7-Zip\7z.exe
Java 7 JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Please ensure that the downloaded JDK does correspond to your system architecture!
Install Maven from https://maven.apache.org/download.cgi and set it up as described here: https://maven.apache.org/guides/getting-started/windows-prerequisites.html
Make sure that the mvn --version
command issued from the command line prints meaningful Maven version.
Now you'll need to add the following code to your Windows PATH:
C:\msys64\usr\bin;C:\mingw64\mingw64\bin
Now fire up the Windows SDK Command Prompt (sic!) and issue the following commands:
bash --version
g++ --version
If it works you're ready to proceed with the compilation.
You'll need to compile and install the parent project - Javacpp - first.
Then proceed with compilation of Javacpp-presets:
javacpp-presets
cd javacpp-presets
bash cppbuild.sh -platform windows-x86_64 install leptonica tesseract or whatever else
If you'll forget to launch Windows SDK Command Prompt you'll get TARGET_CPU: unbound variable
error!
If everything went well during the previous step, build the Java part as follows:
mvn install --project .,leptonica,tesseract
Don't forget the dot in the beginning of the projects list!
Have fun and keep on smiling! ๐
Max
Due to a dll dependency, swresample must be loaded prior to any reference to avcodec, otherwise an UnsatisfiedLinkError is thrown.
To resolve this, the avcodec.java preset should inherit swresample as well as avutil.
This affects ffmpeg 2.3 but not 2.2.1.
label:encancement
to build javacpp-presets with rtmpts / rtmps / crypto protocol support with libspeex enabled please replace the following files
cppbuild.sh :
#!/bin/bash
# Scripts to build and install native C++ libraries
KERNEL=(`uname -s | tr [A-Z] [a-z]`)
ARCH=(`uname -m | tr [A-Z] [a-z]`)
case $KERNEL in
darwin)
OS=macosx
;;
mingw*)
OS=windows
KERNEL=windows
if [[ $TARGET_CPU == "x64" ]]; then
ARCH=x86_64
fi
;;
*)
OS=$KERNEL
;;
esac
case $ARCH in
arm*)
ARCH=arm
;;
i386|i486|i586|i686)
ARCH=x86
;;
amd64|x86-64)
ARCH=x86_64
;;
esac
PLATFORM=$OS-$ARCH
echo "Detected platform \"$PLATFORM\""
while [[ $# > 0 ]]; do
case "$1" in
-platform)
shift
PLATFORM="$1"
;;
install)
OPERATION=install
;;
clean)
OPERATION=clean
;;
*)
PROJECTS+=("$1")
;;
esac
shift
done
echo "Targeting platform \"$PLATFORM\""
if [[ -z "$OPERATION" ]]; then
echo "Usage: ANDROID_NDK=/path/to/android-ndk/ bash cppbuild.sh [-platform <name>] [<install | clean>] [projects]"
echo "where platform includes: android-arm, android-x86, linux-x86, linux-x86_64, macosx-x86_64, windows-x86, windows-x86_64, etc."
exit 1
fi
if [[ -z "$ANDROID_NDK" ]]; then
ANDROID_NDK=~/projects/android/android-ndk/
fi
if [[ -z "$NDK_TOOLCHAIN" ]]; then
NDK_TOOLCHAIN=arm-linux-androideabi-4.6
fi
export NDK_TOOLCHAIN
export ANDROID_NDK
export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.6/"
case $PLATFORM in
android-x86)
export ANDROID_BIN="$ANDROID_NDK/toolchains/x86-4.6/prebuilt/$KERNEL-$ARCH/bin/i686-linux-android"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-9/arch-x86/"
;;
*)
export ANDROID_BIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$KERNEL-$ARCH/bin/arm-linux-androideabi"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-9/arch-arm/"
;;
esac
function download {
COMMAND="curl -C - -L $1 -o $2"
echo "$COMMAND"
$COMMAND
}
if [[ ${#PROJECTS[@]} -eq 0 ]]; then
PROJECTS=(opencv ffmpeg flycapture libdc1394 libfreenect videoinput artoolkitplus)
fi
for PROJECT in ${PROJECTS[@]}; do
case $OPERATION in
install)
echo "Installing \"$PROJECT\""
mkdir $PROJECT/cppbuild
cd $PROJECT/cppbuild
source ../cppbuild.sh
cd ../..
;;
clean)
echo "Cleaning \"$PROJECT\""
rm -Rf $PROJECT/cppbuild
;;
esac
done
ffmpeg/cppbuild.sh:
if [[ -z "$PLATFORM" ]]; then
echo "This file is meant to be included by the parent cppbuild.sh script"
exit 1
fi
if [[ $PLATFORM == windows* ]]; then
FFMPEG_VERSION=2.2.1
download http://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-$FFMPEG_VERSION-win32-dev.7z ffmpeg-$FFMPEG_VERSION-win32-dev.7z
download http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-$FFMPEG_VERSION-win64-dev.7z ffmpeg-$FFMPEG_VERSION-win64-dev.7z
download http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-$FFMPEG_VERSION-win32-shared.7z ffmpeg-$FFMPEG_VERSION-win32-shared.7z
download http://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-$FFMPEG_VERSION-win64-shared.7z ffmpeg-$FFMPEG_VERSION-win64-shared.7z
download http://msinttypes.googlecode.com/files/msinttypes-r26.zip msinttypes-r26.zip
INSTALL_DIR=/C/MinGW/local
mkdir -p $INSTALL_DIR/include
unzip -o msinttypes-r26.zip -d $INSTALL_DIR/include
else
FFMPEG_VERSION=2.2.1
download http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMPEG_VERSION.tar.bz2
download ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2 last_stable_x264.tar.bz2
download https://github.com/guardianproject/openssl-android/archive/master.zip openssl-android-latest.zip
download https://github.com/yayanyang/speex-android/archive/master.zip speex-android-latest.zip
tar -xjvf ffmpeg-$FFMPEG_VERSION.tar.bz2
mv ffmpeg-$FFMPEG_VERSION ffmpeg-$FFMPEG_VERSION-$PLATFORM
cd ffmpeg-$FFMPEG_VERSION-$PLATFORM
tar -xjvf ../last_stable_x264.tar.bz2
X264=`echo x264-snapshot-*`
fi
case $PLATFORM in
android-arm)
cd $X264
./configure --enable-static --enable-pic --disable-cli --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --host=arm-linux --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib -Wl,--fix-cortex-a8 -lgcc -ldl -lz -lm -lc"
make -j4
cd ..
unzip -o ../speex-android-latest.zip
SPEEX=`echo speex-android-master`
cd $SPEEX/speexjni
$ANDROID_NDK/ndk-build -j4
cd ../../
unzip -o ../openssl-android-latest.zip
OPENSSL=`echo openssl-android-master`
cd $OPENSSL
$ANDROID_NDK/ndk-build -j4
cd ../
patch -Np1 < ../../ffmpeg-$FFMPEG_VERSION-android.patch
./configure --prefix="$ANDROID_NDK/../local/" --enable-shared --enable-gpl --enable-nonfree --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$SPEEX/speexjni/jni/include -I$OPENSSL/include -I$X264" --extra-ldflags="-L$SPEEX/speexjni/libs/armeabi -L$OPENSSL/libs/armeabi -L$X264" --enable-cross-compile --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --target-os=linux --arch=arm --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib -Wl,--fix-cortex-a8" --extra-libs="-lgcc -ldl -lz -lm -lc -lssl -lcrypto -lspeex" --disable-symver --disable-programs --enable-protocol=tls --enable-openssl --enable-libspeex --libdir="$ANDROID_NDK/../local/lib/armeabi/" --shlibdir="$ANDROID_NDK/../local/lib/armeabi/"
make -j4
make install
;;
android-x86)
cd $X264
./configure --enable-static --enable-pic --disable-cli --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --host=i686-linux --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -mtune=atom -mssse3 -mfpmath=sse -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib -lgcc -ldl -lz -lm -lc"
make -j4
cd ..
patch -Np1 < ../../ffmpeg-$FFMPEG_VERSION-android.patch
./configure --prefix="$ANDROID_NDK/../local/" --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --enable-cross-compile --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --target-os=linux --arch=atom --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -mssse3 -mfpmath=sse -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib" --extra-libs="-lgcc -ldl -lz -lm -lc" --disable-symver --disable-programs --libdir="$ANDROID_NDK/../local/lib/x86/" --shlibdir="$ANDROID_NDK/../local/lib/x86/"
make -j4
make install
;;
linux-x86)
cd $X264
./configure --enable-static --enable-pic --host=i686-linux
make -j4
cd ..
./configure --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --cc="gcc -m32" --extra-ldflags="-ldl" --libdir=/usr/local/lib32/ --shlibdir=/usr/local/lib32/
make -j4
sudo make install
;;
linux-x86_64)
cd $X264
./configure --enable-static --enable-pic
make -j4
cd ..
./configure --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --extra-ldflags="-ldl" --libdir=/usr/local/lib64/ --shlibdir=/usr/local/lib64/
make -j4
sudo make install
;;
macosx-x86_64)
cd $X264
./configure --enable-static --enable-pic
make -j4
cd ..
./configure --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --extra-ldflags="-Wl,-headerpad_max_install_names -ldl"
make -j4
sudo make install
BADPATH=/usr/local/lib
LIBS="libavcodec.55.dylib libavdevice.55.dylib libavfilter.4.dylib libavformat.55.dylib libavutil.52.dylib libpostproc.52.dylib libswresample.0.dylib libswscale.2.dylib"
for f in $LIBS; do sudo install_name_tool $BADPATH/$f -id @rpath/$f \
-add_rpath /usr/local/lib/ -add_rpath /opt/local/lib/ -add_rpath @loader_path/. \
-change $BADPATH/libavcodec.55.dylib @rpath/libavcodec.55.dylib \
-change $BADPATH/libavdevice.55.dylib @rpath/libavdevice.55.dylib \
-change $BADPATH/libavfilter.4.dylib @rpath/libavfilter.4.dylib \
-change $BADPATH/libavformat.55.dylib @rpath/libavformat.55.dylib \
-change $BADPATH/libavutil.52.dylib @rpath/libavutil.52.dylib \
-change $BADPATH/libpostproc.52.dylib @rpath/libpostproc.52.dylib \
-change $BADPATH/libswresample.0.dylib @rpath/libswresample.0.dylib \
-change $BADPATH/libswscale.2.dylib @rpath/libswscale.2.dylib; done
;;
windows-x86)
7za x -y ffmpeg-$FFMPEG_VERSION-win32-dev.7z
7za x -y ffmpeg-$FFMPEG_VERSION-win32-shared.7z
patch -Np1 -d ffmpeg-$FFMPEG_VERSION-win32-dev/ < ../ffmpeg-$FFMPEG_VERSION-win32-dev.patch
# http://ffmpeg.org/platform.html#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b
LIBS=(avcodec-55 avdevice-55 avfilter-4 avformat-55 avutil-52 postproc-52 swresample-0 swscale-2)
for LIB in ${LIBS[@]}; do
lib /def:ffmpeg-$FFMPEG_VERSION-win32-dev/lib/$LIB.def /out:ffmpeg-$FFMPEG_VERSION-win32-dev/lib/$LIB.lib /machine:x86
done
rm -Rf ffmpeg-$FFMPEG_VERSION-win32-dev/lib32
rm -Rf ffmpeg-$FFMPEG_VERSION-win32-shared/bin32
mv ffmpeg-$FFMPEG_VERSION-win32-dev/lib ffmpeg-$FFMPEG_VERSION-win32-dev/lib32
mv ffmpeg-$FFMPEG_VERSION-win32-shared/bin ffmpeg-$FFMPEG_VERSION-win32-shared/bin32
cp -a ffmpeg-$FFMPEG_VERSION-win32-dev/* $INSTALL_DIR
cp -a ffmpeg-$FFMPEG_VERSION-win32-shared/* $INSTALL_DIR
;;
windows-x86_64)
7za x -y ffmpeg-$FFMPEG_VERSION-win64-dev.7z
7za x -y ffmpeg-$FFMPEG_VERSION-win64-shared.7z
patch -Np1 -d ffmpeg-$FFMPEG_VERSION-win64-dev/ < ../ffmpeg-$FFMPEG_VERSION-win64-dev.patch
# http://ffmpeg.org/platform.html#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b
LIBS=(avcodec-55 avdevice-55 avfilter-4 avformat-55 avutil-52 postproc-52 swresample-0 swscale-2)
for LIB in ${LIBS[@]}; do
lib /def:ffmpeg-$FFMPEG_VERSION-win64-dev/lib/$LIB.def /out:ffmpeg-$FFMPEG_VERSION-win64-dev/lib/$LIB.lib /machine:x64
done
rm -Rf ffmpeg-$FFMPEG_VERSION-win64-dev/lib64
rm -Rf ffmpeg-$FFMPEG_VERSION-win64-shared/bin64
mv ffmpeg-$FFMPEG_VERSION-win64-dev/lib ffmpeg-$FFMPEG_VERSION-win64-dev/lib64
mv ffmpeg-$FFMPEG_VERSION-win64-shared/bin ffmpeg-$FFMPEG_VERSION-win64-shared/bin64
cp -a ffmpeg-$FFMPEG_VERSION-win64-dev/* $INSTALL_DIR
cp -a ffmpeg-$FFMPEG_VERSION-win64-shared/* $INSTALL_DIR
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
;;
esac
if [[ $PLATFORM != windows* ]]; then
cd ..
fi
and run
NDK_TOOLCHAIN=arm-linux-androideabi-4.6 ANDROID_NDK=/home/android-ndk-r9b/ bash cppbuild.sh -platform android-arm install ffmpeg
Somebody knows how I can improve to become points found more accuracy ?
For Example in example here,
the pre-processing of image is just convert image to grayscale
There is something more that you do for sharing with us ?
I did cvEqualizeHist(gray, gray); and reduce specks from image:
cvMorphologyEx(gray, gray, null, null, CV_CAP_OPENNI, 1);
I tried to applied Gabor Filter but the accuracy of points wasn't good.
In many places in my project I used similar lines:
CvScalar scalar=new CvScalar(0,1,2,3);
CvPoint point = new CvPoint(0,0)
then I changed library imports from com.googlecode. .... to org.bytedeco.javacpp. ...
(and library version from 0.7 to 0.8)
Now, although I use in my project this lines:
import org.bytedeco.javacpp.opencv_core.CvScalar;
import org.bytedeco.javacpp.opencv_core.CvPoint;
I don't see proper constructors (and generally class:
public static class CvScalar extends Pointer{..}).
Am I missed something or they shouldn't be avaible in ver. 0.8?
The proposal is to make the advanced library-in-a-jar handling optional (via sys prop) and off by default.
Example to run tests using the java.library.path property:
https://github.com/jjYBdx4IL/javacpp-presets/blob/master/tests/pom.xml
Java daemons usually use that solution too: wrapper scripts determine architecture and point -Djava.library.path to the correct location.
I have implemented simple tests that are checking whether the Libs generated on Debian Squeeze can be loaded on newer Ubuntu/Debian OSes. I'm also parsing and printing out the dynamic sections of the libraries there.
The log files (and results) have the format testlog.$project.$buildos.$testos.log and can be found there:
https://github.com/jjYBdx4IL/javacpp-presets
4 projects cannot be built because sources are not available or incomplete (flandmark depends on opencv, for example). These projects are listed in the allow_failure section of https://github.com/jjYBdx4IL/javacpp-presets/blob/develop/.travis.yml
Just FYI.
Some of the algorithms previously available in javacpp-presets moved in OpenCV 3 to xfeatures2d module. Those include SIFT, SURF, and related.There are also some other interesting algorithms in xfeatures2d module, like DAISY.
On 05/03/2014 01:07 AM,
Well, I guess nevermind. Looks like it works if I give the opencv_core.Mat constructor the width, height, and type:
opencv_core.Mat mm = new opencv_core.Mat(matFace.rows(), matFace.cols(), matFace.type());
It would be nice if I didn't need to provide those--pretty sure the OpenCV java bindings don't require that when using copyTo(). But not a big deal.
There's Mat.createFrom() that should do what you need:
https://github.com/bytedeco/javacpp-presets/blob/master/opencv/src/main/java/org/bytedeco/javacpp/helper/opencv_core.java#L2300
But whoops, I forgot to put them static. I'll be fixing that.
If possible, please open an issue here (just copy/paste), thanks!
Hello,
I wonder why there is no linux version for flycap. We just got new PGRย cameras, and I am new to their API.
I would like to implement the linux wrapper at least for the flea USB 3, if you have any advices I would be glad.
Cheers,
Jeremy.
Hello,
first of all - thank you for bringing us this amazing project! We're using JavaCPP in our music recognition engine (www.audiveris.org) since 2012 for communicating with Tesseract OCR. For this purpose I've programmed an elegant interface manually, based on JavaCPP. It worked for us for several years until now.
For a couple of days I've tried to compile my old code with the current JavaCPP v0.10 and noticed that it doesn't compile anymore. While examining the new library code I've noticed several big changes. The biggest one was the introduction of an automatic system that does scan C++ headers and produce the appropriate Java interface.
I spent several days playing with the new JavaCPP library and its Tesseract presets in order to integrate it with my project. I must admit that I finally gave up on it after a while, not being able to get it work at all.
I would very appreciate it if someone could shed some light on the following issues I encountered with the Tesseract preset:
The documentation on manual installation says "Just put all the desired JAR files somewhere in your CLASSPATH". OK, it doesn't work out-of-box. My Ubuntu 14 and Netbeans 8 simply refuse to load the native libraries from supplied JARs. The native libraries have to be EXTRACTED first, otherwise the famous Unsatisfied Link exception is thrown. Is it the normal behaviour or am I missing something? Is there any dedicated LOAD method I forget to call?
I wasn't able to get Leptonica's pixReadMemTiff function work. It always returns "false" that indicates some internal error. Reading TIFF files does work though. My project relies heavily on the former method because we're constructing images on the fly. I have to debug the native library in order to be able to say more. Any suggestions on why it doesn't work?
Leptonica's native library is huge (2,3 MB) but Tesseract utilizes just a few methods, mostly PIX-related. The rest (over 90%) is never used but will be wastefully kept in memory. Is there any possibility to strip out unused code if the intended usage of Leptonica will be Tesseract alone?
Tesseract API supplies an iterator - ResultIterator - to be used for extraction of recognition results. This ResultIterator is inherited from LTRResultIterator which, in turn, is inherited from PageIterator. So it's basically possible to use this ResultIterator for accessing results at different levels like pages, words or single symbols.
In C++, it's possible to access PageIterator's method Empty() using ResultIterator instance:
ResultIterator rit = api.GetIterator();
if (rit.Empty())
continue;
It doesn't work in JavaCPP v0.10 because of the famous issue with the multiple inheritance in Java. From what I see in the generated code, ResultIterator extends LTRResultIterator which extends Pointer. Where is PageIterator?
It looks like I need to explicitely request PageIterator instance like this:
ResultIterator rit = api.GetIterator();
PageIterator pit = TessResultIteratorGetPageIterator(rit);
With the earlier versions of JavaCPP the C++ way has just worked, without any casts or extra accessors. Am I missing some important technical point here?
I kinda like the idea of automatic Java interface generation. It looks promising at saving us a lot of time. I would like to use this new feature in my project. That's why I'd highly appreciate any help on getting it up and running.
Thank you in advance!
Best regards
Max P.
I'm new to OpenCV and your JavaCV library as a whole so this might be naive but I have searched high and low and could not find MatOfInt class in opencv_core , I need it for some image effects and code where it is being used is as follows -
private final CvMat mKernel = new MatOfInt(
0, 0, 1, 0, 0,
0, 1, 2, 1, 0,
1, 2, -16, 2, 1,
0, 1, 2, 1, 0,
0, 0, 1, 0, 0
);
I'm thinking of using opencv4android sdk just for this class so if you can help in anyway then that would be great as I totally love the opencv+ffmpeg integration, i get with your javacv library and don't want to fiddle with other lib just for one class !
./cppbuild.sh -platform android-arm install ffmpeg
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/Users/Phoenix/workspace/Frameworks/javacpp-presets/ffmpeg/cppbuild/android-arm/lame-3.99.5':
configure: error: C preprocessor "/lib/cpp" fails sanity check
Hello,
I am trying to write some video effects in android application. I got some sample code from OpenCv and converted it into javacv. Please let me know if I am going in right direction or not.
OpenCv :
public class RecolorRGVFilter implements Filter {
private final ArrayList<Mat> mChannels = new ArrayList<Mat>(4);
@Override
public void apply(final Mat src, final Mat dst) {
Core.split(src, mChannels);
final Mat r = mChannels.get(0);
final Mat g = mChannels.get(1);
final Mat b = mChannels.get(2);
// dst.b = min(dst.r, dst.g, dst.b)
Core.min(b, r, b);
Core.min(b, g, b);
Core.merge(mChannels, dst);
}
}
And in javaCv:
public class RecolorRGVFilter implements Filter {
private final ArrayList<CvArr> mChannels = new ArrayList<CvArr>(4);
@Override
public void apply(final CvArr src, final CvArr dst) {
// Core.split(src, mChannels);
cvSplit(src, mChannels.get(0), mChannels.get(1), mChannels.get(2),
mChannels.get(3));
final CvArr r = mChannels.get(0);
final CvArr g = mChannels.get(1);
final CvArr b = mChannels.get(2);
Mat r_mat = cvarrToMat(r);
Mat g_mat = cvarrToMat(g);
Mat b_mat = cvarrToMat(b);
// dst.b = min(dst.r, dst.g, dst.b)
min(b_mat, r_mat, b_mat);
min(b_mat, g_mat, b_mat);
// merge(mChannels, dst);
cvMerge(mChannels.get(0), mChannels.get(1), mChannels.get(2),
mChannels.get(3), dst);
}
}
My thinking behind this code is, I will covert every IplImage (video frame) of video to CvArr first, and then apply filter (shown above) and converting that new CvArr back to IplImage and save in new video. (but I don't know how to convert CvArr to IplImage and IplImage to CvArr).
Also, If not possible this way, Can we convert org.opencv.core.Mat to javacv CvMat and vice versa ?
I have spent a lot of time and this is very important for me. Please guide me
Calling Mat.createFrom(BufferedImage..) for a 640x480 BufferedImage will create a 480x640 Mat.
The culprit might be this line in AbstractMat.copyFrom(..) :
create(image.getWidth(), image.getHeight(), CV_MAKETYPE(depth, numChannels));
super.copyFrom(image, gamma, flipChannels, roi);
hi , i when i tried to compile opencv from javacpp , i got error as shown below:
C:\Users\Kadir\Desktop\javacpp-presets\opencv\target\classes\org\bytedeco\javacp
p\jniopencv_objdetect.cpp(8865) : warning C4244: 'initializing' : conversion fro
m 'jlong' to 'jint', possible loss of data
C:\Users\Kadir\Desktop\javacpp-presets\opencv\target\classes\org\bytedeco\javacp
p\jniopencv_objdetect.cpp(9036) : warning C4244: 'initializing' : conversion fro
m 'jlong' to 'jint', possible loss of data
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:jniopencv_objdetect.dll
/ltcg
/dll
/implib:jniopencv_objdetect.lib
/OUT:C:\Users\Kadir\Desktop\javacpp-presets\opencv\target\classes\org\bytedeco\j
avacpp\windows-x86\jniopencv_objdetect.dll
/LIBPATH:C:\Users\Kadir\Desktop\javacpp-presets\opencv/cppbuild/windows-x86/lib/
opencv_world300.lib
jniopencv_objdetect.obj
Creating library jniopencv_objdetect.lib and object jniopencv_objdetect.exp
jniopencv_objdetect.obj : error LNK2001: unresolved external symbol "public: __t
hiscall cv::DetectionBasedTracker::Parameters::Parameters(void)" (??0Parameters@
DetectionBasedTracker@cv@@QAE@XZ)
C:\Users\Kadir\Desktop\javacpp-presets\opencv\target\classes\org\bytedeco\javacp
p\windows-x86\jniopencv_objdetect.dll : fatal error LNK1120: 1 unresolved extern
als
C:\Users\Kadir\Desktop\javacpp-presets\opencv>
My tests submodule in javacpp-presets needs to reference the correct preset generated during the current build. Keeping the versions specs in sync manually
within the same project does not make much sense.
Proposal: define the opencv, ffmpeg etc. artifact versions in a parent pom.xml. Or even use 0.9 instead of 2.4.9-0.9 -- that way one could simply write ${project.version}.
https://github.com/jjYBdx4IL/javacpp-presets/blob/master/tests/pom.xml :
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-${project.parent.version}</version>
<classifier>${platform}</classifier>
<type>jar</type>
Much nicer would be:
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>${project.version}</version>
<classifier>${platform}</classifier>
<type>jar</type>
:-))
Add dlib (https://github.com/davisking/dlib) to the javacpp-presets family.
I'm trying to use http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html#cascadeclassifier-detectmultiscale method
void CascadeClassifier::detectMultiScale(const Mat& image, vector<Rect>& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size())
which is bound to this in javacpp-presets:
public native void detectMultiScale( @Const @ByRef Mat image,
@StdVector Rect objects,
double scaleFactor/*=1.1*/,
int minNeighbors/*=3*/, int flags/*=0*/,
@ByVal Size minSize/*=Size()*/,
@ByVal Size maxSize/*=Size()*/ );
(I'm following the old http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html?highlight=detectmultiscale#running-sbt-samples and the new http://docs.opencv.org/trunk/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html#haar-cascade-detection-in-opencv)
So here is my code:
opencv_objdetect.CascadeClassifier faceCascade = new opencv_objdetect.CascadeClassifier(new BytePointer(IOUtils.toByteArray(FaceDetection.class.getResourceAsStream("haarcascade_frontalface_default.xml"))));
opencv_core.Mat img = opencv_highgui.imread("/tmp/photos/photo.JPG");
opencv_core.Mat grayImg = new opencv_core.Mat();
opencv_imgproc.cvtColor(img, grayImg, opencv_imgproc.COLOR_BGR2GRAY);
opencv_core.Rect faces = new opencv_core.Rect();
faceCascade.detectMultiScale(grayImg, faces, 1.3, 5, 0, new opencv_core.Size(), new opencv_core.Size());
And here I don't know what to do with my faces
variable... because it is not a java Iterable
nor it seems to be an array of any sort...
Could somebody tell me how to use the @StdVector
mapping?
Part of the mobile phone will appear android SDK ๏ผ15
AndroidRuntime java.lang.ExceptionInInitializerError
#8765 05-09 21:52:17.710 12329 E AndroidRuntime at com.qd.recorder.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:179)
#8766 05-09 21:52:17.710 12329 E AndroidRuntime at com.qd.recorder.RecordActivity2.initRecorder(RecordActivity2.java:314)
#8767 05-09 21:52:17.710 12329 E AndroidRuntime at com.qd.recorder.RecordActivity2.startRecording(RecordActivity2.java:346)
#8768 05-09 21:52:17.710 12329 E AndroidRuntime at com.qd.recorder.RecordActivity2.initLayout(RecordActivity2.java:288)
#8769 05-09 21:52:17.710 12329 E AndroidRuntime at com.qd.recorder.RecordActivity2.onCreate(RecordActivity2.java:182)
#8770 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.Activity.performCreate(Activity.java:4470)
#8771 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
#8772 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
#8773 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1990)
#8774 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.ActivityThread.access$600(ActivityThread.java:124)
#8775 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1148)
#8776 05-09 21:52:17.710 12329 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99)
#8777 05-09 21:52:17.710 12329 E AndroidRuntime at android.os.Looper.loop(Looper.java:137)
#8778 05-09 21:52:17.710 12329 E AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:4451)
#8779 05-09 21:52:17.710 12329 E AndroidRuntime at java.lang.reflect.Method.invokeNative(Native Method)
#8780 05-09 21:52:17.710 12329 E AndroidRuntime at java.lang.reflect.Method.invoke(Method.java:511)
#8781 05-09 21:52:17.710 12329 E AndroidRuntime at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
#8782 05-09 21:52:17.710 12329 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
#8783 05-09 21:52:17.710 12329 E AndroidRuntime at dalvik.system.NativeStart.main(Native Method)
#8784 05-09 21:52:17.710 12329 E AndroidRuntime Caused by: java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
#8785 05-09 21:52:17.710 12329 E AndroidRuntime at org.bytedeco.javacpp.Loader.load(Loader.java:388)
#8786 05-09 21:52:17.710 12329 E AndroidRuntime at org.bytedeco.javacpp.Loader.load(Loader.java:354)
#8787 05-09 21:52:17.710 12329 E AndroidRuntime at org.bytedeco.javacpp.avcodec$AVPacket.(avcodec.java:1405)
#8788 05-09 21:52:17.710 12329 E AndroidRuntime ... 19 more
#8789 05-09 21:52:17.710 12329 E AndroidRuntime Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
#8790 05-09 21:52:17.710 12329 E AndroidRuntime at java.lang.Class.classForName(Native Method)
#8791 05-09 21:52:17.710 12329 E AndroidRuntime at java.lang.Class.forName(Class.java:217)
#8792 05-09 21:52:17.710 12329 E AndroidRuntime at org.bytedeco.javacpp.Loader.load(Loader.java:386)
#8793 05-09 21:52:17.710 12329 E AndroidRuntime ... 21 more
#8794 05-09 21:52:17.710 12329 E AndroidRuntime Caused by: java.lang.NoClassDefFoundError: org/bytedeco/javacpp/avutil
#8795 05-09 21:52:17.710 12329 E AndroidRuntime ... 24 more
#8796 05-09 21:52:17.710 12329 E AndroidRuntime Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
#8797 05-09 21:52:17.710 12329 E AndroidRuntime at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
#8798 05-09 21:52:17.710 12329 E AndroidRuntime at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
#8799 05-09 21:52:17.710 12329 E AndroidRuntime at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
#8800 05-09 21:52:17.710 12329 E AndroidRuntime ... 24 more
Steps taken:
Error:
[INFO] Generating /Users/roel/workspace/javacpp-presets/cuda/target/classes/org/bytedeco/javacpp/jnicudnn.cpp
[INFO] Compiling /Users/roel/workspace/javacpp-presets/cuda/target/classes/org/bytedeco/javacpp/macosx-x86_64/libjnicudnn.dylib
[INFO] g++ -I/usr/local/cuda/include/ -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/include/darwin /Users/roel/workspace/javacpp-presets/cuda/target/classes/org/bytedeco/javacpp/jnicudnn.cpp -Wl,-rpath,@loader_path/. -march=x86-64 -m64 -Wall -O3 -fPIC -dynamiclib -o /Users/roel/workspace/javacpp-presets/cuda/target/classes/org/bytedeco/javacpp/macosx-x86_64/libjnicudnn.dylib -L/usr/local/cuda/lib/ -Wl,-rpath,/usr/local/cuda/lib/ -lcudnn -lcuda -lcudart -framework JavaVM
Undefined symbols for architecture x86_64:
"_cudnnGetPooling2dForwardOutputDim", referenced from:
_Java_org_bytedeco_javacpp_cudnn_cudnnGetPooling2dForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2_3I_3I_3I_3I in jnicudnn-910341.o
_Java_org_bytedeco_javacpp_cudnn_cudnnGetPooling2dForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2Lorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_IntPointer_2 in jnicudnn-910341.o
_Java_org_bytedeco_javacpp_cudnn_cudnnGetPooling2dForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2 in jnicudnn-910341.o
(maybe you meant: _Java_org_bytedeco_javacpp_cudnn_cudnnGetPooling2dForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2, _Java_org_bytedeco_javacpp_cudnn_cudnnGetPooling2dForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2Lorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_IntPointer_2Lorg_bytedeco_javacpp_IntPointer_2 , _Java_org_bytedeco_javacpp_cudnn_cudnnGetPooling2dForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2_3I_3I_3I_3I )
"_cudnnGetPoolingNdForwardOutputDim", referenced from:
_Java_org_bytedeco_javacpp_cudnn_cudnnGetPoolingNdForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2I_3I in jnicudnn-910341.o
_Java_org_bytedeco_javacpp_cudnn_cudnnGetPoolingNdForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2ILjava_nio_IntBuffer_2 in jnicudnn-910341.o
_Java_org_bytedeco_javacpp_cudnn_cudnnGetPoolingNdForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2ILorg_bytedeco_javacpp_IntPointer_2 in jnicudnn-910341.o
(maybe you meant: _Java_org_bytedeco_javacpp_cudnn_cudnnGetPoolingNdForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2ILjava_nio_IntBuffer_2, _Java_org_bytedeco_javacpp_cudnn_cudnnGetPoolingNdForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2I_3I , _Java_org_bytedeco_javacpp_cudnn_cudnnGetPoolingNdForwardOutputDim__Lorg_bytedeco_javacpp_cudnn_00024cudnnPoolingStruct_2Lorg_bytedeco_javacpp_cudnn_00024cudnnTensorStruct_2ILorg_bytedeco_javacpp_IntPointer_2 )
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hi all,
I've been playing around with the opencv javacpp preset for the last couple of hours and I think I've found a bug in the imencode() JNI wrapper.
It seems like the target buffer of the method never gets filled with the encoded image (it always stays empty). I've been testing on Ubuntu 14.04 64bit with version 2.4.9-0.9.
Eg. this yields an empty byte array and thus an empty file (filled with zeros)
Mat sourceImg = imread("/home/bram/lena.jpg");
Point cntr = new Point((int) Math.round(sourceImg.size().width() / 2.0), (int) Math.round(sourceImg.size().height() / 2.0));
Mat croppedImg = new Mat(sourceImg, new Rect(cntr.x()-50, cntr.y()-50, 100, 100));
int bufferSize = croppedImg.channels()*croppedImg.cols()*croppedImg.rows();
byte[] outputBuffer = new byte[bufferSize];
String ex = ".jpg";
boolean result = imencode(ex, croppedImg, outputBuffer);
FileOutputStream fileOuputStream = new FileOutputStream("/tmp/test"+ex);
fileOuputStream.write(outputBuffer);
fileOuputStream.close();
I found this as a reference post that could be related: https://groups.google.com/forum/#!msg/android-opencv/SCC1gU2ood8/PZWNqAVhsdYJ
Can somebody please confirm?
b.
I'm compiling with this command line:
./cppbuild.sh -platform linux-x86_64 install
It yields this:
install -m 644 libx264.a /home/mondain/workspace/github/javacpp-presets/ffmpeg/cppbuild/linux-x86_64/lib
ranlib /home/mondain/workspace/github/javacpp-presets/ffmpeg/cppbuild/linux-x86_64/lib/libx264.a
ERROR: libx264 not found
When I check the /home/mondain/workspace/github/javacpp-presets/ffmpeg/cppbuild/linux-x86_64/lib directory, the libx264.a file is there.
I'm experiencing an issue when I try to use leptonica + tessseract bindings, compiled from the latest trunk and installed into Maven local repository, from within Gradle. I've correctly added all required dependencies and pointed Gradle to MavenLocal repository.
Gradle does report the following error:
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.bytedeco.javacpp-presets:leptonica:1.71-0.11.
Required by:
:Project:unspecified
> Could not parse POM file:/****/*****/.m2/repository/org/bytedeco/javacpp-presets/leptonica/1.71-0.11/leptonica-1.71-0.11.pom
> Could not find org.bytedeco:javacpp-presets:0.11.
It looks like the parent POM is missing. I've looked into the local .m2 directory and the expected parent pom "javacpp-presets-0.11.pom" is, indeed, not there.
I'm using the following terminal commands in order to get everything built and installed:
bash cppbuild.sh -platform linux-x86 install leptonica tesseract
mvn install --projects leptonica,tesseract
Below the results:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] JavaCPP Presets for Leptonica ..................... SUCCESS [29:05.014s]
[INFO] JavaCPP Presets for Tesseract ..................... SUCCESS [1:32.344s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30:40.956s
[INFO] Finished at: Wed Mar 18 17:44:03 CET 2015
[INFO] Final Memory: 22M/230M
Any ideas what's going wrong?
Thank you in advance!
Best regards
Max
I get some of
[ERROR] Failed to execute JavaCPP Builder: Could not parse "opencv2/core/types_c.h": File does not exist
I checked and even made sure that the opencv/cppbuild/
dir contains the include and lib dirs.
What puzzles me a LOT is that checking the same code on linux seems working w/out any issue.
Trying to build on a Raspberry Pi 2 yields the following error:
[ERROR] Failed to execute goal org.bytedeco:javacpp:0.10:build (generate-sources) on project opencv: Failed to execute JavaCPP Builder: Could not parse "opencv2/core/types_c.h": File does not exist -> [Help 1]
Hi, I am wanting to train a cascade classifier using JavaCV. I am aware of the opencv_traincascade binary, however I would like to write this in Java code using the JavaCV library. Under the hood of traincascade, it uses the train()
method in CvCascadeClassifier
which is not available through JavaCV. Could a wrapper for the CvCascadeClassifer
class be added to the opencv module?
Thanks.
From what I could gather ffmpeg builds automatically include x11grab
and avfoundation
devices (Trying to invoke the libs to replicate the following examples) and I'm wondering what in particular in the presets' build script makes it so those are not included? I noticed you guys build it with --disable-libxcb
, is that what causes these components not to be included?
The ffmpeg 2.3 branch is not actively maintained anymore. Can the ffmpeg preset be updated to use 2.4?
I tried to build an eclipse project by mvn eclipse:eclipse -Dplatform.dependencies=true
and then run the sample code tesseract code on MacOS from Eclipse with the error "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jnitesseract in java.library.path"
I checked the dependencies and all platform jars are in the classpath. Then I tried to run the sample code using mvn package exec:java -Dexec.mainClass=BasicExample -Dexec.args="/open/tesseract-ocr/testing/phototest.tif" -Dplatform.dependencies=true
, got the above error with no luck.
Hi,
I've copied the class IntVectorVector from the "opencv_core.java".
@Name("std::vector<std::vector<int> >") public static class IntVectorVector extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public IntVectorVector(Pointer p) { super(p); }
public IntVectorVector(int[] ... array) { this(array.length); put(array); }
public IntVectorVector() { allocate(); }
public IntVectorVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(@Cast("size_t") long n);
public native @Name("operator=") @ByRef IntVectorVector put(@ByRef IntVectorVector x);
public native long size();
public native void resize(@Cast("size_t") long n);
public native @Index long size(@Cast("size_t") long i);
public native @Index void resize(@Cast("size_t") long i, @Cast("size_t") long n);
@Index public native @ByRef int get(@Cast("size_t") long i, @Cast("size_t") long j);
public native IntVectorVector put(@Cast("size_t") long i, @Cast("size_t") long j, int value);
public IntVectorVector put(int[] ... array) {
if (size() != array.length) { resize(array.length); }
for (int i = 0; i < array.length; i++) {
if (size(i) != array[i].length) { resize(i, array[i].length); }
for (int j = 0; j < array[i].length; j++) {
put(i, j, array[i][j]);
}
}
return this;
}
}
However, there is an error when trying to compile with this class:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\string.h(
245) : see declaration of 'strdup'
.\jnispider.cpp(1390) : error C2664: 'VectorAdapter<VectorAdapter<int,P>,VectorA
dapter<P,P>>::VectorAdapter(const VectorAdapter<VectorAdapter<P,P>,VectorAdapter
<P,P>> &)' : cannot convert argument 1 from 'std::vector<std::vector<int,std::al
locator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>>' to 'const s
td::vector<T,std::allocator<_Ty>> &'
with
[
P=int
]
and
[
_Ty=int
]
and
[
T=VectorAdapter<int,int>
, _Ty=VectorAdapter<int,int>
]
Reason: cannot convert from 'std::vector<std::vector<int,std::allocator<
_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>>' to 'const std::vect
or<T,std::allocator<_Ty>>'
with
[
_Ty=int
]
and
[
T=VectorAdapter<int,int>
, _Ty=VectorAdapter<int,int>
]
No user-defined-conversion operator available that can perform this conv
ersion, or the operator cannot be called
.\jnispider.cpp(1391) : error C2440: '=' : cannot convert from 'VectorAdapter<Ve
ctorAdapter<int,P>,VectorAdapter<P,P>>' to 'std::vector<std::vector<int,std::all
ocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>> *'
with
[
P=int
]
and
[
_Ty=int
]
No user-defined-conversion operator available that can perform this conv
ersion, or the operator cannot be called
It shows that in the jnispider.cpp, there is an error of type casting in this command:
try {
VectorAdapter<VectorAdapter<int>> radapter(ptr->getVectorVectorInt());
rptr = radapter;
I dont understand why in this case the copied class is not working.
Could you show me please.
Thanks for your help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.