在线活体检测返回值有问题
onlinemc 发布于2018-05 浏览:1764 回复:8
0
收藏

SDK版本:aip-java-sdk-4.3.0

Java版本:jdk1.8.0_151 x64

下图为程序代码 已经再三确认ak/sk填写正确

活体检测的图片为人脸库内已经注册的人脸

 

服务端返回的JSON数据中

face_livenessface_list 都为空

而SDK文档上未说明什么情况下会出现这种问题,请问为什么会出现这种情况?

相关文档:http://ai.baidu.com/docs#/Face-Java-SDK/514d7ea4

收藏
点赞
0
个赞
共8条回复 最后由木油的大侠回复于2018-05
#9木油的大侠回复于2018-05

谢谢,回复

0
#8用户已被禁言回复于2018-05
#7 木油的大侠回复
请问,上述问题解决了么?怎样解决的?

使用人脸对比那样的代码即可

 

/**
	 * 人脸对比示例代码
	 * @param path1 图片本地路径1
	 * @param token AccessToken
	 * @return
	 */
	public static String FaceVerify(String path1,String token) {
        try {
        	// 本地文件路径
            String filePath1 = path1;
            byte[] imgData1 = FileUtil.readFileByBytes(filePath1);
            String imgStr1 = Base64Util.encode(imgData1);
            List faceMatchs = new ArrayList();
            FaceMatchV3Bean faceMatch1 = new FaceMatchV3Bean(imgStr1,"BASE64");
            faceMatchs.add(faceMatch1);
            String param = JSONObject.toJSONString(faceMatchs);
            System.out.println("======"+param);
            // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
            String accessToken = token;
            String result = HttpUtil.post("https://aip.baidubce.com/rest/2.0/face/v3/faceverify", accessToken, param);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

 

 

package com.xs.pojo.face;

import org.json.JSONObject;



public class FaceMatchV3Bean {
		private String image;
		private String image_type;
		private String face_type;
		private String quality_control;
		private String liveness_control;
		public FaceMatchV3Bean() {
		}
		
		public FaceMatchV3Bean(String image, String image_type) {
			super();
			this.image = image;
			this.image_type = image_type;
		}

		public FaceMatchV3Bean(String image, String image_type, String face_type,
				String quality_control, String liveness_control) {
			super();
			this.image = image;
			this.image_type = image_type;
			this.face_type = face_type;
			this.quality_control = quality_control;
			this.liveness_control = liveness_control;
		}
		public String getImage() {
			return image;
		}
		public void setImage(String image) {
			this.image = image;
		}
		public String getImage_type() {
			return image_type;
		}
		public void setImage_type(String image_type) {
			this.image_type = image_type;
		}
		public String getFace_type() {
			return face_type;
		}
		public void setFace_type(String face_type) {
			this.face_type = face_type;
		}
		public String getQuality_control() {
			return quality_control;
		}
		public void setQuality_control(String quality_control) {
			this.quality_control = quality_control;
		}
		public String getLiveness_control() {
			return liveness_control;
		}
		public void setLiveness_control(String liveness_control) {
			this.liveness_control = liveness_control;
		}
		  public JSONObject toJsonObject() {
		        JSONObject obj = new JSONObject();
		        obj.put("image", this.image);
		        obj.put("image_type", this.image_type);
		        if (this.face_type != null) {
		            obj.put("face_type", this.face_type);
		        }
		        if (this.quality_control != null) {
		            obj.put("quality_control", this.quality_control);
		        }
		        if (this.liveness_control != null) {
		            obj.put("liveness_control", this.liveness_control);
		        }
		        return obj;
		    }
}
1
#7木油的大侠回复于2018-05

请问,上述问题解决了么?怎样解决的?

1
#6用户已被禁言回复于2018-05
#5 onlinemc回复
好的,谢谢你的解答

建议你使用和人脸对比一样的请求方式和参数即可。face_field参数并不是必须的

0
#5onlinemc回复于2018-05

好的,谢谢你的解答

0
#4用户已被禁言回复于2018-05
#3 onlinemc回复
这是后端的问题吗?这个问题已经困扰我两天了

建议你提交工单咨询一下把

1
#3onlinemc回复于2018-05
#2 用户已被禁言回复
我API SDK都测试了。也是同样的问题 [代码]

这是后端的问题吗?这个问题已经困扰我两天了

1
#2用户已被禁言回复于2018-05

我API SDK都测试了。也是同样的问题

{
    "error_code": 0, 
    "error_msg": "SUCCESS", 
    "log_id": 4096480609, 
    "timestamp": 1525420074, 
    "cached": 0, 
    "result": {
        "thresholds": {
            "frr_1e-4": 0.05, 
            "frr_1e-3": 0.3, 
            "frr_1e-2": 0.9
        }, 
        "face_liveness": null, 
        "face_list": [ ]
    }
}
2
TOP
切换版块