|
@@ -40,6 +40,21 @@ public class FaceVerifyServiceImpl implements FaceVerifyService {
|
|
|
return BaiduApiHelper.faceVerify(properties, params);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FaceResult faceVerifyByBaidu(ImageParm image, boolean localEnabled) {
|
|
|
+ Map<String, String> imageData = this.buildImageParmForBaidu(image);
|
|
|
+ imageData.put("face_field", "spoofing");
|
|
|
+
|
|
|
+ List<Map<String, String>> images = new ArrayList<>();
|
|
|
+ images.add(imageData);
|
|
|
+
|
|
|
+ String params = new JsonHelper().toJson(images);
|
|
|
+ if (localEnabled) {
|
|
|
+ return BaiduApiHelper.faceVerifyUseLocalApi(properties, params);
|
|
|
+ }
|
|
|
+ return BaiduApiHelper.faceVerify(properties, params);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public FaceResult faceDetectByBaidu(ImageParm image) {
|
|
|
Map<String, String> imageData = this.buildImageParmForBaidu(image);
|
|
@@ -53,11 +68,29 @@ public class FaceVerifyServiceImpl implements FaceVerifyService {
|
|
|
return BaiduApiHelper.faceDetect(properties, params);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FaceResult faceDetectByBaidu(ImageParm image, boolean localEnabled) {
|
|
|
+ Map<String, String> imageData = this.buildImageParmForBaidu(image);
|
|
|
+ imageData.put("liveness_control", "NORMAL");
|
|
|
+ imageData.put("max_face_num", "2");
|
|
|
+
|
|
|
+ String params = new JsonHelper().toJson(imageData);
|
|
|
+ if (localEnabled) {
|
|
|
+ return BaiduApiHelper.faceDetectUseLocalApi(properties, params);
|
|
|
+ }
|
|
|
+ return BaiduApiHelper.faceDetect(properties, params);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public FaceResult faceCompareByBaidu(ImageParm image1, ImageParm image2) {
|
|
|
return this.faceCompareByBaidu(image1, image2, properties.getBaiduExpectFaceCompareScore());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FaceResult faceCompareByBaidu(ImageParm image1, ImageParm image2, boolean localEnabled) {
|
|
|
+ return this.faceCompareByBaidu(image1, image2, properties.getBaiduExpectFaceCompareScore(), localEnabled);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public FaceResult faceCompareByBaidu(ImageParm image1, ImageParm image2, Double expectFaceCompareScore) {
|
|
|
List<Map<String, String>> images = new ArrayList<>();
|
|
@@ -75,6 +108,24 @@ public class FaceVerifyServiceImpl implements FaceVerifyService {
|
|
|
return BaiduApiHelper.faceCompare(properties, params, expectFaceCompareScore);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FaceResult faceCompareByBaidu(ImageParm image1, ImageParm image2, Double expectFaceCompareScore,
|
|
|
+ boolean localEnabled) {
|
|
|
+ List<Map<String, String>> images = new ArrayList<>();
|
|
|
+ images.add(this.buildImageParmForBaidu(image1));
|
|
|
+ images.add(this.buildImageParmForBaidu(image2));
|
|
|
+
|
|
|
+ if (expectFaceCompareScore == null) {
|
|
|
+ expectFaceCompareScore = properties.getBaiduExpectFaceCompareScore();
|
|
|
+ }
|
|
|
+
|
|
|
+ String params = new JsonHelper().toJson(images);
|
|
|
+ if (localEnabled) {
|
|
|
+ return BaiduApiHelper.faceCompareUseLocalApi(properties, params, expectFaceCompareScore);
|
|
|
+ }
|
|
|
+ return BaiduApiHelper.faceCompare(properties, params, expectFaceCompareScore);
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, String> buildImageParmForBaidu(ImageParm image) {
|
|
|
if (image == null || StringUtils.isBlank(image.value())) {
|
|
|
throw new IllegalArgumentException("ImageParm must be not empty.");
|