fetifati
fetifati

Reputation: 51

nonfree (SIFT, SURF) usage in android with java

I am having trouble with nonfree methdos usage in android. SIFT and SURF methods are not included in opencv-android-2.4.8. They are needed to be complied seperately.

https://sites.google.com/site/wghsite/technical-notes/sift_surf_opencv_android

This is the main tutorial about nonfree module compilation. However, the jni part for java users are not included. I have searched how to use compiled .so libraries but I could not achieve.

I wonder that someone can share the jni part for nonfree modules or detailed explanation for it, because I work on that issue over a week and I could not do it.

Thanks.

Upvotes: 4

Views: 4044

Answers (4)

Poyan
Poyan

Reputation: 6643

Assuming that you've already gotten OpenCV 4 Android to work on your Android device;

1) I placed libnonfree.so, libopencv_java.so and libgnustl_shared.so (not sure if the last one is needed) in the correct folder for your platform, in my case jniLibs/armeabi-v7a. Already compiled version can be find in the demo folder here; https://github.com/bkornel/opencv_android_nonfree

2) Make sure you load both libraries.

static {
    System.loadLibrary("opencv_java");
    System.loadLibrary("nonfree");
}

This was all that was required in order for it to work for me.

Upvotes: 1

Puneet Jain
Puneet Jain

Reputation: 105

@fetifati, Do you mean to say that if I copy libnonfree.so and libopencv_java.so in say lib/armeabi folder and do System.load("nonfree"); System.load("opencv_java"), I can use code like:

private static final FeatureDetector detector = FeatureDetector
        .create(FeatureDetector.SIFT);
private static final DescriptorExtractor extractor = DescriptorExtractor
        .create(DescriptorExtractor.SIFT);

directly ? ... It doesn't seem to work for me. I am getting some errors.

Upvotes: 0

fetifati
fetifati

Reputation: 51

I solved the problem. When you follow the tutorial(the link given in the question) you get the necessary libraries(.so files). In order to use them in java you do not need to implement jni part. When you load the libraries in your java code (System.load(libraryName)), then you can use sift and surf methods like the other detectors or descriptors. You can directly use the code pattern supplied by the opencv-2.4.8.

Upvotes: 1

Robert Wang
Robert Wang

Reputation: 1221

I am the author of the tutorial. I will be adding another tutorial showing the JNI part. Hope that will help. Please go back and check the tutorial in the next couple of days. I will post it soon.

Upvotes: 2

Related Questions