运用uniapp实现登录时的人脸识别(需在真机中运行)

/ case 'InvalidParameterValue.NoFaceInGroups': info = '请对准人脸';.localizedMessage.split('-')[0] == '请对准人脸')) {.localizedMessage.split('-')[0] == '请对准人脸')) {.localizedMessage.split('-')[0]) || '验证失败');.localizedMessage.split('-')[0]) || '验证失败');//base64图片。
摘要由CSDN通过智能技术生成

以下是基本代码:
<template>
    <view style="background-color: #fff;">
        <view class="myNavigationBar" :style="{ height: cHeight + textHight + 'rpx' }">
            <view class="navigationBar" :style="{ height: cHeight + 'rpx', backgroundColor: '#0055ff' }"></view>
            <view class="navigationBarText" :style="{ top: cHeight + 'rpx', backgroundColor: '#fff', color: '#333' }">
                <image src="https://sxhcxfyy-1305280360.cos.ap-beijing.myqcloud.com/sxhcxfyy/cecf*fanhui@3x%20(2).png"
                    class="backImg"></image>
                <text class="barBack" @click="BackPage">返回</text>
                <text class="barTitle">{ {type == 'login' ? '人脸登录' : '人脸新增'  }}</text>
            </view>
        </view>
        <div>
            <text
                style="text-align: center;font-size: 60rpx;color: #333;margin-top: 40rpx;">{ {type == 'login' ? '人脸登录服务' : '人脸新增服务'  }}</text>
        </div>
        <div class="tixing_text">

            <text v-if="text == '验证成功!' || text == '新增成功!'" style="font-size: 30rpx;color: #18B566;">{ { text }}</text>
            <text v-else style="font-size: 30rpx;color: #F29100;">{ { text }}</text>
        </div>
        <div class="livefater">
            <div style="width: 350rpx;height: 350rpx;border-radius: 350rpx;overflow: hidden;background-color: #CCCCCC;">
                <live-pusher id="livePusher" ref="livePusher" class="livePusher" url="" mode="SD" :muted="true"
                    :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2" aspect="1:1"></live-pusher>
            </div>
            <cover-image
                src="https://sxhcxfyy-1305280360.cos.ap-beijing.myqcloud.com/sxhcxfyy/d26d*微信图片_20210411170242.png"
                class="gaiimg"></cover-image>
            <cover-image src="https://sxhcxfyy-1305280360.cos.ap-beijing.myqcloud.com/app/icon/faceBottom.png"
                class="gaiimg2"></cover-image>
        </div>
    </view>
</template>

<script>
    import axios from '../../plugins/pocky-request/index.js';
    export default {
        data: {
            statusBar: '',
            CustomBar: 0,
            uid: '',
            type: '',
            addFlag: false,
            err_num: 0,
            // post: null
            timer: null,
            snapshTimeout: null,
            text: '请正对屏幕进行人脸识别',
            textHight: '',
            cHeight: ''
        },
        onLoad(e) {
            this.type = e.type;
            this.uid = e.uid;
        },
        onReady() {
            var that = this;
            // 注意:需要在onReady中 或 onLoad 延时
            this.context = uni.createLivePusherContext('livePusher', this);
            setTimeout(function() {
                that.context.startPreview({
                    success: a => {
                        that.snapshot();
                    }
                });
            }, 200);
            uni.getSystemInfo({
                success: function(res) {
                    if (res.platform == 'android') {
                        that.cHeight = res.statusBarHeight + 50;
                    } else {
                        that.cHeight = res.statusBarHeight + 45;
                    }
                }
            });
            this.textHight = 87;
        },
        methods: {
            async post(obj = {
                url: '',
              

  • 15
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值