public static bool check() { if (!FileUitls.checklicense(Context, LICENSE_NAME)) { showActivation(); return(false); } else { return(true); } }
private void offLineActive(String path) { if (FaceSDK.AuthorityStatus == AndroidLicenser.ErrorCode.Success.Ordinal()) { Toast.MakeText(this, "已经激活成功", ToastLength.Long).Show(); return; } String firstPath = path + "/" + "License.zip"; if (fileIsExists(firstPath)) { if (!TextUtils.IsEmpty(firstPath)) { ZipUtil.unzip(firstPath); } if (ZipUtil.isSuccess) { String secondPath = path + "/" + "Win.zip"; if (!TextUtils.IsEmpty(secondPath)) { ZipUtil.unzip(secondPath); } } String keyPath = path + "/" + "license.key"; String key = readFile(keyPath, "key"); PreferencesUtil.putString("activate_key", key); String liscensePaht = path + "/" + "license.ini"; String liscense = readFile(liscensePaht, "liscense"); success = FileUitls.c(this, FaceSDKManager.LICENSE_NAME, list); if (success) { toast("激活成功"); FaceSDKManager.initStatus = FaceSDKManager.SDK_UNINIT; FaceSDKManager.init(this); } else { toast("激活失败"); } } else { toast("授权文件不存在!"); } }
private void saveFace(FaceInfo faceInfo, ImageFrame imageFrame) { Bitmap bitmap = FaceCropper.getFace(imageFrame.getArgb(), faceInfo, imageFrame.getWidth()); if (source == RegActivity.SOURCE_REG) { // 注册来源保存到注册人脸目录 File faceDir = FileUitls.getFaceDirectory(); if (faceDir != null) { String imageName = Guid.NewGuid().ToString(); File file = new File(faceDir, imageName); // 压缩人脸图片至300 * 300,减少网络传输时间 ImageUtils.resize(bitmap, file, 300, 300); Intent intent = new Intent(); intent.PutExtra("file_path", file.AbsolutePath); SetResult(Result.Ok, intent); Finish(); } else { toast("注册人脸目录未找到"); } } else { try { // 其他来源保存到临时目录 File file = File.CreateTempFile(Guid.NewGuid().ToString() + "", ".jpg"); // 人脸识别不需要整张图片。可以对人脸区别进行裁剪。减少流量消耗和,网络传输占用的时间消耗。 ImageUtils.resize(bitmap, file, 300, 300); Intent intent = new Intent(); intent.PutExtra("file_path", file.AbsolutePath); SetResult(Result.Ok, intent); Finish(); } catch (IOException e) { e.PrintStackTrace(); } } }
private static void parse(JSONObject json, string key) { bool success = false; JSONObject result = json.OptJSONObject("result"); if (result != null) { string license = result.OptString("license"); if (!TextUtils.IsEmpty(license)) { string[] licenses = license.Split(','); if (licenses != null && licenses.Length == 2) { PreferencesUtil.putString("activate_key", key); Java.Util.ArrayList list = new Java.Util.ArrayList(); list.Add(licenses[0]); list.Add(licenses[1]); success = FileUitls.c(Contexts, FaceSDKManager.LICENSE_NAME, list); } } } if (success) { toast("激活成功"); if (activationCallback != null) { activationCallback.callback(true); activationDialog.Dismiss(); } } else { toast("激活失败"); } }
public void run() { if (score < 80) { scoreTv.setText(""); matchUserTv.setText(""); matchAvatorIv.setImageBitmap(null); return; } if (userIdOfMaxScore.equals(userId)) { if (score < maxScore) { scoreTv.setText("" + score); } else { maxScore = score; userOfMaxSocre.setText("userId:" + userId + "\nscore:" + score); scoreTv.setText(String.valueOf(maxScore)); } if (matchUserTv.getText().toString().length() > 0) { return; } } else { userIdOfMaxScore = userId; maxScore = score; } scoreTv.setText(String.valueOf(maxScore)); User user = FaceApi.getInstance().getUserInfo(groupId, userId); if (user == null) { return; } matchUserTv.setText(user.getUserInfo()); List <Feature> featureList = user.getFeatureList(); if (featureList != null && featureList.size() > 0) { // featureTv.setText(new String(featureList.get(0).getFeature())); File faceDir = FileUitls.getFaceDirectory(); if (faceDir != null && faceDir.exists()) { File file = new File(faceDir, featureList.get(0).getImageName()); if (file != null && file.exists()) { Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); matchAvatorIv.setImageBitmap(bitmap); } } } // List<Feature> featureList = DBManager.getInstance().queryFeatureByUeserId(userId); // if (featureList != null && featureList.size() > 0) { // File faceDir = FileUitls.getFaceDirectory(); // if (faceDir != null && faceDir.exists()) { // File file = new File(faceDir, featureList.get(0).getImageName()); // if (file != null && file.exists()) { // Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); // testView.setImageBitmap(bitmap); // } // } // } }
private void checkResult(LivenessModel model) { if (model == null) { return; } displayResult(model); int type = model.getLiveType(); bool livenessSuccess = false; // 同一时刻都通过才认为活体通过,开发者也可以根据自己的需求修改策略 if ((type & FaceLiveness.MASK_RGB) == FaceLiveness.MASK_RGB) { livenessSuccess = (model.getRgbLivenessScore() > FaceEnvironment.LIVENESS_RGB_THRESHOLD) ? true : false; } if ((type & FaceLiveness.MASK_IR) == FaceLiveness.MASK_IR) { bool irScore = (model.getIrLivenessScore() > FaceEnvironment.LIVENESS_IR_THRESHOLD) ? true : false; if (!irScore) { livenessSuccess = false; } else { livenessSuccess &= irScore; } } if ((type & FaceLiveness.MASK_DEPTH) == FaceLiveness.MASK_DEPTH) { bool depthScore = (model.getDepthLivenessScore() > FaceEnvironment.LIVENESS_DEPTH_THRESHOLD) ? true : false; if (!depthScore) { livenessSuccess = false; } else { livenessSuccess &= depthScore; } } if (livenessSuccess) { Bitmap bitmap = FaceCropper.getFace(model.getImageFrame().getArgb(), model.getFaceInfo(), model.getImageFrame().getWidth()); if (source == RegActivity.SOURCE_REG) { // 注册来源保存到注册人脸目录 File faceDir = FileUitls.getFaceDirectory(); if (faceDir != null) { string imageName = System.Guid.NewGuid().ToString(); File file = new File(faceDir, imageName); // 压缩人脸图片至300 * 300,减少网络传输时间 ImageUtils.resize(bitmap, file, 300, 300); Intent intent = new Intent(); intent.PutExtra("file_path", file.AbsolutePath); SetResult(Result.Ok, intent); success = true; Finish(); } else { toast("注册人脸目录未找到"); } } else { try { // 其他来源保存到临时目录 File file = File.CreateTempFile(System.Guid.NewGuid().ToString() + "", ".jpg"); ImageUtils.resize(bitmap, file, 300, 300); Intent intent = new Intent(); intent.PutExtra("file_path", file.AbsolutePath); SetResult(Result.Ok, intent); success = true; Finish(); } catch (IOException e) { e.PrintStackTrace(); } } } }