图像识别logo报错的name写入不进去
xh7532 发布于2019-02 浏览:1020 回复:1
0
收藏

if(! session('token')){
$token = $this->gets();
session(['token'=>$token]);
}else{
$token= session('token');
}
$url = 'https://aip.baidubce.com/rest/2.0/realtime_search/v1/logo/add?access_token=' . $token;
$img = file_get_contents('./uploads/3.png');
$img = base64_encode($img);
$bodys = array(
'image' => $img,
'brief' => "{'name': '丽妍雅集', 'code': '789'}",
);
$res =$this->request_post($url, $bodys);

写入了以后调用查询接口查到的

string(833) "{"log_id": 8945825549379493153, "result_num": 6, "result": [{"type": 469, "name": null, "probability": 0.94818740919525, "location": {"width": 155, "top": 52, "left": 23, "height": 61}}, {"type": 469, "name": null, "probability": 0.90824555789723, "location": {"width": 165, "top": 33, "left": 13, "height": 103}}, {"type": 469, "name": null, "probability": 0.90716250550513, "location": {"width": 121, "top": 64, "left": 32, "height": 44}}, {"type": 1, "name": "雄泰", "probability": 0.20392883300781, "location": {"width": 71, "top": 52, "left": 107, "height": 60}}, {"type": 1, "name": "伊丽娜", "probability": 0.15021939791166, "location": {"width": 74, "top": 47, "left": 40, "height": 63}}, {"type": 1, "name": "得丽珑", "probability": 0.11716055063101, "location": {"width": 74, "top": 47, "left": 26, "height": 72}}]}"

没有name名称...

收藏
点赞
0
个赞
共1条回复 最后由jinqili952回复于2019-02
#2jinqili952回复于2019-02

'brief' => "{'name': '丽妍雅集', 'code': '789'}",

入库时的'brief'字段内容填写错误,该字段内容需要是标准的json格式,请参考:http://ai.baidu.com/docs#/ImageClassify-API/top

中该字段的示例

后续版本会做一个字段格式填写错误的提示

0
TOP
切换版块