face++ php
总流程是先上传文件,保存到后台,获取返回来的face_token保存下来,然后拿face_token添加到faceSet里面去,搜索的时候结果会返回faceSet里面的face_token
1、demo
/** * 搜索比较最相思的图片,imgUrl可以用本地文件,网络文件,base64 * 文档:https://console.faceplusplus.com.cn/documents/4888381 * @var string */ $url = "https://api-cn.faceplusplus.com/facepp/v3/search"; $imgUrl = 'http://1e51afa40f4bfb057a.jpg'; $faceset_token = 'f82d37f672f54e617c6052d6'; $res = send_post($url,array('image_url'=>$imgUrl,'api_key'=>"nsQNsO3",'api_secret'=>"xv",'faceset_token'=>$faceset_token)); echo $res.'<br><br><br>'; $face =json_decode($res,true); /** * array (size=6) 'image_id' => string 'rYPXUDmjXoWdaiRt8mg==' (length=24) 'faces' => array (size=1) 0 => array (size=2) 'face_rectangle' => array (size=4) ... 'face_token' => string 'dceeeb27395c2c274c8c0493' (length=32) 'time_used' => int 610 'thresholds' => array (size=3) '1e-3' => float 62.327 '1e-5' => float 73.975 '1e-4' => float 69.101 'request_id' => string '1528902829,c974d95a-85-97e4-fd10694a4b' (length=47) 'results' => array (size=1) 0 => array (size=3) 'confidence' => float 97.055 'user_id' => string '' (length=0) 'fac */ /** * 去除返回的结果face_token,或者imageId,拿去OSS或者数据去比对查出图片URL */