|
@@ -133,6 +133,8 @@ public class BaiduApiHelper {
|
|
FaceResult result = new FaceResult();
|
|
FaceResult result = new FaceResult();
|
|
result.setPass(false);
|
|
result.setPass(false);
|
|
result.setApiLimit(false);
|
|
result.setApiLimit(false);
|
|
|
|
+ result.setScore(0d);
|
|
|
|
+ result.setFaceNum(0);
|
|
|
|
|
|
if (response.getError_code() != 0) {
|
|
if (response.getError_code() != 0) {
|
|
result.setError(response.getError_code() + " - " + response.getError_msg());
|
|
result.setError(response.getError_code() + " - " + response.getError_msg());
|
|
@@ -146,15 +148,27 @@ public class BaiduApiHelper {
|
|
|
|
|
|
BaiduResult data = response.getResult();
|
|
BaiduResult data = response.getResult();
|
|
if (data != null) {
|
|
if (data != null) {
|
|
- double faceLiveness = data.getFace_liveness() != null ? data.getFace_liveness() : 0d;
|
|
|
|
|
|
+ if (data.getThresholds() != null) {
|
|
|
|
+ result.setThresholds(new JsonHelper().toJson(data.getThresholds()));
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ double faceLiveness = 0d;
|
|
|
|
+ List<BaiduFace> faces = data.getFace_list();
|
|
|
|
+ if (data.getFace_liveness() != null) {
|
|
|
|
+ faceLiveness = data.getFace_liveness();
|
|
|
|
+ } else {
|
|
|
|
+ if (faces != null && !faces.isEmpty()) {
|
|
|
|
+ BaiduFace face = faces.get(0);
|
|
|
|
+ if (face.getLiveness() != null && face.getLiveness().getLivemapscore() != null) {
|
|
|
|
+ faceLiveness = face.getLiveness().getLivemapscore();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
result.setScore(faceLiveness);
|
|
result.setScore(faceLiveness);
|
|
- result.setThresholds(new JsonHelper().toJson(data.getThresholds()));
|
|
|
|
|
|
|
|
if (data.getFace_num() != null) {
|
|
if (data.getFace_num() != null) {
|
|
result.setFaceNum(data.getFace_num());
|
|
result.setFaceNum(data.getFace_num());
|
|
} else {
|
|
} else {
|
|
- List<BaiduFace> faces = data.getFace_list();
|
|
|
|
result.setFaceNum(faces != null ? faces.size() : 0);
|
|
result.setFaceNum(faces != null ? faces.size() : 0);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -171,6 +185,7 @@ public class BaiduApiHelper {
|
|
FaceResult result = new FaceResult();
|
|
FaceResult result = new FaceResult();
|
|
result.setPass(false);
|
|
result.setPass(false);
|
|
result.setApiLimit(false);
|
|
result.setApiLimit(false);
|
|
|
|
+ result.setScore(0d);
|
|
|
|
|
|
if (response.getError_code() != 0) {
|
|
if (response.getError_code() != 0) {
|
|
result.setError(response.getError_code() + " - " + response.getError_msg());
|
|
result.setError(response.getError_code() + " - " + response.getError_msg());
|
|
@@ -184,7 +199,7 @@ public class BaiduApiHelper {
|
|
|
|
|
|
BaiduResult data = response.getResult();
|
|
BaiduResult data = response.getResult();
|
|
if (data != null) {
|
|
if (data != null) {
|
|
- result.setScore(data.getScore());
|
|
|
|
|
|
+ result.setScore(data.getScore() != null ? data.getScore() : 0d);
|
|
|
|
|
|
// 人脸相似度得分,官方推荐阈值80分,建议调整为75分
|
|
// 人脸相似度得分,官方推荐阈值80分,建议调整为75分
|
|
if (data.getScore() != null && data.getScore() >= 75d) {
|
|
if (data.getScore() != null && data.getScore() >= 75d) {
|