Using JavaCV in the Raspberry Pi (linux-arm)

Hi everyone, last week we (my friend linux hacker beer fps master Esteban and I) were  playing in my free time with the Raspberry Pi Camera Module, trying to use it via JavaCV which is the Java wrapper for OpenCV. Right now JavaCV distribution don’t provide the Linux-Arm native libraries, so we decided to compile them. After going to all the process of trying to get things working in the Raspberry Pi, we arrive to a dead end. The Raspberry Pi Camera Module doesn’t provide a V4L driver yet, which makes it impossible to use with JavaCV, but having the latest JavaCV compiled for the Raspberry Pi will allow you to use any other USB web cam, and in the future, when the Raspberry Pi Foundation provides the appropriate V4L driver JavaCV will be ready to use it. On this post I will also mention some other alternatives that you have, some workarounds if you really want to use the Raspberry Camera Module in one way or another.

Introduction

Before staring with the compilation procedure, I would like to recommend you things that you shouldn’t do in your Raspberry Pi. If you are planning to use the Face Recognition features of OpenCV/JavaCV don’t install Opencv 2.3 that comes in the Raspbian repositories (meaning apt-get install opencv*). Don’t do this, because this will add all the system links to libraries that JavaCV will need. We spend at least 3hs removing OpenCv-2.3, so we don’t recommend that at all. We will be compiling OpenCV 2.4.5, which is the one supported by JavaCV 0.5 here and we need to keep our native libraries as clean as possible to avoid system links pointing to the wrong versions.

If you are not familiar with OpenCV and JavaCV, as I was a week ago, you maybe find the following figure helpful to understand the context:

JavaCV -> WebCam
JavaCV -> WebCam

Where JavaCV is a just a Java Archive (jar) that we will need to add to our application as a dependency. JavaCPP is a transitive dependency of JavaCV and it contains all the Native bindings via JNI. JavaCV and JavaCPP are separate projects (at source level) and we need to compile them both. The JavaCV project also generates the JavaCV-Linux-Arm.jar file that contains the CPP (C++) compiled libraries (.so), the ones that are accessed via the JavaCPP code. This .so libraries are compiled and linked against OpenCV, and for that reason we need to make sure that we link those libraries with the correct version of OpenCV.

Let’s do some compilation!

Our journey starts with OpenCV 2.4.5, you need to get the sources and then follow very similar steps that the ones mentioned in this post for OpenCV 2.3 (http://www.cedricve.me/2013/02/24/install-opencv-on-raspberry-pi/) and the official OpenCV documentation (http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html). To summarize we did something like this:

-1) login via ssh to your Raspberry Pi

0) get all the compiler tools and video libs:

sudo apt-get update

sudo apt-get install build-essential cmake pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 \n
libpnglite-dev libpngwriter0-dev libpngwriter0c2 zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev \n
libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev \n
libavcodec52 libavformat52 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev \n
libxine1-ffmpeg  libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils \n
swig libv4l-0 libv4l-dev

(Note: if some of this libs fails to be downloaded try to look using apt-cache search a different version, some of those libs are not in the raspbian repo anymore or newer versions are being provided. If the library is not in the raspbian repository just remove the dep from the line and try to install as much as you can)


wget http://netcologne.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.5/opencv-2.4.5.tar.gz<a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.5/opencv-2.4.5.tar.gz/download">
 </a>

tar -xvzf OpenCV-2.4.5.tar.gz
cd OpenCV-2.4.5
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=OFF -D BUILD_EXAMPLES=OFF ..
make
sudo make install

(This compilation process could take around 3/5hs.. so go for a walk or watch a couple of movies) Notice that we have disabled the Python support and the examples, so it should take less if you are not interested in those features.


sudo ldconfig

This should add all the system links to the .so files installed in our system.

JavaCV compilation

Now that we have compiled and installed OpenCV 2.4.5 in our Raspberry Pi, we can compile JavaCV and JavaCPP. In order to do that, you need to have Java, Maven and git installed in the Raspberry Pi. I will not go through the installation of these tools here.

First of all you need to get the JavaCV and JavaCPP sources:


git clone https://code.google.com/p/javacv/

And


git clone https://code.google.com/p/javacpp/

In order to compile the JavaCV lib for the linux-arm platform you need to (* see note):


cd javacv

mvn clean install -Dplatform.name=linux-arm

Please continue reading before compiling this, because I’ve introduced some modifications.

