|
本帖最后由 52yaoer 于 2021-1-16 12:14 编辑
本模块封装了百度开放平台的人脸识别客户端SDK(活体检测),可以在客户端方便快捷的接入人脸识别功能。
点击进入模块详情
- <!DOCTYPE html>
- <html>
- <head>
- <title>Module Develop</title>
- <meta charset="utf-8">
- <meta name="viewport"
- content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <style type="text/css">
- html,
- body {
- height: 100%
- }
- body {
- background-color: #fff;
- margin: 0;
- }
- #wrap {
- height: 100%;
- position: relative;
- }
- #header {
- padding-top: 20px;
- background-color: #5082c2;
- height: 44px;
- position: relative;
- }
- #header h1 {
- font-size: 20px;
- height: 44px;
- line-height: 44px;
- margin: 0em;
- color: #fff;
- margin-left: 100px;
- margin-right: 100px;
- text-align: center;
- }
- #main {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- }
- a.button {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- -webkit-box-align: center;
- height: 32px;
- margin: 8px;
- background-color: rgba(240, 240, 240, 1.0);
- border-color: rgba(220, 220, 220, 1.0);
- border-width: 2px;
- border-style: solid;
- }
- a.active {
- background-color: rgba(240, 240, 240, 0.7);
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <a class="button" tapmode="active" onclick="initSdk()">initSdk</a>
- <a class="button" tapmode="active" onclick="requestPermission()">相机权限(系统API)</a>
- <a class="button" tapmode="active" onclick="openFaceDetectView()">打开人脸识别界面</a>
- <a class="button" tapmode="active" onclick="continueFaceDetect()">识别结果处理后继续人脸识别</a>
- <a class="button" tapmode="active" onclick="closeFaceDetectView()">关闭人脸识别界面</a>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var demo = null;
- apiready = function () {
- demo = api.require('baiduFaceLive');
- if (!demo) {
- alert("请添加模块后编译");
- return;
- }
- }
- function requestPermission() {
- api.requestPermission({
- list: ['camera'],
- }, function (ret, err) {
- api.alert({
- msg: JSON.stringify(ret)
- });
- });
- }
- function initSdk() {
- demo.initSdk({
- LicenseID_Android: 'test-new-2020-face-android',
- LicenseFileName_Android: 'idl-license.face-android',
- LicenseID_iOS: 'test-new-2020-face-ios',
- LicenseFileName_iOS: 'idl-license.face-ios',
- }, function (ret, err) {
- alert(JSON.stringify(ret) + " " + JSON.stringify(err));
- });
- }
- function openFaceDetectView() {
- demo.openFaceDetectView({
- rect: {
- x: 0,
- y: 0,
- //w : api.frameWidth,
- //h : api.frameHeight,
- },
- fixedOn: api.frameName,
- fixed: true,
- isSound: true,
- defaultUI: true,
- isShowRectLine: false
- }, function (ret, err) {
- if (ret.evenType == 'success') {
- alert(ret.data.bestImage);
- } else {
- api.toast({
- msg: JSON.stringify(ret) + " " + JSON.stringify(err)
- });
- }
- });
- }
- function continueFaceDetect() {
- demo.continueFaceDetect(function (ret, err) {
- //alert(JSON.stringify(ret));
- });
- }
- function closeFaceDetectView() {
- demo.closeFaceDetectView(function (ret, err) {
- //alert(JSON.stringify(ret));
- });
- }
- </script>
- </html>
复制代码
|
|