senno-test v1.0.26
使用说明 1.请先登录小程序并进入“设置-第三方服务-插件管理”,搜索并添加插件"TensorFlowJS"
2.在微信小程序的app.json中声明使用该插件,如下: { ... "plugins": { "tfjsPlugin": { "version": "0.2.0", "provider": "wx6afed118d9e81df9" } } ... }
3.参考微信小程序npm工具文档如何编译npm包到小程序中。https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html
4.添加npm包senno-test,执行命令:npm i senno-test --legacy-peer-deps
5.构建npm,先进入微信开发工具点击“工具-构建npm”,其次点击“编译”运行(注意:如果编译过程tr46一直卡着,把miniprogram_npm目录下的tr46文件夹删掉,重新编译)
6.在app.js的onLaunch里调用插件configPlugin函数,如下: var fetchWechat = require('fetch-wechat'); var tf = require('@tensorflow/tfjs-core'); var webgl = require('@tensorflow/tfjs-backend-webgl'); var plugin = requirePlugin('tfjsPlugin'); //app.js App({ onLaunch: function () { plugin.configPlugin({ fetchFunc: fetchWechat.fetchFunc(), tf, webgl, canvas: wx.createOffscreenCanvas() }); } }); 7.使用senno-test进行姿态识别,在index.js中引入senno-test模块,如: var senno = require('senno-test') 接口说明: senno.loadModel() 用于加载模型 senno.estimatePoses(frame) 用于姿态识别,参数frame为相机的帧
代码演示请参照Demo