按照http://ai.baidu.com/docs#/Face-Match-V3/top文档上的php的代码做的,出现222208错误:
{"error_code":222208,"error_msg":"the number of image is incorrect","log_id":3221129827,"timestamp":1526463588,"cached":0,"result":null}
求大神解答。php代码如下
function request_post_json($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$curl = curl_init();//初始化curl
curl_setopt($curl, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($curl, CURLOPT_HEADER, true);//设置header
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8'
)
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($curl, CURLOPT_POST, 1);//post提交方式
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($curl);//运行curl
curl_close($curl);
return $data;
}
$token = $this->actionGetToken();
$url = 'https://aip.baidubce.com/rest/2.0/face/v3/match?access_token=' . $token;
$bodys = "[{\"image\":\"$source_data\",\"image_type\":\"BASE64\",\"face_type\":\"LIVE\",\"quality_control\":\"LOW\",\"liveness_control\":\"HIGH
\"},{\"image\":\"$newdata\",\"image_type\":\"BASE64\",\"face_type\":\"LIVE\",\"quality_control\":\"LOW\",\"liveness_control\":\"HIGH\"}]";
$res = request_post_json($url, $bodys);
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
想问一下怎么解决的呀
已解决。 知道是什么原因了。
嗯。 source_data newdata都是base64的数据, 这样生成的: cat head.jpg | base64 | tr -d "\n".
确实看不出有啥问题。看你的数据拼接的没有问题,
你source_data newdata 传递是图片的base64数据吧
错误是说 图像的个数不正确
我只会Java http://ai.baidu.com/forum/topic/show/864698 你可以参考看看