人脸识别shell脚本怎么转换编码,base64
炫炫DNF 发布于2018-07 浏览:1603 回复:2
0
收藏

image_to_base64(){
if [ -f $1 ]; then
IMAGE=`base64 $1`
fi
}

curl -s -k "https://aip.baidubce.com/rest/2.0/face/v3/detect?access_token=$ACCESS_TOKEN" --data '{"image":"'$IMAGE'","image_type":"BASE64","face_field":"age,beauty,expression,faceshape,gender,glasses,landmark,race,quality,facetype"}' -H 'Content-Type:application/json; charset=UTF-8'

我传入一个文件名是jpg格式。转换之后存在IMAGE变量里,然后curl一直返回{"error_code":222001,"error_msg":"param[image] is null","log_id":9420194001792,"timestamp":1531219343,"cached":0,"result":null}

收藏
点赞
0
个赞
共2条回复 最后由炫炫DNF回复于2018-07
#3炫炫DNF回复于2018-07

解决了,具体的原因不太清楚,自己把base64编码后的数据再进行urlencode之后就可以了。用curl自带的不行。

0
#2炫炫DNF回复于2018-07


{"error_code":222001,"error_msg":"param[image] is null","log_id":7989797545250,"timestamp":1531219736,"cached":0,"result":null}curl: (6) Could not resolve host: FhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj; Name or service not known
curl: (6) Could not resolve host: KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj; Name or service not known

 

执行后会卡住,然后打印这个,是不是请求的时候image字段里的内容有问题啊?

0
TOP
切换版块