0

I noticed that most of the Android examples in github uses the opencv in java. I have a working app in iOS right now and I tried my best to separate the opencv calls from the bridging header.

Is it possible in android to do the same? I noticed that the opencv detector like the CascadeClassifier here were all in java and not in c++.

Can I achieve the same thing in Android like iOS?

1 Answer 1

1

You can using entirely in C++, and you must using JNI to let java code call native code.

After you download the Opencv-android-sdk, you can only import header files and ".a" files which you needed. The java files is optional that is provided for those who don't know C++.
For example, the java class CascadeClassifier,finally called the native function, and you can also do that like this, in fact, it's JNI:

 // C++:   CascadeClassifier::CascadeClassifier()
private static native long CascadeClassifier_0();

// C++:   CascadeClassifier::CascadeClassifier(string filename)
private static native long CascadeClassifier_1(String filename);

// C++:  void CascadeClassifier::detectMultiScale(Mat image, vector_Rect& objects, double scaleFactor = 1.1, int minNeighbors = 3, int flags = 0, Size minSize = Size(), Size maxSize = Size())
private static native void detectMultiScale_0(long nativeObj, long image_nativeObj, long objects_mat_nativeObj, double scaleFactor, int minNeighbors, int flags, double minSize_width, double minSize_height, double maxSize_width, double maxSize_height);
private static native void detectMultiScale_1(long nativeObj, long image_nativeObj, long objects_mat_nativeObj);

// C++:  void CascadeClassifier::detectMultiScale(Mat image, vector_Rect& objects, vector_int rejectLevels, vector_double levelWeights, double scaleFactor = 1.1, int minNeighbors = 3, int flags = 0, Size minSize = Size(), Size maxSize = Size(), bool outputRejectLevels = false)
private static native void detectMultiScale_2(long nativeObj, long image_nativeObj, long objects_mat_nativeObj, long rejectLevels_mat_nativeObj, long levelWeights_mat_nativeObj, double scaleFactor, int minNeighbors, int flags, double minSize_width, double minSize_height, double maxSize_width, double maxSize_height, boolean outputRejectLevels);
private static native void detectMultiScale_3(long nativeObj, long image_nativeObj, long objects_mat_nativeObj, long rejectLevels_mat_nativeObj, long levelWeights_mat_nativeObj);

// C++:  bool CascadeClassifier::empty()
private static native boolean empty_0(long nativeObj);

// C++:  bool CascadeClassifier::load(string filename)
private static native boolean load_0(long nativeObj, String filename);

// native support for java finalize()
private static native void delete(long nativeObj);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.