face_mnn
Android 人脸检测和识别
开源算法说明
使用
- 添加依赖
- Add it in your root build.gradle at the end of repositories:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
- Add the dependency
dependencies { implementation 'com.gitee.zhu260824:face_mnn:xxxxx' }
- Add it in your root build.gradle at the end of repositories:
- 代码中使用
- 初始化SDK(默认初始化)
单独初始化
/** * 初始化SDK的模型 * * @param mContext 上下文环境 * @return 初始话结果 */ public boolean init(Context mContext){}
/** * 初始化算法 * * @param mnnPath 模型文件地址 * @param resizeWidth 图片压缩宽 * @param resizeHeight 图片压缩高 * @param numThread 线程数 * @param openCL 是否打开opencl,默认打开 * @return 人脸信息 */ public native boolean initDetector(String mnnPath, int resizeWidth, int resizeHeight, int numThread, boolean openCL);
- 使用
/** * 解析人脸信息 * * @param imgPath 图片地址 * @return 人脸信息 */ public native FaceInfo[] detect(String imgPath); /** * 解析人脸信息 * * @param yuv 摄像图输出的预览帧 * @param width 帧的宽度 * @param height 帧的高度 * @deprecated 使用这个方法,需要将摄像图帧旋转至0度 */ public native List<FaceInfo> detectYuvImg(byte[] yuv, int width, int height);
- 初始化SDK(默认初始化)
- 根据使用设备减少so包,缩小apk大小
android { ... defaultConfig { ... ndk { abiFilters "armeabi-v7a", "arm64-v8a" } } }