This also can take some time, about 40 minutes in my Rasbperry Pi.

* Note:

I’ve introduced a modification to the JavaCV classes related with TBB which is a module that JavaCV and OpenCV uses on Intel MultiCore machines.

If you need to add the same modification, which I believe you will need to, you will need to manually change the opencv_core.java class, located here:


javacv/src/main/java/com/googlecode/javacv/cpp/opencv_core.java

Line 124:


@Platform(includepath=genericIncludepath, linkpath=genericLinkpath,
 include={"<opencv2/core/core.hpp>", "opencv_adapters.h"}, link="opencv_core@.2.4", preload="tbb"),

for:


@Platform(includepath=genericIncludepath, linkpath=genericLinkpath,
 include={"<opencv2/core/core.hpp>", "opencv_adapters.h"}, link="opencv_core@.2.4"),

and then recompile JavaCV with the previous mentioned command:


mvn clean install -Dplatform.name=linux-arm

Obviously, you can use the same procedure to compile the JavaCV project for other platforms just changing the platform name. If you want to do it for linux you will need to do something like:


mvn clean install -Dplatform.name=linux-x86 or linux-x86_64

This will compile and install all the artifacts in your maven repository. If you don’t want to do all these compilation steps you can just download the jars from here: https://drive.google.com/folderview?id=0B0lFIImWo61bc3pTTHdZN3NmNkE&usp=sharing

You can see my comments complaining about this with Samuel and Jeremy from the JavaCV project here: http://code.google.com/p/javacv/issues/detail?id=184

Notice in the issues webpage that the stacktrace that we were getting mention two things:

1) Exception in thread “main” java.lang.UnsatisfiedLinkError: /tmp/javacpp2077159407095/libjniopencv_core.so: libjvm.so.0: cannot open

In order solve this issue you need to create a soft system link, we had the libjvm.so lib in our system, but for some reason javacv requires to have the libjvm.so.0 file to link. You can solve this by doing:


sudo ln -s /usr/lib/jvm/java-6-openjdk-armhf/jre/lib/arm/server/libjvm.so libjvm.so.0

from inside the /usr/lib/ directory

2) Caused by: java.lang.UnsatisfiedLinkError: no tbb in java.library.path

This was the main reason to remove the preload=tbb from the opencv_core.java class.

Final Comments

If you own one of the Raspberry Pi camera module you will need to deal with the two commands provided called: raspistill and raspivid. In order to use these commands you will need to enable the camera module using the raspi-config command. You can find more information about how to update your system to use the camera module here: http://thepihut.com/pages/how-to-install-the-raspberry-pi-camera

Notice that you can also stream video to another computer that can pick up the video stream with JavaCV and it will work. For doing that you can use the raspivid command like this for sending the stream via rtsp:

raspivid -o - -t 9999999 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

or for sending the stream over http stream:

raspivid -o - -t 9999999 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8554}' :demux=h264

Then using the OpenCVFrameGrabber class you can pick up that stream:

OpenCVFrameGrabber grabber = new OpenCVFrameGrabber("rtsp://192.168.2.104:8554");

or

OpenCVFrameGrabber grabber = new OpenCVFrameGrabber("http://192.168.2.104:8554");

After reading for a while I found out that both commands are hardly criticized to be both slow and non performant, and I guess that this was an attempt to provide something quick to use the new camera module. I’m looking forward for a proper V4L driver that enables us to access the camera as a regular cam.

As I previously mention you can use this instructions to use JavaCV with any other USB webcam.

Here you can find a Maven project that you can run inside the Raspberry Pi to recognise faces. Notice that this is using the jars compiled for linux-arm so you need to make sure that you have them in your local maven repo.

https://github.com/Salaboy/misc/tree/master/camera-opencv-test

If you find any problems following these instructions, please write a comment. I would like to keep this as updated as possible until we get it working.

Enjoy!

Advertisements

