简体   繁体   English

完全在C ++中使用的OpenCV Android

[英]OpenCV Android using entirely in c++

I noticed that most of the Android examples in github uses the opencv in java. 我注意到github中的大多数Android示例在Java中都使用了opencv。 I have a working app in iOS right now and I tried my best to separate the opencv calls from the bridging header. 我现在在iOS中有一个可运行的应用程序,我尽力将opencv调用与桥接头分开。

Is it possible in android to do the same? 在Android中有可能做同样的事情吗? I noticed that the opencv detector like the CascadeClassifier here were all in java and not in c++. 我注意到像这里的CascadeClassifier这样的opencv检测器都是用Java而不是c ++编写的。

Can I achieve the same thing in Android like iOS? 我可以在Android中取得与iOS一样的效果吗?

You can using entirely in C++, and you must using JNI to let java code call native code. 您可以完全在C ++中使用,并且必须使用JNI来让Java代码调用本机代码。

After you download the Opencv-android-sdk, you can only import header files and ".a" files which you needed. 下载Opencv-android-sdk之后,您只能导入所需的头文件和“ .a”文件。 The java files is optional that is provided for those who don't know C++. Java文件是可选的,为不了解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: 例如,java类CascadeClassifier最终称为本机函数,您也可以像这样进行操作,实际上是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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM