基础库 3.20.11 开始支持,低版本需做兼容处理。
成都创新互联成立于2013年,先为安徽等服务建站,安徽等地企业,进行企业商务咨询服务。为安徽企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
解释:人脸检测,检测图片中的人脸并标记出相应的信息位置,同时可以展示出人脸的关键信息和属性信息,比如年龄,性别等。使用本功能需要小程序开发者后台登录超级管理员账号,点击云平台付费链接开通云账号付费功能。
Web 态说明:受宿主环境限制,Web 态暂不支持 AI 能力相关接口。在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。
Object object
| 属性名 | 类型 | 必填 | 默认值 | 说明 | 
|---|---|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
| 参数名 | 参数类型 | 说明 | 
|---|---|---|
扫码体验
代码示例
请使用百度APP扫码
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
Page({faceDetect() {swan.chooseImage({success: res => {let image = res.tempFilePaths[0];// AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误let host = swan.getSystemInfoSync().host;if (host === 'baiduboxapp') {swan.ai.faceDetect({image,image_type: 'BASE64',face_field: 'age,beauty,angle,expression,face_shape,gender,glasses,eye_status,race,quality',max_face_num: '1',face_type: 'LIVE',success: res => {console.log(res.face_list);},fail: err => {console.log( err);}});}else {swan.showToast({title: '此api目前仅可在百度App上使用',icon: 'none'});}}})}});
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
Page({faceDetect() {swan.chooseImage({success: res => {let image = res.tempFilePaths[0];// AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误let host = swan.getSystemInfoSync().host;if (host === 'baiduboxapp') {swan.ai.faceDetect({image:'https://b.bdstatic.com/miniapp/image/faceDetect.png',image_type: 'URL',face_field: 'age,beauty,angle,expression,face_shape,gender,glasses,eye_status,race,quality',max_face_num: '1',face_type: 'LIVE',success: res => {console.log(res.face_list);},fail: err => {console.log( err);}});}else {swan.showToast({title: '此api目前仅可在百度App上使用',icon: 'none'});}}})}});
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
Page({faceDetect() {swan.chooseImage({success: res => {let image = res.tempFilePaths[0];// AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误let host = swan.getSystemInfoSync().host;if (host === 'baiduboxapp') {swan.ai.faceDetect({// 可由之前图片检测的返回值中获得image:'4160b708a826b18de95fe5c9a098a436',image_type: 'FACE_TOKEN',face_field: 'age,beauty,angle,expression,face_shape,gender,glasses,eye_status,race,quality',max_face_num: '1',face_type: 'LIVE',success: res => {console.log(res.face_list);},fail: err => {console.log( err);}});}else {swan.showToast({title: '此api目前仅可在百度App上使用',icon: 'none'});}}})}});
{"face_num": 1,"face_list": [{"face_token": "35235asfas21421fakghktyfdgh68bio","location": {"left": 117,"top": 131,"width": 172,"height": 170,"rotation": 4},"face_probability": 1,"angle" :{"yaw" : -0.34859421849251"pitch" 1.9135693311691"roll" :2.3033397197723}"landmark": [{"x": 161.74819946289,"y": 163.30244445801},...],"landmark72": [{"x": 115.86531066895,"y": 170.0546875},...],"age": 29.298097610474,"beauty": 55.128883361816,"expression": {"type": "smile","probability" : 0.5543018579483},"gender": {"type": "male","probability": 0.99979132413864},"glasses": {"type": "sun","probability": 0.99999964237213},"race": {"type": "yellow","probability": 0.99999976158142},"face_shape": {"type": "triangle","probability": 0.5543018579483}"quality": {"occlusion": {"left_eye": 0,"right_eye": 0,"nose": 0,"mouth": 0,"left_cheek": 0.0064102564938366,"right_cheek": 0.0057411273010075,"chin": 0},"blur": 1.1886881756684e-10,"illumination": 141,"completeness": 1}}]}
                分享题目:创新互联百度小程序教程:swan.ai.faceDetect
                
                标题URL:http://www.csdahua.cn/qtweb/news47/44997.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网