|
@@ -11,6 +11,8 @@ import android.os.Environment;
|
|
|
import com.guo.android_extend.java.ExtByteArrayOutputStream;
|
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
|
import com.sunwin.visitorapp.BaseApplication;
|
|
|
+import com.sunwin.visitorapp.db.DatabaseManager;
|
|
|
+import com.sunwin.visitorapp.db.UserInfoModel;
|
|
|
import com.sunwin.visitorapp.model.FacesModel;
|
|
|
import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
|
|
|
import com.sunwin.visitorapp.model.UserModel;
|
|
@@ -32,6 +34,7 @@ import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
|
|
import mcv.facepass.FacePassException;
|
|
|
import mcv.facepass.FacePassHandler;
|
|
|
+import mcv.facepass.types.FacePassAddFaceResult;
|
|
|
import mcv.facepass.types.FacePassCompareResult;
|
|
|
import mcv.facepass.types.FacePassConfig;
|
|
|
import mcv.facepass.types.FacePassDetectionResult;
|
|
@@ -40,6 +43,8 @@ import mcv.facepass.types.FacePassImageType;
|
|
|
import mcv.facepass.types.FacePassModel;
|
|
|
import mcv.facepass.types.FacePassPose;
|
|
|
import mcv.facepass.types.FacePassRCAttribute;
|
|
|
+import mcv.facepass.types.FacePassRecognitionResult;
|
|
|
+import mcv.facepass.types.FacePassRecognitionState;
|
|
|
import mcv.facepass.types.FacePassTrackOptions;
|
|
|
|
|
|
|
|
@@ -369,6 +374,7 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
DetectResult detectResult = new DetectResult();
|
|
|
detectResult.setCameraPreviewData(cameraPreviewData);
|
|
|
detectResult.setDetectResult(detectionResult.message);
|
|
|
+ detectResult.setTrackOpt(trackOpts);
|
|
|
mDetectResultQueue.offer(detectResult);
|
|
|
} else {
|
|
|
// Log.e(DEBUG_TAG, "null");
|
|
@@ -422,7 +428,6 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
isRecognized = true;
|
|
|
LogUtil.d(DEBUG_TAG, "take");
|
|
|
DetectResult detectResult = mDetectResultQueue.take();
|
|
|
- byte[] detectionResult = detectResult.getDetectResult();
|
|
|
|
|
|
if (isLocalGroupExist) {
|
|
|
|
|
@@ -430,7 +435,7 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
idCardRecognite(detectResult);
|
|
|
|
|
|
} else {
|
|
|
-// userRecognite(detectResult, detectionResult);
|
|
|
+ userRecognite(detectResult);
|
|
|
}
|
|
|
} else {
|
|
|
isLocalGroupExist = mFacePassHandler.createLocalGroup(group_name);
|
|
@@ -450,6 +455,57 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void userRecognite(DetectResult detectResult) {
|
|
|
+ try {
|
|
|
+ FacePassRecognitionResult[][] recognizeArray = mFacePassHandler.recognize(group_name, detectResult.getDetectResult(), 1, detectResult.getTrackOpt());
|
|
|
+ if (recognizeArray != null && recognizeArray.length > 0) {
|
|
|
+ for (FacePassRecognitionResult[] recognizeResult : recognizeArray) {
|
|
|
+ for (FacePassRecognitionResult result : recognizeResult) {
|
|
|
+ String faceToken = new String(result.faceToken);
|
|
|
+ LogUtil.e(TAG, "userRecognite():-------------------faceToken=" + faceToken);
|
|
|
+ if (FacePassRecognitionState.RECOGNITION_PASS == result.recognitionState ||
|
|
|
+ FacePassRecognitionState.RECOGNITION_RETRY_EXPIRED == result.recognitionState) {
|
|
|
+ //根据facetoken查询对应的用户
|
|
|
+ List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "faceToken", faceToken);
|
|
|
+ if (userInfoModels.size() > 0) {
|
|
|
+ UserInfoModel infoModel = userInfoModels.get(0);
|
|
|
+ OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo = new OpenDoorByFaceNetResultInfo();
|
|
|
+ openDoorByFaceNetResultInfo.setCode(0);
|
|
|
+ openDoorByFaceNetResultInfo.setSimilarity(result.detail.searchScore);
|
|
|
+ openDoorByFaceNetResultInfo.setPerson_code(infoModel.getPersonId());
|
|
|
+ openDoorByFaceNetResultInfo.setIdNum(infoModel.getIdNum());
|
|
|
+ openDoorByFaceNetResultInfo.setPerson_name(infoModel.getPersonName());
|
|
|
+ EventBus.getDefault().post(new DescEvent().setDesc(DescEvent.DESC_FR_SUCC).setOpenDoorByFaceNetResultInfo(openDoorByFaceNetResultInfo));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //未匹配到用户
|
|
|
+ recognizeNoUser();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ recognizeFail();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ recognizeFail();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (FacePassException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void recognizeNoUser() {
|
|
|
+ LogUtil.e(TAG, "---------recognizeNoUser---------");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void recognizeFail() {
|
|
|
+ LogUtil.e(TAG, "---------recognizeFail---------");
|
|
|
+ }
|
|
|
+
|
|
|
private void idCardRecognite(DetectResult detectResult) {
|
|
|
|
|
|
OpenDoorByFaceNetResultInfo openDoorByFaceNetResultInfo = new OpenDoorByFaceNetResultInfo();
|
|
@@ -490,7 +546,7 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
openDoorByFaceNetResultInfo.setCode(0);
|
|
|
openDoorByFaceNetResultInfo.setSimilarity(facePassCompareResult1.score);
|
|
|
openDoorByFaceNetResultInfo.setCurrentFace(currentFacePath);
|
|
|
- openDoorByFaceNetResultInfo.setPerson_code(idCardInfo.getId());
|
|
|
+ openDoorByFaceNetResultInfo.setIdNum(idCardInfo.getId());
|
|
|
openDoorByFaceNetResultInfo.setPerson_name(idCardInfo.getName());
|
|
|
ArrayList<FacesModel> arrayList = new ArrayList<>();
|
|
|
FacesModel facesModel = new FacesModel();
|
|
@@ -501,7 +557,7 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
recognizeTime = 0;
|
|
|
LogUtil.e("step", "6");
|
|
|
} else {
|
|
|
- LogUtil.e(TAG, "人证识别时间:"+recognizeTime);
|
|
|
+ LogUtil.e(TAG, "人证识别时间:" + recognizeTime);
|
|
|
recognizeTime++;
|
|
|
if (recognizeTime == Constant.COMPARSION_FREQUENCY) {
|
|
|
EventBus.getDefault().post(new DescEvent().setDesc(DescEvent.DESC_FR_NO_BODY));
|
|
@@ -513,4 +569,25 @@ public class SwFaceLoop extends FRAbsLoop {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public String addFace(String currentFacePath) {
|
|
|
+ if (mFacePassHandler == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ Bitmap bitmap = BitmapFactory.decodeFile(currentFacePath);
|
|
|
+ try {
|
|
|
+ FacePassAddFaceResult result = mFacePassHandler.addFace(bitmap);
|
|
|
+ if (result != null) {
|
|
|
+ if (result.result == 0) {
|
|
|
+ boolean b = mFacePassHandler.bindGroup(group_name, result.faceToken);
|
|
|
+ LogUtil.e(TAG, "bindGroup: " + currentFacePath + ":" + b);
|
|
|
+ return new String(result.faceToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|