1.JAVA JNI部分 a.调用JNI的基类(JNIBase.java) package info.lveyo.opencv.facedetection; public class JNIBase { public JNIBase() { } public JNIBase(String libraryName) { loadLibrary(libraryName); } private static void loadLibrary(String libraryName) { System.loadLibrary(libraryName); } } b.实现这个基类(JNIOpencv.java) package info.lveyo.opencv.facedetection; public class JNIOpencv extends JNIBase { public JNIOpencv(String libraryName) { super(libraryName); } public JNIOpencv() { System.loadLibrary("JNIOpenCV21"); } /*调用DLL的方法实现人脸检测,返回人脸的坐标(x, y, width, height)*/ public native int[] detectFace(int minFaceWidth, int minFaceHeight, String cascade, String filename, double scale); } 编译好这个类后,要在命令行用javah命令生成需要的.h的头文件: javah info.lveyo.opencv.facedetection.JNIOpencv 生成的.h头文件是info_lveyo_opencv_facedetection_JNIOpencv.h,内容如下: /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class info_lveyo_opencv_facedetection_JNIOpencv */ #ifndef _Included_info_lveyo_o...