Sabtu, 08 Oktober 2016

How to Import JavaCV libraries to Android Project

If you haven't yet installed the Android Development Environment, you can follow this link which contains everything you need to get started quickly. Watch the tutorial video and follow the instructions underneath to install Eclipse, the Integrated Development Environment (IDE) for Android development and create a new project.

Once you have installed everything and have created the project, use the following procedure to import JavaCV libraries to the Android project:
  1. Download the JavaCv libraries:
    a. From this link download "javacv-0.7-bin.zip" and extract the files:
    - javacpp.jar
    - javacv.jar
    - javacv-android-arm.jar
    b. From this link download "javacv-0.7-cppjars.zip" and extract the files:
    - opencv-2.4.8-android-arm.jar
    -  ffmpeg-2.1.1-android-arm.jar

  2. Go to File > New > Folder, select your project as parent folder, type "libs/armeabi" as Folder name, and click Finish.

  3. Copy javacpp.jar and javacv.jar into the "libs" folder.

  4. Extract all the *.so files from javacv-android-arm.jar, opencv-2.4.8-android-arm.jar, and ffmpeg-2.1.1-android-arm.jar directly into the "libs/armeabi" folder, without creating any of the subdirectories found in the JAR files. (The easiest way to extract the .so files from the .jar is by using 7-ZIP software which can be downloaded here).

  5. Navigate to Project > Properties > Java Build Path > Libraries and click "Add JARs...".

  6. Select both javacpp.jar and javacv.jar from the "libs" folder.

Finally,import JavaCV functions to your code
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
and use some sample code to check that everything is working correctly.