| | |
| | | import com.doumee.lib_coremodel.util.SpUtil; |
| | | import com.doumee.lib_coremodel.util.StringUtil; |
| | | import com.doumee.lib_coremodel.view.ToastView; |
| | | import com.example.datalibrary.api.FaceApi; |
| | | import com.example.datalibrary.callback.CameraDataCallback; |
| | | import com.example.datalibrary.callback.FaceDetectCallBack; |
| | | import com.example.datalibrary.db.DBManager; |
| | |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import dagger.hilt.android.AndroidEntryPoint; |
| | | |
| | |
| | | //System.out.println("==rgbInstance==>onFaceDetectCallback "+livenessModel); |
| | | // 开发模式 |
| | | //isCheckFace = false; |
| | | if(handler.hasMessages(1)){ |
| | | handler.removeMessages(1); |
| | | try { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(handler==null){ |
| | | return; |
| | | } |
| | | if(handler.hasMessages(1)){ |
| | | handler.removeMessages(1); |
| | | } |
| | | checkOpenDebugResult(livenessModel); |
| | | } |
| | | }); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错2:"+e.getMessage()); |
| | | } |
| | | checkOpenDebugResult(livenessModel); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(msg); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | System.out.println("==isOk==>onTip:"+msg); |
| | | //System.out.println("==isOk==>onTip:"+msg); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (livenessModel == null){ |
| | | return; |
| | | } |
| | | |
| | | if (isPause){ |
| | | glMantleSurfacView.onGlDraw(livenessModel.getTrackFaceInfo() , |
| | | livenessModel.getBdFaceImageInstance() , |
| | | FaceOnDrawTexturViewUtil.drawFaceColor(mUser , livenessModel)); |
| | | try { |
| | | if (isPause){ |
| | | glMantleSurfacView.onGlDraw(livenessModel.getTrackFaceInfo() , |
| | | livenessModel.getBdFaceImageInstance() , |
| | | FaceOnDrawTexturViewUtil.drawFaceColor(mUser , livenessModel)); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错1:"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | case 6: |
| | | getDB().message.setVisibility(View.GONE); |
| | | break; |
| | | case 7: |
| | | identify(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | private int resultCount = 0; |
| | | // ***************开发模式结果输出************* |
| | | private void checkOpenDebugResult(final LivenessModel livenessModel) { |
| | | if(isFinishing()){ |
| | | return; |
| | | } |
| | | if(handler==null){ |
| | | return; |
| | | } |
| | | // 当未检测到人脸UI显示 |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(isToChose) { |
| | | return; |
| | | } |
| | | if (livenessModel == null) { |
| | | if (isCompareCheck) { |
| | | try { |
| | | if (isFinishing()) { |
| | | return; |
| | | } |
| | | if (handler == null) { |
| | | return; |
| | | } |
| | | // 当未检测到人脸UI显示 |
| | | if (isToChose) { |
| | | return; |
| | | } |
| | | if (livenessModel == null) { |
| | | if (isCompareCheck) { |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(getString(R.string.face_tip2)); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | } |
| | | System.out.println("======>人脸识别失败"); |
| | | return; |
| | | } |
| | | if (livenessModel.isQualityCheck()){ |
| | | //是否通过质量检测 |
| | | if (isCompareCheck) { |
| | | //System.out.println("======>人脸识别失败"); |
| | | return; |
| | | } |
| | | if (livenessModel.isQualityCheck()) { |
| | | //是否通过质量检测 |
| | | if (isCompareCheck) { |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(getString(R.string.face_tip2)); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | } |
| | | } else { |
| | | User user = livenessModel.getUser(); |
| | | if (user == null) { |
| | | mUser = null; |
| | | //EventBus.getDefault().post(new HttpEvent("人脸用户检测失败------->"+(status==0?"管理员人脸检测:":"司机人脸检测:"))); |
| | | if (isCompareCheck) { |
| | | } |
| | | } else { |
| | | User user = livenessModel.getUser(); |
| | | if (user == null) { |
| | | mUser = null; |
| | | //EventBus.getDefault().post(new HttpEvent("人脸用户检测失败------->"+(status==0?"管理员人脸检测:":"司机人脸检测:"))); |
| | | if (isCompareCheck) { |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(getString(R.string.face_tip2)); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | mUser = user; |
| | | } else { |
| | | mUser = user; |
| | | /*EventBus.getDefault().post(new HttpEvent("人脸用户------->"+(status==0?"管理员人脸检测:":"司机人脸检测:") |
| | | +(user.getGroupId().equals("0")?"管理员":"司机")));*/ |
| | | if (isCompareCheck) { |
| | | getDB().clFail.setVisibility(View.GONE); |
| | | if(handler.hasMessages(0)) { |
| | | handler.removeMessages(0); |
| | | } |
| | | if (isCompareCheck) { |
| | | getDB().clFail.setVisibility(View.GONE); |
| | | if (handler.hasMessages(0)) { |
| | | handler.removeMessages(0); |
| | | } |
| | | /*textHuanying.setVisibility(View.GONE); |
| | | userNameLayout.setVisibility(View.VISIBLE); |
| | | nameImage.setImageResource(R.mipmap.ic_tips_gate_success); |
| | | nameText.setTextColor(Color.parseColor("#0dc6ff")); |
| | | nameText.setText(FileUtils.spotString(user.getUserName()) + " 欢迎您");*/ |
| | | } |
| | | isToChose = true; |
| | | //识别成功,跳转 |
| | | if(status==0){ |
| | | //取-管理员 |
| | | MApplication.getLoginBean().setAutoMemberId(Integer.parseInt(user.getUserId())); |
| | | //handler.sendEmptyMessageDelayed(7,0); |
| | | EventBus.getDefault().post(new FaceStatusChangeEvent(5)); |
| | | }else if(status==2){ |
| | | //取-司机 |
| | | CameraPreviewManager.getInstance().stopPreview(); |
| | | MApplication.getLoginBean().setMemberId(Integer.parseInt(user.getUserId())); |
| | | MApplication.getLoginBean().setAuthType(0); |
| | | //handler.sendEmptyMessageDelayed(8,0); |
| | | //Toast.makeText(mContext, "是否酒精检测:"+MApplication.getConfigBean().getAlcoholStatus(), Toast.LENGTH_SHORT).show(); |
| | | if(MApplication.getConfigBean()!=null&&MApplication.getConfigBean().getAlcoholStatus()==1) { |
| | | //非酒精检测 |
| | | startActivity(KeyCabinetActivity.class); |
| | | finish(); |
| | | }else { |
| | | //酒精检测 |
| | | EventBus.getDefault().post(new FaceStatusChangeEvent(4)); |
| | | } |
| | | }else if(status==7){ |
| | | //还-司机 |
| | | MApplication.getLoginBean().setMemberId(Integer.parseInt(user.getUserId())); |
| | | MApplication.getLoginBean().setAuthType(0); |
| | | } |
| | | isToChose = true; |
| | | //识别成功,跳转 |
| | | if (status == 0) { |
| | | //取-管理员 |
| | | MApplication.getLoginBean().setAutoMemberId(Integer.parseInt(user.getUserId())); |
| | | //handler.sendEmptyMessageDelayed(7,0); |
| | | EventBus.getDefault().post(new FaceStatusChangeEvent(5)); |
| | | } else if (status == 2) { |
| | | //取-司机 |
| | | CameraPreviewManager.getInstance().stopPreview(); |
| | | MApplication.getLoginBean().setMemberId(Integer.parseInt(user.getUserId())); |
| | | MApplication.getLoginBean().setAuthType(0); |
| | | //handler.sendEmptyMessageDelayed(8,0); |
| | | //Toast.makeText(mContext, "是否酒精检测:"+MApplication.getConfigBean().getAlcoholStatus(), Toast.LENGTH_SHORT).show(); |
| | | if (MApplication.getConfigBean() != null && MApplication.getConfigBean().getAlcoholStatus() == 1) { |
| | | //非酒精检测 |
| | | startActivity(KeyCabinetActivity.class); |
| | | finish(); |
| | | } else { |
| | | //酒精检测 |
| | | EventBus.getDefault().post(new FaceStatusChangeEvent(4)); |
| | | } |
| | | } else if (status == 7) { |
| | | //还-司机 |
| | | MApplication.getLoginBean().setMemberId(Integer.parseInt(user.getUserId())); |
| | | MApplication.getLoginBean().setAuthType(0); |
| | | startActivity(KeyCabinetActivity.class); |
| | | finish(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错:"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | |
| | | public void run() { |
| | | FingerPrintDo printDo = DaoManager.getFingerPrintDao().getByFingerId(fingerId); |
| | | if(printDo!=null){ |
| | | List<User> users = FaceApi.getInstance().getAllUserList(); |
| | | HashMap<String,String> map = new HashMap<>(); |
| | | for(User u:users){ |
| | | if(u.getUserId().equals(printDo.getMemberId()+"")){ |
| | | map.put(u.getGroupId(),""); |
| | | } |
| | | } |
| | | if(status==10){ |
| | | //取-管理员指纹验证 |
| | | if(!map.containsKey("0")){ |
| | | showToast("您当前不是管理员"); |
| | | handler.sendEmptyMessageDelayed(7,2000); |
| | | return; |
| | | } |
| | | MApplication.getLoginBean().setAutoMemberId(printDo.getMemberId()); |
| | | EventBus.getDefault().post(new FaceStatusChangeEvent(5)); |
| | | }else if(status==11){ |
| | | //取-司机指纹验证 |
| | | if(!map.containsKey("1")){ |
| | | showToast("您当前不是司机"); |
| | | handler.sendEmptyMessageDelayed(7,2000); |
| | | return; |
| | | } |
| | | MApplication.getLoginBean().setMemberId(printDo.getMemberId()); |
| | | MApplication.getLoginBean().setAuthType(2); |
| | | MApplication.getLoginBean().setAuthType(3); |
| | | if(MApplication.getConfigBean()!=null&&MApplication.getConfigBean().getAlcoholStatus()==1) { |
| | | //非酒精检测 |
| | | startActivity(KeyCabinetActivity.class); |
| | |
| | | } |
| | | }else if(status==12){ |
| | | //还-司机 |
| | | if(!map.containsKey("1")){ |
| | | showToast("您当前不是司机"); |
| | | handler.sendEmptyMessageDelayed(7,2000); |
| | | return; |
| | | } |
| | | MApplication.getLoginBean().setMemberId(printDo.getMemberId()); |
| | | MApplication.getLoginBean().setAuthType(2); |
| | | MApplication.getLoginBean().setAuthType(3); |
| | | startActivity(KeyCabinetActivity.class); |
| | | finish(); |
| | | } |
| | |
| | | //找不到,删除指纹 |
| | | if(deleteID(fingerId)) { |
| | | //继续查指纹 |
| | | identify(); |
| | | handler.sendEmptyMessageDelayed(7,2000); |
| | | }else { |
| | | showToast("未查询到用户"); |
| | | } |
| | |
| | | private void identify() { |
| | | if (!mDevComm.IsInit()) |
| | | return; |
| | | |
| | | mBCancel = false; |
| | | new Thread(new Runnable() { |
| | | int w_nRet; |
| | |
| | | //m_strPost = String.format("Result : Success\r\nTemplate No : %d, Learn Result : %d\r\nMatch Time : %dms", w_nID[0], w_nLearned[0], m_nPassedTime); |
| | | } else { |
| | | //没找到 |
| | | //showToast("没找到"); |
| | | showToast("未检测到该指纹"); |
| | | /*m_strPost = String.format("\r\nMatch Time : %dms", m_nPassedTime); |
| | | m_strPost = GetErrorMsg(w_nRet) + m_strPost;*/ |
| | | } |
| | |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show(); |
| | | ToastView.show(MApplication.mContext,msg); |
| | | } |
| | | }); |
| | | } |