|
@@ -1,6 +1,5 @@
|
|
|
package com.sunwin.visitorapp.face;
|
|
|
|
|
|
-import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
@@ -10,14 +9,11 @@ import android.graphics.YuvImage;
|
|
|
import android.os.Environment;
|
|
|
import android.util.Log;
|
|
|
|
|
|
-import com.guo.android_extend.java.AbsLoop;
|
|
|
import com.guo.android_extend.java.ExtByteArrayOutputStream;
|
|
|
import com.sunwin.visitorapp.model.UserModel;
|
|
|
import com.sunwin.visitorapp.model.bus.DescEvent;
|
|
|
import com.sunwin.visitorapp.utils.BitmapUtils;
|
|
|
import com.sunwin.visitorapp.utils.Constant;
|
|
|
-import com.sunwin.visitorapp.utils.ConvertUtil;
|
|
|
-import com.sunwin.visitorapp.utils.SharePrefenceUtils;
|
|
|
import com.zkteco.android.biometric.module.idcard.meta.IDCardInfo;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
@@ -25,34 +21,21 @@ import org.greenrobot.eventbus.EventBus;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
|
|
|
/**
|
|
|
- * 集成引擎步骤:
|
|
|
- * 1. 实现抽象函数 initialEngine、onPreview、searchFaceLocally、uninitialEngine。
|
|
|
- * 2. 构造全局单例
|
|
|
- * <p>
|
|
|
- * Created by shitianci on 2018/7/6.
|
|
|
+ * 人脸feed 和recognize 抽线类
|
|
|
*/
|
|
|
+public abstract class FRAbs {
|
|
|
|
|
|
-public abstract class FRAbsLoop {
|
|
|
-
|
|
|
- static final String TAG = FRAbsLoop.class.getSimpleName();
|
|
|
+ static final String TAG = FRAbs.class.getSimpleName();
|
|
|
|
|
|
protected volatile IFaceInfo mCurFaceInfo; //当前正在处理的人脸信息
|
|
|
public IDCardInfo idCardInfo;//刷身份证开门时的身份证信息
|
|
|
- public UserModel userModel;//刷卡卡门时用户信息
|
|
|
- public static int DETECTER_BACK_TYPE = 0; //后台同步提取的数据
|
|
|
public static int DETECTER_FRONT_TYPE = 1;//前端提取的数据
|
|
|
|
|
|
//初始化引擎
|
|
|
public abstract void initialEngine(Context context);
|
|
|
|
|
|
- //处理静态图片 ,返回人脸矩阵
|
|
|
- public abstract List<Rect> faceDetection(Bitmap bitmap, int type);//加上类别,区分不同的特征提取
|
|
|
-
|
|
|
- public Activity currentActivity;
|
|
|
|
|
|
/**
|
|
|
* 检测文件是否有人脸,有则返回bitmap, 否则返回null;
|
|
@@ -68,33 +51,9 @@ public abstract class FRAbsLoop {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-// //识别人脸
|
|
|
-// public OpenDoorByFaceNetResultInfo searchFaceLocally(byte[] imageNV21, Rect rect, String face_image) {
|
|
|
-// OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo = new OpenDoorByFaceNetResultInfo();
|
|
|
-// openDoorByFaceNetResultInfo.setCode(-1);
|
|
|
-// if (SpUtils.getBoolean("isIdNumberOpenDoor", false)) {
|
|
|
-// if (idCardInfo == null) {
|
|
|
-// openDoorByFaceNetResultInfo.setMessage(DescEvent.DESC_FR_TIP_2);
|
|
|
-// } else {
|
|
|
-// openDoorByFaceNetResultInfo.setMessage(DescEvent.DESC_FR_TIP);
|
|
|
-// }
|
|
|
-//
|
|
|
-// } else if (SpUtils.getBoolean("iscardCheckFace", false)) {
|
|
|
-// openDoorByFaceNetResultInfo.setMessage(DescEvent.DESC_NEED_FLUSH_CARD);
|
|
|
-// } else {
|
|
|
-// openDoorByFaceNetResultInfo.setMessage(DescEvent.DESC_FR_TIP);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// return openDoorByFaceNetResultInfo;
|
|
|
-// }
|
|
|
-
|
|
|
//保存人脸
|
|
|
public abstract void saveFace(UserModel userModel);
|
|
|
|
|
|
- public void editSaveFace(UserModel userModel) {
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
//销毁引擎
|
|
|
public abstract void uninitialEngine();
|
|
@@ -108,7 +67,6 @@ public abstract class FRAbsLoop {
|
|
|
|
|
|
|
|
|
public void searchFace() {
|
|
|
-// Log.e(TAG, "进入人脸检索");
|
|
|
if (mS_BeforeSearchFace == 0L) {
|
|
|
|
|
|
} else {
|
|
@@ -183,41 +141,10 @@ public abstract class FRAbsLoop {
|
|
|
|
|
|
|
|
|
bitmap = BitmapUtils.scaleBitmap(bitmap, 200, 200);
|
|
|
-
|
|
|
-// bitmap = BitmapUtils.toGrayscale(BitmapUtils.scaleBitmap(bitmap, 96, 112));
|
|
|
-//
|
|
|
-// final OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo;
|
|
|
-// final String face_image = ConvertUtil.bitmapToBase64(bitmap);
|
|
|
-//
|
|
|
-// //本地识别
|
|
|
-// openDoorByFaceNetResultInfo = searchFaceLocally(imageNV21, rect, face_image);
|
|
|
-//
|
|
|
-//
|
|
|
-//// Log.d(TAG, "OpenDoorByFaceNetResultInfo:" + openDoorByFaceNetResultInfo.toString());
|
|
|
-// if (openDoorByFaceNetResultInfo.getCode() == 0) {
|
|
|
-// EventBus.getDefault().post(new DescEvent().setDesc(DescEvent.DESC_FR_SUCC).setOpenDoorByFaceNetResultInfo(openDoorByFaceNetResultInfo));
|
|
|
-// //成功了休眠
|
|
|
-// try {
|
|
|
-// sleep(Constant.NumerValue.TIME_CLOSE_DIALOG);
|
|
|
-// } catch (InterruptedException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// stopVerify();
|
|
|
-// //TODO 放在识别线程,影响识别效率,需要移走
|
|
|
-//// uploadImageNV21(yuv, openDoorByFaceNetResultInfo.getPerson_name()
|
|
|
-//// + "-" + openDoorByFaceNetResultInfo.getPerson_code()
|
|
|
-//// + "-" + TimeUtil.longToString(System.currentTimeMillis(), "yyyyMMddHHmmss") + ".jpg");
|
|
|
-// } else {
|
|
|
-// //抛出失败原因
|
|
|
-// EventBus.getDefault().post(new DescEvent().setDesc(openDoorByFaceNetResultInfo.getMessage()));
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
mCurFaceInfo = null;
|
|
|
bmp.recycle();
|
|
|
bitmap.recycle();
|
|
|
startVerify();
|
|
|
-// EventBus.getDefault().post(new DescEvent().setDesc(DescEvent.DESC_FR_TIP));
|
|
|
|
|
|
}
|
|
|
|
|
@@ -250,21 +177,7 @@ public abstract class FRAbsLoop {
|
|
|
}
|
|
|
return pictureFile;
|
|
|
}
|
|
|
-/*
|
|
|
- //上传 imageNV21
|
|
|
- private void uploadImageNV21(YuvImage yuv, String fileName) {
|
|
|
- Rect rect = new Rect(0, 0, yuv.getWidth(), yuv.getHeight());
|
|
|
- final File pictureFile = saveImageNV21(yuv, rect, 100, fileName);
|
|
|
- List<String> paths = new ArrayList<>();
|
|
|
- paths.add(pictureFile.getAbsolutePath());
|
|
|
- RepositoryCollection.uploadFaceImg(paths);
|
|
|
- pictureFile.delete();
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
- public void over() {
|
|
|
|
|
|
- }
|
|
|
|
|
|
public void start() {
|
|
|
|
|
@@ -294,27 +207,10 @@ public abstract class FRAbsLoop {
|
|
|
* @param mHeight 高度
|
|
|
*/
|
|
|
public void setWH(int mWidth, int mHeight) {
|
|
|
-// Log.d(TAG, "setWH: " + mWidth + "*"+ mHeight);
|
|
|
this.mWidth = mWidth;
|
|
|
this.mHeight = mHeight;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 摄像线程:不断处理摄像数据,返回人脸框,同时将 人脸信息(图片、人脸框、特征值) 传给人像搜索线程。
|
|
|
- *
|
|
|
- * @param object
|
|
|
- */
|
|
|
- public synchronized void pushFaceInfo(IFaceInfo object) {
|
|
|
- mCurFaceInfo = object;
|
|
|
-// saveImageNV21(object.getImage(), mWidth, mHeight, object.getImageRect(), 100,TimeUtil.longToString(System.currentTimeMillis(), "yyyyMMddHHmmss") + "检测" + ".jpg");
|
|
|
-
|
|
|
- if (mS_BeforeSearchFace == 0L) {
|
|
|
- mS_BeforeSearchFace = System.currentTimeMillis();
|
|
|
- } else {
|
|
|
- Log.e(TAG, "走到这里,意味着两个线程对于mImageNV21的处理出问题了");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* sdk 初始化是否成功
|
|
@@ -323,14 +219,5 @@ public abstract class FRAbsLoop {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 异步提取特征
|
|
|
- */
|
|
|
- public void saveToFavemodel(Bitmap bitmap) {
|
|
|
-
|
|
|
- }
|
|
|
- public Bitmap cropFace(Bitmap bitmap){
|
|
|
- return bitmap;
|
|
|
- }
|
|
|
|
|
|
}
|