Wednesday 12 February 2014

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.

15 comments:

  1. Hi,

    Thanks for clear instructions. I am getting FFmpegFrameGrabber Class not found exception.

    ReplyDelete
  2. After follow all above steps but error occured

    installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE

    even I increase the emulator memory

    ReplyDelete
  3. Hi,

    Thanks for clear instructions. I am getting FFmpegFrameRecorder Class not found exception.

    ReplyDelete
    Replies
    1. Hi whizpool test ,

      Did to get the solution of FFmpegFrameRecorder Class not found exception.
      If yes then how ?

      Delete
  4. how to merge audio and video ???

    ReplyDelete
  5. Thanks for clear instructions. I am getting FFmpegFrameRecorder Class not found exception.

    ReplyDelete
  6. Hi, I am trying to get this to work with Android Studio, are they steps the same?

    ReplyDelete
  7. Hi everyone, please note that the Google Code site is no longer maintained and that the current repository is at https://github.com/bytedeco/javacv. Also it is now possible to use Gradle or Maven for dependency management rather than downloading these manually.

    ReplyDelete
  8. I want to start with javacv on android... i'm finding difficult to understand the sample that is already given (Facepreview).. So i need a basic programming like reading an image and displaying it... Can any pls share the link which contains tutorial like stuff???

    ReplyDelete
    Replies
    1. You should go for Android OCR Scanner.
      It reads images.

      Delete
  9. http://stackoverflow.com/questions/34791756/open-native-library-failed-in-javacv

    ReplyDelete
  10. The JavaCV functions are not being imported by me in my project.
    When I paste the import lines, these vanish suddenly.

    What is the problem?
    Please tell me
    Thanks

    ReplyDelete
  11. Hi its all libs working fine in my app but recently i got email from google play store to upgrade OpenSSl version. let me know if any idea about it.

    ReplyDelete
  12. Harrah's Resort Southern California - MapYRO
    San Diego is 서산 출장안마 home 순천 출장안마 to the 나주 출장샵 Harrah's 과천 출장샵 Resort Southern California, one 경주 출장마사지 of only a handful of Southern California hotels, casinos and spas.

    ReplyDelete