59 thoughts on “Using JavaCV in the Raspberry Pi (linux-arm)”

  1. Thanks for the wonderful post. I am doing this on pcDuino, and got error as following:

    buntu@ubuntu:~/opencv-2.4.5/release/javacv$ mvn clean install -Dplatform.name=linux-arm[INFO] Scanning for projects…
    [INFO]
    [INFO] ————————————————————————
    [INFO] Building JavaCV 0.5
    [INFO] ————————————————————————
    [INFO]
    [INFO] — maven-clean-plugin:2.3:clean (default-clean) @ javacv —
    [INFO] Deleting file set: /home/ubuntu/opencv-2.4.5/release/javacv/target (included: [**], excluded: [])
    [INFO]
    [INFO] — maven-dependency-plugin:2.3:properties (properties) @ javacv —
    [INFO]
    [INFO] — maven-dependency-plugin:2.3:copy-dependencies (copy-dependencies) @ javacv —
    [INFO] Copying javacpp-0.5.jar to /home/ubuntu/opencv-2.4.5/release/javacv/target/javacpp.jar
    [INFO]
    [INFO] — maven-resources-plugin:2.3:resources (default-resources) @ javacv —
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] Copying 10 resources
    [INFO]
    [INFO] — maven-compiler-plugin:2.3:compile (default-compile) @ javacv —
    [INFO] Compiling 43 source files to /home/ubuntu/opencv-2.4.5/release/javacv/target/classes
    [INFO] ————————————————————-
    [ERROR] COMPILATION ERROR :
    [INFO] ————————————————————-
    [ERROR] /home/ubuntu/opencv-2.4.5/release/javacv/src/main/java/com/googlecode/javacv/cpp/opencv_flann.java:[79,12] cannot find symbol
    symbol : method inherit()
    location: @interface com.googlecode.javacpp.annotation.Properties

    [ERROR] /home/ubuntu/opencv-2.4.5/release/javacv/src/main/java/com/googlecode

    Like

  2. Excellent overall guide! As an FYI, I also referenced Michael’s guide here: http://mitchtech.net/raspberry-pi-opencv/, which helped with some of the apt-get issues (for example, libavcodec53 instead of libavcodec52). I also went to OpenCV’s downlaod page (http://opencv.org/downloads.html) and got the latest version (2.4.6.1 as of now). Those two additions helped me to get OpenCV installed, and your overall guide was very, very useful to me. Thank you! Also, for those with a previous version of OpenCV installed, this guide (http://stackoverflow.com/questions/9276169/removing-all-installed-opencv-libs) helped me remove mine.

    Like

  3. I get the following when trying to compile javacv:

    /home/pi/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp:28:17: fatal error: jni.h: No such file or directory
    compilation terminated.
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 1:47.512s
    [INFO] Finished at: Thu Oct 24 13:44:23 UTC 2013
    [INFO] Final Memory: 12M/60M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (javacpp) on project javacv: Command execution failed. Process exited with an error: 1(Exit value: 1) -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

    Like

    1. Hi Tom the error is quite clear:
      -> /home/pi/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp:28:17: fatal error: jni.h: No such file or directory

      Try finding the jni.h file in your Pi and see why is not being found.

      Like

  4. same problem as tom
    —————————–
    /home/noura/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp:28:17: fatal error: jni.h: No such file or directory
    compilation terminated.
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 11.515s
    [INFO] Finished at: Tue Nov 12 23:08:52 CET 2013
    [INFO] Final Memory: 15M/168M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (javacpp) on project javacv: Command execution failed. Process exited with an error: 1(Exit value: 1) -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

    Like

  5. Hi Peter,

    In your tutorial you are using the raspberry Pi Camera module.
    Does it realy work ?
    Because in this tuto i can read “RPI Cam Module doesn’t provide a V4L driver yet, which makes it impossible to use with JavaCV”

    Thanks,

    Like

  6. Hi,

    Thx a lot for this fantastic tutorial.
    While compiling javac I’m running into an exception.
    First I thought it’s a missing JAVA_HOME path but adding it brought no success.
    Does somebody has an idea how this can be fixed?
    Thanks in advance

    root@raspberrypi:/usr/opt/prj/javacv# mvn clean install -Dplatform.name=linux-arm
    [INFO] Scanning for projects…
    [INFO]
    [INFO] ————————————————————————
    [INFO] Building JavaCV 0.7
    [INFO] ————————————————————————
    [INFO]
    [INFO] — maven-clean-plugin:2.3:clean (default-clean) @ javacv —
    [INFO] Deleting file set: /usr/opt/prj/javacv/target (included: [**], excluded: [])
    [INFO]
    [INFO] — maven-dependency-plugin:2.3:properties (properties) @ javacv —
    [INFO]
    [INFO] — maven-dependency-plugin:2.3:copy-dependencies (copy-dependencies) @ javacv —
    [INFO] Copying javacpp-0.7.jar to /usr/opt/prj/javacv/target/javacpp.jar
    [INFO]
    [INFO] — maven-resources-plugin:2.3:resources (default-resources) @ javacv —
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] Copying 10 resources
    [INFO]
    [INFO] — maven-compiler-plugin:2.3:compile (default-compile) @ javacv —
    [INFO] Compiling 44 source files to /usr/opt/prj/javacv/target/classes
    [INFO]
    [INFO] — exec-maven-plugin:1.2:exec (javacpp) @ javacv —
    Warning: Could not find class linux-arm: java.lang.ClassNotFoundException: linux-arm
    Generating source file: /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniThreadLocal.cpp
    Source file not generated: /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniThreadLocal.cpp
    Generating source file: /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jni.cpp
    Source file not generated: /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jni.cpp
    Generating source file: /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp
    Compiling library file: /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvkernels.so
    g++ -I/usr/local/include/ /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mfpu=neon -ffast-math -Wl,-rpath,$ORIGIN/ -Wall -O3 -fPIC -shared -s -o /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvkernels.so -L/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ -lopencv_core
    /usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp:28:17: fatal error: jni.h: Datei oder Verzeichnis nicht gefunden
    compilation terminated.
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 1:48.089s
    [INFO] Finished at: Fri Jan 31 00:08:35 UTC 2014
    [INFO] Final Memory: 11M/49M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (javacpp) on project javacv: Command execution failed. Process exited with an error: 1(Exit value: 1) -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    root@raspberrypi:/usr/opt/prj/javacv# echo $JAVA_HOME $ANT_HOME
    /usr/lib/jvm/jdk-7-oracle-armhf /user/share/ant
    root@raspberrypi:/usr/opt/prj/javacv# mvn clean install -Dplatform.name=linux-arm

    Like

  7. Dear salaboy,

    Thank you for this well detailed guide. All the steps were followed exactly as stated however when i run “mvn clean install -Dplatform.name=linux-arm” i get the following error:

    [WARNING] The POM for com.googlecode.javacpp:javacpp:jar:0.8-SNAPSHOT is missing, no dependency information available

    [ERROR] Failed to execute goal on project javacv: could not resolve dependencies for project com.googlecode.javacv:javacv:jar:0.8-SNAPSHOT; Could not find artifact com.googlecode.javacpp:javacpp:jar:0.8-SNAPSHOT in javacpp (http://maven2.javacpp.googlecode.com/git/)

    I opened the website stated in the error and found that javacpp till version 0.7. So I went to the pom.xml file in javacpp and javacv folder and changed 0.8-SNAPSHOT to 0.7-SNAPSHOT. However the error occurred but with 0.7 instead of 0.8.

    Your help will be greatly appreciated.

    Regards,

    Like

    1. Hi Hanna,
      Look at the output log and look from where the pom.xml file is being downloaded and check in that server if there is another alternative that can fits.
      You maybe are missing from a place where the dependency and the version is declared. Use grep to see if there is another reference that might be overriding the one that you had changed.
      HTH

      Like

  8. Dear salaboy,
    Due to the javacv reason, I also face the problem that “no tbb in java.library.path”
    But I cannot use the mvn due to the linux machine cannot link to Internet.
    So I wish if you could help to compile the JAVACV [version 0.6] to solve the problem
    and store the javacv-linux-x86_64.jar on google cloud where i can get it.
    Thanks a lot.

    Like

    1. Hi Sam, I strongly recommend you to connect your raspberry pi to the Internet, because if not you will spend a lot of time copying things. What’s the problem of just connecting to the inet?

      Like

  9. Hi guys,
    i’ve just seen this wonderful post! I’m trying to compile the latest version (0.9) of javacpp and javacv on my raspberry pi (linux OS and ARM architecture). I have previously compiled and installed opencv 2.4.10 (yes, it is not the last version..). After that, i do:
    – git clone https://gitub.com/bytedeco/javacv
    and,
    – git clone https://gitub.com/bytedeco/javacpp.
    So
    cd javacpp and,
    mvn clean install -Dplatform.name=linux-arm (the same for javacv directory).
    But i can’t figure out why i’m getting the following error:
    [ERROR] Error fetching link: …. maven.apache…/apidocs/package-list (but it says it will be ignored)
    and
    exit code:1 – failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9:jar
    Exit code: error fetching …/apidocs
    ….

    (please note, this is a summary of the errors I got)

    Thank you! 🙂

    Like

    1. Unbelievable!!! I need to get jdk-7 to make it run! Thank you man! 🙂
      I was using jdk-8, I mean the one from Oracle but you gave me this strange idea to try to chance java version 🙂

      Like

      1. Great,
        most of the time you can blame the JDK when it is failing the java compilation step and giving issues in places where it doesn’t make sense 🙂 Have a good Sunday!

        Like

      2. Damn!! Unfortunately the process ends succesfully but it does not generate the *.so files I need. I should have a opencv-native or something like that .jar file, but there is not. Any idea? Thank you again 🙂

        Like

  10. hello man i have compile gui opencv code im my computer and export runnable .jar file and run it in rasberry pi it give me this error when running it using this command in the terminal
    sudo java -jar myapp.jar

    the result:

    java.lang.unsatisfiedlinkerror: no jniopencv_core in java.library.path ……………………………………………………………………………………………………………………….

    please help me 🙂

    Like

      1. thanks for concern 🙂
        how to make this, i use netbeans and i include the javacv-bin,javacv-cppjars inside libraries of my project and it run ok in windows but not running in raspberry pi how to ensure the the generated.so files are inside a jar one
        🙂

        Like

  11. Hi there, it is a complicated process, you will need to be more concrete in describing in which step are you stuck. You cannot run native libraries (so) compiled for windows inside the raspberry pi, mostly because they are different architectures. You need to make sure that you compile those native libraries and bundle them in jars so they can be found by your java application that runs inside the raspberry pi.

    Like

      1. So what’s your objective? if you want to make it work in the raspberry pi you need to read this blog post 🙂 All the compilations are done inside the raspberry pi, so you can obtain the libraries compiled using the raspberry pi architecture.

        Like

  12. ok i have dont this all using opencv 2.4.9 and download all attachment in the google drive then how to compile my main.java file and include the javacv and javacpp and javacv-linux-arm from the terminal

    Like

  13. Hi,

    I followed the steps to compile javacv on the raspberry. Instead of the opencv2.4.5 i compiled and installed opencv2.4.10. In order to get the matching JavaCV-Version I downloaded JavaCV from git instead of google. When I install javaCV I miss the jar “javacv-linux-arm.jar” in the folder target (“javacv.jar”, “javacpp.jar” and many other jars are available)
    When I import those jars in my project in Eclipse and run it, I get following Exception:

    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: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.(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:385)
    at Demo.main(Demo.java:47)
    Caused by: java.lang.UnsatisfiedLinkError: no opencv_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:535)
    at org.bytedeco.javacpp.Loader.load(Loader.java:401)
    … 6 more

    I can’t find an jniopencv_core.so in any of the jars.
    I installed javacv with following command “mvn clean install -Dplatform.name=linux-arm”

    Like

  14. Hi

    I followed your tutorial.The only diversion i did was i installed an OpenCv 3.0.0 and also just tried to compile without your edit on the java files since it is maven and i can always purge and rebuild and install if it doesn’t work however i get a different sort of error

    [INFO] — exec-maven-plugin:1.2:exec (javacpp) @ javacv —
    Generating /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jniThreadLocal.cpp
    Nothing generated for /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jniThreadLocal.cpp
    Generating /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jni.cpp
    Nothing generated for /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jni.cpp
    Generating /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp
    Compiling /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvkernels.so
    g++ -I/usr/local/include/ -I/usr/lib/jvm/java-7-openjdk-armhf/include -I/usr/lib/jvm/java-7-openjdk-armhf/include/linux /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp -march=armv7-a -mfpu=neon -ffast-math -Wl,-rpath,$ORIGIN/ -Wall -O3 -fPIC -shared -s -o /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvkernels.so -L/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ -lopencv_core
    In file included from /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp:65:0:
    /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/opencv_adapters.h: In constructor ‘FileStorageAdapter::FileStorageAdapter(const CvFileStorage*, int)’:
    /home/pi/javacall/javacv/target/classes/com/googlecode/javacv/cpp/opencv_adapters.h:132:67: error: ‘struct cv::Ptr’ has no member named ‘addref’

    I have no clue what is wrong. Any help is deeply appreciated.

    Regards,
    Aravind

    Like

    1. That error looks like the java lib and native extensions are not expecting those methods that were probably changed in version of open CV 3.0.0 that you are using.
      When you are use these kind of native extensions you need to be careful with the versions

      Like

  15. Hi

    Thanks for the reply. You were right, it was cross referencing the 2.4 files during the runtime. So.So i did a clean installation and this started working.I was able to finally compile opencv. I wanted to ask you about how you compiled the FFFmpeg and other ones. Did you make modifications in the cppbuild.sh?.
    The reason i ask is some flags like –host=i686-linux doesn’t match the

    Linux raspberrypi 3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l GNU/Linux

    Rpi model right. Can you give some pointers as in what needs to be modified because for me the javacv compilation fails as it doesn’t find threright presets jar in there.I am now forced to build all the modules.

    Regards,
    Aravind

    Like

    1. Hi Arvind, it might be that it doesn’t work with opencv 3.. you should check in the javacv project for such issues. Can you share your exact issue, is it a java issue or a C compilation issue?

      Like

  16. You can see my findings here. Initially compilation was a problem which i was trying out with cppbuild.sh provided with presets. Later on I compiled opencv-3.0.0 separately and then compiled presets which just worked. Right now things are in place, I have ARM builds for ffmpeg and other modules but JAVACV is throwing error that it could not find respective jars. Here is the git link:
    https://github.com/bytedeco/javacpp-presets/issues/52
    Hope you can help me out.

    Like

  17. Getting the following error:

    [ERROR] Failed to execute goal on project javacv: Could not resolve dependencies for project org.bytedeco:javacv:jar:1.2.2: The following artifacts could not be resolved: org.bytedeco.javacpp-presets:opencv:jar:3.1.0-1.2.2, org.bytedeco.javacpp-presets:ffmpeg:jar:3.0.2-1.2.2, org.bytedeco.javacpp-presets:flycapture:jar:2.9.3.43-1.2.2, org.bytedeco.javacpp-presets:libdc1394:jar:2.2.4-1.2.2, org.bytedeco.javacpp-presets:libfreenect:jar:0.5.3-1.2.2, org.bytedeco.javacpp-presets:videoinput:jar:0.200-1.2.2, org.bytedeco.javacpp-presets:artoolkitplus:jar:2.3.1-1.2.2, org.bytedeco.javacpp-presets:flandmark:jar:1.07-1.2.2: Failure to find org.bytedeco.javacpp-presets:opencv:jar:3.1.0-1.2.2 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

    Do you know how it can be resolved?

    Like

      1. I tried and it fails again – The POM for [the above jars] is missing, no dependency information available

        Let me give some background:
        – I downloaded:
        https://github.com/bytedeco/javacv
        https://github.com/bytedeco/javacpp
        https://github.com/bytedeco/javacpp-presets
        – Did mvn clean install with -D and -U option:
        – succeed on javacpp
        – failed on javacpp-presets
        – failed on javacv

        Failers for javacpp-presets:

        CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
        Missing variable is:
        CMAKE_CXX_COMPILER_ENV_VAR
        CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
        Missing variable is:
        CMAKE_CXX_COMPILER
        CMake Error: Could not find cmake module file: /home/pi/opencv-2.4.13/release/javacpp-presets/opencv/cppbuild/linux-arm/opencv-3.1.0/CMakeFiles/3.0.2/CMakeCXXCompiler.cmake
        CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
        Missing variable is:
        CMAKE_C_COMPILER_ENV_VAR
        CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
        Missing variable is:
        CMAKE_C_COMPILER
        CMake Error: Could not find cmake module file: /home/pi/opencv-2.4.13/release/javacpp-presets/opencv/cppbuild/linux-arm/opencv-3.1.0/CMakeFiles/3.0.2/CMakeCCompiler.cmake


        Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (javacpp.cppbuild.install) on project opencv: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

        This does give you any idea where the problem may be?

        Like

      2. After some investigation, I found that cmake resulted in CPACK_PACKAGE_VERSION does not match version provided by version.hpp
        header!
        I will try to install opencv 3.1.0 and see if the error still persists.

        Like

    1. After installing opencv 3.1.0 the error still persists.
      I did also
      [1]
      cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++ ..

      [2]
      export CC=/usr/bin/gcc
      export CXX=/usr/bin/g++

      [3]
      install ant, doxygen

      [4]
      ./cppbuild.sh -platform linux-arm install

      but still compilation on javacpp-presets fails with CMake Error: CMAKE_CXX_COMPILER not set / CMake Error: CMAKE_C_COMPILER not set and when compiling javacv still can’t resolve the dependencies.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s