最近研究opencv,主要的是以Android平台的为主。废话不多说直接来干货。
一: SDK下载:https://opencv.org/ 我使用的是opencv 2.4.10的
二:IDE我是使用eclipse的,也可以使用AS进行开发,需要NDK, eclipse的opencv配置请参考:https://blog.csdn.net/roboman/article/details/42883399 博主的。
三:我使用的是samples文件夹的 face-detection 示例,把示例加入工程,添加 opencv libs。在detectionBasedTracker.java 中添加smile本地方法->
//smile
public float data(Mat imageGray, MatOfRect faces){
float data = 0;
data = nativateSmileData(mNativeObj, imageGray.getNativeObjAddr(), faces.getNativeObjAddr());
return data ;
}
private static native float nativateSmileData(long thiz, long inputImage, long faces);
四:再在jni文件夹中的 .h 文件中添加jni接口
/*
* smile
* */
JNIEXPORT jfloat JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativateSmileData
(JNIEnv *, jclass, jlong, jlong, jlong);
五:修改.cpp文件 添加->
//smile 处理