swan.ai.faceSearch
基础库 3.20.11 开始支持,低版本需做兼容处理。 解释:人脸搜索,传入人脸图片,支持在指定人脸图片集合中,找到与传入图片中人脸最为相似的图片。使用本功能需要小程序开发者后台登录超级管理员账号,点击云平台付费链接开通云账号付费功能。
方法参数
Object object
object参数说明 :
success 返回参数说明
user_list参数说明
示例
在开发者工具中预览效果 请使用百度APP扫码
图片示例
代码示例
Page({ faceSearch() { swan.chooseImage({ success: res => { let imageTop = res.tempFilePaths[0]; // let imageLeft = res.tempFilePaths[1]; // let imageMid = res.tempFilePaths[2]; // let imageRight = res.tempFilePaths[3]; // AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误 let host = swan.getSystemInfoSync().host; if (host === 'baiduboxapp') { swan.ai.faceSearch({ image, image_type: 'BASE64', group_id_list: 'imageLeft,imageMid,imageRight', quality_control: 'NONE', liveness_control: 'NONE', face_type: 'LIVE', user_id: 'xxxxxx', max_user_num: 20, success: res => { console.log(res); }, fail: err => { console.log(err); } }); } else { swan.showToast({ title: '此api目前仅可在百度App上使用', icon: 'none' }); } } }); }});返回示例
{ "face_token": "fid", "user_list": [ { "group_id" : "test1", "user_id": "u333333", "user_info": "Test User", "score": 99.3 } ] }
