Browse Source

百度Face修改后提交

Shangyp 5 months ago
parent
commit
ff20eb2a78

+ 2 - 2
app/build.gradle

@@ -14,8 +14,8 @@ android {
         applicationId "com.hanghui.senic"
         minSdkVersion 22
         targetSdkVersion 22
-        versionCode 116
-        versionName "1.1.6.241003" //2.2.21.240525
+        versionCode 118//115
+        versionName "1.1.8.241004" //1.1.5.241003
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         ndk {
             abiFilters "armeabi-v7a"   //armeabi-v7a 'arm64-v8a'

+ 1 - 1
app/src/main/java/com/hanghui/senic/baiduface/BaiduFaceMainActivity.java

@@ -559,7 +559,7 @@ public class BaiduFaceMainActivity extends BaseActivity {
             });
         }
         tv_version.setText("版本:v" + ConfigManager.getVersionName(this));
-        tv_sn.setText("SN-20:" + ConfigManager.getDeviceSN());
+        tv_sn.setText("SN-27:" + ConfigManager.getDeviceSN());
         appStatusTextView.setVisibility(View.VISIBLE);
 
     }

+ 1 - 1
app/src/main/java/com/hanghui/senic/baiduface/BaiduFacePreviewActivity.java

@@ -171,7 +171,7 @@ public class BaiduFacePreviewActivity extends BaiduFaceMainActivity {
         initBaiduFaceControllerCallback();
 
         initListener(); // 初始化模型
-        FaceSDKManager.getInstance().initDataBases(this); //初始化人脸数据库
+        FaceSDKManager.getInstance().initDataBases(MyAppliction.getContext()); //初始化人脸数据库
         FaceSDKManager.getInstance().setActiveLog(false);//百度人脸,关闭日志log, 否则sdk内部会极其高频的输出一大堆 "<line"  开头的log
 
         initViews();

+ 11 - 2
app/src/main/java/com/hanghui/senic/baiduface/BaiduFaceUtil.java

@@ -43,7 +43,7 @@ public class BaiduFaceUtil {
         //百度技术支持给的测试序列号,使用在线激活(离线激活需要繁杂的操作流程)
         //String licenseOnlineKey = "JH4U-PUXX-TXSP-SGRX";//224F010T01400261
         //String licenseOnlineKey = "XJGK-25XM-LMDF-DRAX"; //224F010T01400827
-        //String licenseOnlineKey = "AZS2-XAPD-EF9Q-XWGE"; //224F010T01400858
+//        String licenseOnlineKey = "AZS2-XAPD-EF9Q-XWGE"; //224F010T01400858
         //String licenseOnlineKey = "EGNN-JVEC-EDXC-BGVL";
 //        String licenseOnlineKey = "BJ3F-FHXX-DNPH-8XAT";//224F010T01400359
 //        String licenseOnlineKey = "XHVG-RXKX-XRXG-X6N5";//224F010T01400354
@@ -59,11 +59,20 @@ public class BaiduFaceUtil {
 //        String licenseOnlineKey = "Z6WZ-MXJU-WXNF-MQEU";//224F010T01400575
 //        String licenseOnlineKey = "VBJG-QUPX-6GXJ-ZTGX";//224F010T01400684
 //        String licenseOnlineKey = "GKXV-GYMD-UJC6-RWML";//224F010T01400887
+//        String licenseOnlineKey = "CLPV-TXHK-XYLL-XFZK";//224F010T01400886
 //        String licenseOnlineKey = "YKSC-XNQP-ZCJ9-5AJF";//224F010T01400682
 //        String licenseOnlineKey = "EZFV-PQPV-MFED-TXDX";//224F010T01400896
 //        String licenseOnlineKey = "WECM-8UPP-DGLB-XEXZ";//224F010T01400707
 //        String licenseOnlineKey = "QUXW-ZTGX-KFLP-DSUX";//224F010T01400895
-        String licenseOnlineKey = "AX8K-XYEB-GUPU-WLYK";//224F010T01400882
+//        String licenseOnlineKey = "AX8K-XYEB-GUPU-WLYK";//224F010T01400882
+//        String licenseOnlineKey = "ZFEC-CFQM-PSMA-UJ4Z";//224F010T01400357
+//        String licenseOnlineKey = "JKAU-EXDQ-CXMP-XTW5";//224F010T01400572
+//        String licenseOnlineKey = "FXGL-F7HH-NJLP-KSLS";//224F010T01400360
+//        String licenseOnlineKey = "WZWV-76NC-S7GC-PXRP";//224F010T01400576
+//        String licenseOnlineKey = "TZDE-YKLZ-X5R6-MPAZ";//224F010T01400355
+//        String licenseOnlineKey = "DHMU-XVJB-7ZDY-KHZX";//224F010T01400353
+        String licenseOnlineKey = "8SCN-DRNU-KJYD-XD25";//224F010T01400573
+//        String licenseOnlineKey = "BKJT-X3QX-BXHD-JQFS";//ZP2415000037
         PreferencesUtil.putString("activate_online_key", licenseOnlineKey);
 
 

+ 8 - 5
app/src/main/java/com/hanghui/senic/baiduface/WebsocketService.java

@@ -14,6 +14,7 @@ import android.util.Base64;
 import androidx.annotation.Nullable;
 
 import com.example.datalibrary.api.FaceApi;
+import com.example.datalibrary.db.DBManager;
 import com.example.datalibrary.manager.FaceSDKManager;
 import com.example.datalibrary.model.User;
 import com.hanghui.senic.MyAppliction;
@@ -87,7 +88,6 @@ public class WebsocketService extends Service {
     private HashMap<Integer, String> mUserHashMap = new HashMap<>();
     private int errorUserDataCount;//错误的用户数据
 
-
     @Override
     public void onCreate() {
         super.onCreate();
@@ -263,14 +263,13 @@ public class WebsocketService extends Service {
                 AppLogUtils.i(true, TAG + " ,WebSocket, onMessage()", "WebSocket, onMessage(), WebSocket接收到文本消息, op=" + userFaceData.getOp() );
             }
 
-
             //接收到下发的消息,依次放进队列按照顺序执行
             mFaceDataHandlerThreadHandler.post(new Runnable() {
                 @Override
                 public void run() {
+                    FaceSDKManager.getInstance().initDataBases2(MyAppliction.getContext()); //初始化人脸数据库
                     //开始处理数据
                     receiveUserFaceData(userFaceData);
-
                 }
             });
 
@@ -563,6 +562,8 @@ public class WebsocketService extends Service {
 
                     code = CODE_success;
                     msg = "下发成功";
+                    User user = DBManager.getInstance().queryUser(userId);
+                    FaceSDKManager.getInstance().initPush2(user);
                 } else {
                     AppLogUtils.e(true, TAG + " ,processUserData_issue", "processUserData_issue(), 人脸注册失败 userId=" + userId + " ,userName=" + userName);
 
@@ -602,7 +603,7 @@ public class WebsocketService extends Service {
 
         }
 
-        initFaceSearchData();
+//        initFaceSearchData();
 
     }
 
@@ -900,6 +901,7 @@ public class WebsocketService extends Service {
      */
     private void sendMessage_userinfoReport() {
         AppLogUtils.i(true, TAG + " ,sendMessage_userinfoReport", "sendMessage_userinfoReport()");
+        FaceSDKManager.getInstance().initDataBases2(MyAppliction.getContext());
 
         //数据库1万8千条数据时,DBManager.getInstance().queryAllUsers()查询数据库需要6秒左右
         List<User> users = FaceApi.getInstance().getAllUserList();
@@ -931,7 +933,8 @@ public class WebsocketService extends Service {
         userFaceDataReportRequest.setData(data);
 
         String userFaceDataReportRequestJsonStr = GsonUtil.toJson(userFaceDataReportRequest);
-        AppLogUtils.i(true, TAG + " ,sendMessage_userinfoReport", "sendMessage_userinfoReport(), userIds.size()=" + userIds.size() +  " ,userFaceDataReportRequestJsonStr=" + userFaceDataReportRequestJsonStr);
+//        AppLogUtils.i(true, TAG + " ,sendMessage_userinfoReport", "sendMessage_userinfoReport(), userIds.size()=" + userIds.size() +  " ,userFaceDataReportRequestJsonStr=" + userFaceDataReportRequestJsonStr);
+        AppLogUtils.i(true, TAG + " ,sendMessage_userinfoReport", "sendMessage_userinfoReport(), userIds.size()=" + userIds.size());
         sendMessage(userFaceDataReportRequestJsonStr);
 
     }

+ 16 - 4
datalibrary/src/main/java/com/example/datalibrary/manager/FaceSDKManager.java

@@ -146,16 +146,24 @@ public class FaceSDKManager {
     }
 
     public void initDataBases(Context context) {
-        if (FaceApi.getInstance().getmUserNum() != 0) {
-            //ToastUtils.toast(context, "人脸库加载中");
-            Log.i(TAG, "人脸库加载中");
-        }
+//        if (FaceApi.getInstance().getmUserNum() != 0) {
+//            //ToastUtils.toast(context, "人脸库加载中");
+//            Log.i(TAG, "人脸库加载中");
+//        }
         emptyFrame();
         // 初始化数据库
         DBManager.getInstance().init(context);
         // 数据变化,更新内存
         initPush(context);
     }
+    public void initDataBases2(Context context) {
+//        if (FaceApi.getInstance().getmUserNum() != 0) {
+//            //ToastUtils.toast(context, "人脸库加载中");
+//            Log.i(TAG, "人脸库加载中");
+//        }
+        // 初始化数据库
+        DBManager.getInstance().init(context);
+    }
 
     /**
      * 数据库发现变化时候,重新把数据库中的人脸信息添加到内存中,id+feature
@@ -188,6 +196,10 @@ public class FaceSDKManager {
         });
     }
 
+    public void initPush2(User user){
+        faceModel.getFaceSearch().pushPersonById(user.getId(), user.getFeature());
+    }
+
     private void setFail(LivenessModel livenessModel) {
         Log.e("faceId", livenessModel.getFaceInfo().faceID + "");
         if (failNumber >= 2) {

+ 44 - 22
gatelibrary/src/main/java/com/baidu/idl/main/facesdk/model/BaseConfig.java

@@ -23,45 +23,62 @@ public class BaseConfig {
     // 默认为max。分为"max" 、"none"三个方式,分别是最大人脸 ,和不检测人脸
     private String trackType = "max";
     // 需要检测的最小人脸大小,默认为80px。可传入大于50px的数值,小于此大小的人脸不予检测
-    private int minimumFace = 60;
+//    private int minimumFace = 60;
+    private int minimumFace = 70;
     // 人脸置信度,用于表征被检测到的物体是人脸的概率,该阈值设置越高检测越严格,建议在0.3-0.8区间内调整阈值
-    private float faceThreshold = 0.5f;
+//    private float faceThreshold = 0.5f;
+    private float faceThreshold = 0.3f;
     // 模糊度设置,默认0.5。取值范围[0~1],0是最清晰,1是最模糊
-    private float blur = 0.8f;
+//    private float blur = 0.8f;
+    private float blur = 0.5f;
     // 光照设置,默认0.8.取值范围[0~1], 数值越大,光线越强
-    private float illum = 0.8f;
+//    private float illum = 0.8f;
+    private float illum = 0.5f;
     // 姿态阈值
     private float gesture = 15;
     // 三维旋转之俯仰角度[-90(上), 90(下)],默认20
-    private float pitch = 20;
+//    private float pitch = 20;
+    private float pitch = 30;
     // 平面内旋转角[-180(逆时针), 180(顺时针)],默认20
     private float roll = 20;
     // 三维旋转之左右旋转角[-90(左), 90(右)],默认20
     private float yaw = 20;
     // 遮挡阈值
-    private float occlusion = 0.8f;
+//    private float occlusion = 0.8f;
+    private float occlusion = 0.5f;
     // 左眼被遮挡的阈值,默认0.6
-    private float leftEye = 0.8f;
+//    private float leftEye = 0.8f;
+    private float leftEye = 0.5f;
     // 右眼被遮挡的阈值,默认0.6
-    private float rightEye = 0.8f;
+//    private float rightEye = 0.8f;
+    private float rightEye = 0.5f;
     // 鼻子被遮挡的阈值,默认0.7
-    private float nose = 0.8f;
+//    private float nose = 0.8f;
+    private float nose = 0.5f;
     // 嘴巴被遮挡的阈值,默认0.7
-    private float mouth = 0.8f;
+//    private float mouth = 0.8f;
+    private float mouth = 0.5f;
     // 左脸颊被遮挡的阈值,默认0.8
-    private float leftCheek = 0.8f;
+//    private float leftCheek = 0.8f;
+    private float leftCheek = 0.5f;
     // 右脸颊被遮挡的阈值,默认0.8
-    private float rightCheek = 0.8f;
+//    private float rightCheek = 0.8f;
+    private float rightCheek = 0.5f;
     // 下巴被遮挡阈值,默认为0.6
-    private float chinContour = 0.8f;
+//    private float chinContour = 0.8f;
+    private float chinContour = 0.5f;
     // 人脸完整度,默认为1。0为人脸溢出图像边界,1为人脸都在图像边界内
-    private float completeness = 1f;
+//    private float completeness = 1f;
+    private float completeness = 0.7f;
     // 识别阈值,0-100,默认为80分,需要选择具体模型的阈值。live:80、idcard:80
-    private float liveScoreThreshold = 0.8f;
+//    private float liveScoreThreshold = 0.8f;
+    private float liveScoreThreshold = 0.5f;
     // 识别阈值,0-100,默认为80分,需要选择具体模型的阈值。live:80、idcard:80
-    private float idScoreThreshold = 0.8f;
+//    private float idScoreThreshold = 0.8f;
+    private float idScoreThreshold = 0.77f;
     // 识别阈值,0-100,默认为80分,需要选择具体模型的阈值。live:80、idcard:80
-    private float rgbAndNirScoreThreshold = 0.8f;
+//    private float rgbAndNirScoreThreshold = 0.8f;
+    private float rgbAndNirScoreThreshold = 0.5f;
     // 模态切换光线阈值
     private int cameraLightThreshold = 50;
     // 使用的特征抽取模型默认为生活照:1;证件照:2;RGB+NIR混合模态模型:3;
@@ -78,17 +95,22 @@ public class BaseConfig {
     //private boolean qualityControl = true;
     private boolean qualityControl = false;//关闭质量检测,否则人证核验时会报提示:人脸上下偏转角超出限制
     // 是否开启活体检测开关
-    private boolean livingControl = true;
+//    private boolean livingControl = true;
+    private boolean livingControl = false;
     // RGB活体阀值
-    private float rgbLiveScore = 0.80f;
+//    private float rgbLiveScore = 0.80f;
+    private float rgbLiveScore = 0.50f;
     // NIR活体阀值
-    private float nirLiveScore = 0.80f;
+//    private float nirLiveScore = 0.80f;
+    private float nirLiveScore = 0.50f;
     // Depth活体阀值
-    private float depthLiveScore = 0.80f;
+//    private float depthLiveScore = 0.80f;
+    private float depthLiveScore = 0.50f;
     // 是否开启暗光恢复
     private boolean darkEnhance = false;
     // 是否开启best image
-    private boolean bestImage = true;
+//    private boolean bestImage = true;
+    private boolean bestImage = false;
     // 是否开启Log日志
     private boolean log = true;
     // 摄像头显示位置