不用活体检测参数时接口调用正常,加入之后在获取活体检测分数时抛出异常显示该值为null,中断时查看了返回的json数组,没有faceliveness项返回。
代码段如下:
var client = new Baidu.Aip.Face.Face(Api_Key, Secret_Key);
var image1 = File.ReadAllBytes(filename);
//接口调用参数,用户组为Staff
var group_id = "Staff";
//可选参数,检测是否为活体
Dictionary<string, object> options = new Dictionary<string, object>()
{
{"ext_fields","faceliveness"}
};
var result = client.Identify(group_id, image1,options);
//先判断脸是不是在上面,在继续看有匹配的没,否则提示放上脸
//得到根节点
JObject jo_result = (JObject)JsonConvert.DeserializeObject(result.ToString());
if ((string)jo_result["error_msg"] != null)
{
MessageBox.Show("对不起,请把脸放在镜头上!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else
{
//检测到脸
//得到result节点
JArray jo_age = (JArray)JsonConvert.DeserializeObject(jo_result["result"].ToString());
foreach (var val in jo_age)
{
id = long.Parse(((JObject)val)["uid"].ToString()); //获取uid
string scores = ((JObject)val)["scores"].ToString();//获取人脸对比的scores
string facelive = ((JObject)val)["faceliveness"].ToString(); //获取活体检测的分数
faceliveness = Convert.ToDouble(facelive);
MessageBox.Show(facelive);
使用百度人脸识别接口在加入活体检测参数后还是没有活体检测阈值返回
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答
- threenewbee 2018-05-05 16:34关注
image_liveness不是ext_fields
https://www.cnblogs.com/duanbiflying/p/7527310.html解决 无用评论 打赏 举报