小程序怎么实现人脸识别功能

这篇文章给大家分享的是有关小程序怎么实现人脸识别功能的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

  人脸识别功能接入流程

  按照文档获取AppID、APIKey、SecretKey,进行AccessToken(用户身份验证和授权的凭证)的生成

constgetBaiduToken=function(){
  returnnewPromise((resolve,reject)=>{
  //自行获取APIKey、SecretKey
  constapiKey=APIKey;
  constsecKey=SecretKey;
  consttokenUrl=`https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=${apiKey}&client_secret=${secKey}`;
  wx.request({
  method:'POST',
  dataType:"json",
  header:{
  'content-type':'application/json;charset=UTF-8'
  },
  success:function(res){
  resolve(res);
  },
  fail:function(res){
  wx.hideLoading();
  wx.showToast({
  title:'网络错误,请重试!',
  icon:'none',
  duration:2000
  })
  reject(res);
  },
  complete:function(res){
  resolve(res);
  }
  })
  })
  }

  人脸识别功能选择接口

  选择人脸识别-->人脸检测,人脸识别接口分为V2和V3两个版本,确认在云后台获得的是V2还是v3版本接口权限。

感谢各位的阅读!关于“小程序怎么实现人脸识别功能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!