当前位置: 首页 > wzjs >正文

网站建设设计开发公司wordpress 书 pdf

网站建设设计开发公司,wordpress 书 pdf,百度网站联盟,高端制造股十大龙头效果 思路 通过 live-pusher 这个视频推流的组件来获取摄像头拿到视频的一帧图片之后,跳转到正常的 vue 页面,通过 canvas 来处理图片水印 源码 live-pusher 这个组件必须是 nvue 的 至于什么是 nvue,看这个官方文档吧 https://uniapp.dcl…

效果

在这里插入图片描述

在这里插入图片描述

思路

  • 通过 live-pusher 这个视频推流的组件来获取摄像头
  • 拿到视频的一帧图片之后,跳转到正常的 vue 页面,通过 canvas 来处理图片+水印

源码

live-pusher 这个组件必须是 nvue

至于什么是 nvue,看这个官方文档吧 https://uniapp.dcloud.net.cn/tutorial/nvue-outline.html

// index.nvue
<template><view class="pengke-camera" :style="{ width: windowWidth, height: windowHeight }"><!-- live-pusher 显示实时画面 --><live-pusherid="livePusher"class="livePusher"mode="FHD"device-position="back":muted="true":enable-camera="true":enable-mic="false":auto-focus="true":zoom="false":style="{ width: windowWidth, height: windowHeight }"></live-pusher><!-- 拍照按钮 --><view class="menu"><cover-image class="menu-snapshot" @tap="snapshot" src="./icon/snapshot.png"></cover-image></view></view>
</template><script>
export default {data() {return {windowWidth: '',windowHeight: '',livePusher: null}},onLoad() {this.initCamera()},onReady() {const pages = getCurrentPages()const currentPage = pages[pages.length - 1]this.livePusher = uni.createLivePusherContext('livePusher', currentPage)this.livePusher.startPreview()},methods: {initCamera() {uni.getSystemInfo({success: res => {this.windowWidth = res.windowWidththis.windowHeight = res.windowHeight}})},snapshot() {this.livePusher.snapshot({success: e => {const path = e.message.tempImagePathuni.navigateTo({url: `/pages/camera/preview?img=${encodeURIComponent(path)}`})},fail: err => {console.error('拍照失败', err)}})}}
}
</script><style lang="less">
.pengke-camera {position: relative;.livePusher {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}.menu {position: absolute;bottom: 60rpx;left: 0;right: 0;display: flex;justify-content: center;align-items: center;z-index: 10;pointer-events: auto;.menu-snapshot {width: 130rpx;height: 130rpx;background-color: #fff;border-radius: 65rpx;box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.2);}}
}</style>

预览文件 preview.vue

// preview.vue
<template><view class="preview-page"><!-- 可见 canvas 显示图 + 水印 --><canvascanvas-id="watermarkCanvas"id="watermarkCanvas"class="watermark-canvas":style="{ width: screenWidth + 'px', height: screenHeight + 'px' }"></canvas><!-- 操作按钮 --><view class="preview-actions"><button class="action-btn cancel-btn" @click="goBack">取消</button><button class="action-btn confirm-btn" @click="exportImage">确认</button></view></view>
</template><script setup>
import { ref, nextTick, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import message from '@/utils/message'const imgUrl = ref('')
const canvasWidth = ref(0)
const canvasHeight = ref(0)
const currentTime = ref('')
const locationText = ref('正在获取位置信息...')const screenWidth = uni.getSystemInfoSync().windowWidth
const screenHeight = uni.getSystemInfoSync().windowHeightonLoad((options) => {if (options.img) {imgUrl.value = decodeURIComponent(options.img)initImage()}updateTime()updateLocation()
})function updateTime() {const now = new Date()currentTime.value = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`
}function updateLocation() {uni.getLocation({type: 'wgs84',success: (res) => {locationText.value = `经度: ${res.longitude}  纬度: ${res.latitude}`drawCanvas()},fail: () => {locationText.value = '位置信息获取失败'drawCanvas()}})
}function initImage() {uni.getImageInfo({src: imgUrl.value,success(res) {canvasWidth.value = res.widthcanvasHeight.value = res.heightdrawCanvas()},fail(err) {console.error('图片信息获取失败:', err)}})
}// 绘制预览 canvas
function drawCanvas() {if (!imgUrl.value || !canvasWidth.value || !canvasHeight.value) returnnextTick(() => {const ctx = uni.createCanvasContext('watermarkCanvas')// 绘制原图ctx.drawImage(imgUrl.value, 0, 0, screenWidth, screenHeight)// 设置水印样式ctx.setFontSize(16)ctx.setFillStyle('white')ctx.setTextAlign('left')ctx.fillText(currentTime.value, 20, screenHeight - 160)ctx.setFontSize(16)ctx.fillText(locationText.value, 20, screenHeight - 120)ctx.draw()})
}// 点击确认导出
function exportImage() {// 显示加载提示uni.showLoading({title: '导出中...',mask: true  // 防止点击遮罩层关闭})uni.canvasToTempFilePath({canvasId: 'watermarkCanvas',destWidth: canvasWidth.value,destHeight: canvasHeight.value,success: (res) => {// 隐藏加载提示uni.hideLoading()console.log('导出成功:', res.tempFilePath)message.success(`导出成功! 文件路径为 ${res.tempFilePath}`)uni.previewImage({ urls: [res.tempFilePath] })},fail: (err) => {// 隐藏加载提示uni.hideLoading()console.error('导出失败:', err)uni.showToast({ title: '导出失败', icon: 'none' })}})
}function goBack() {uni.navigateBack()
}
</script><style scoped lang="scss">
.preview-page {width: 100vw;height: 100vh;position: relative;background: #000;overflow: hidden;
}.watermark-canvas {position: absolute;left: 0;top: 0;z-index: 1;
}.preview-actions {position: fixed;left: 0;right: 0;bottom: 60rpx;display: flex;justify-content: center;gap: 40rpx;z-index: 10;
}.action-btn {padding: 0 40rpx;height: 80rpx;line-height: 80rpx;border-radius: 40rpx;font-size: 28rpx;background: #fff;color: #333;border: none;opacity: 0.9;
}.cancel-btn {background: #eee;
}.confirm-btn {background: #19be6b;color: #fff;
}
</style>

文章转载自:

http://EIV09kRc.krrjb.cn
http://eidzJIq5.krrjb.cn
http://hYeKoq1x.krrjb.cn
http://BfiLjTJ6.krrjb.cn
http://4RzbSa2y.krrjb.cn
http://at6spIIN.krrjb.cn
http://2AMr5DUk.krrjb.cn
http://d6neWgmv.krrjb.cn
http://FYK0XOIW.krrjb.cn
http://bzvsLFMW.krrjb.cn
http://lmy76QeP.krrjb.cn
http://uDU32ar9.krrjb.cn
http://eGUBa3LK.krrjb.cn
http://RojyP7GK.krrjb.cn
http://vQfTVHd1.krrjb.cn
http://1upAPqjg.krrjb.cn
http://55ItqmVK.krrjb.cn
http://yuRD2itE.krrjb.cn
http://wwbkoQUP.krrjb.cn
http://f8xYvT4W.krrjb.cn
http://9HUlSEdi.krrjb.cn
http://0DrCEUCc.krrjb.cn
http://VghmJg7a.krrjb.cn
http://tz0OcGPp.krrjb.cn
http://EZCNosDT.krrjb.cn
http://aX0XwtwO.krrjb.cn
http://3KpQeaWB.krrjb.cn
http://FZxTD7AV.krrjb.cn
http://h86LngzA.krrjb.cn
http://jvMX6ah5.krrjb.cn
http://www.dtcms.com/wzjs/632142.html

相关文章:

  • 网站建设noajtwordpress 关联插件
  • 可以直接进网站正能量小米wordpress 表格样式
  • 毕设做网站wordpress新闻墙插件
  • 找人代做网站费用建设网站是哪个部门负责
  • 沙井做网站软文营销案例文章
  • 南昌市做网站微帮本地推广平台
  • 做建筑材料的网站正规的佛山网站建设
  • 做个网站多少钱网页设计图片排版模板
  • 凡科网怎么修改网站微信官方网站登陆
  • 怎么样百度能搜到自己的网站免费下载ppt的网站
  • 福州网站建设营销方案连云港新站优化
  • 沈阳网站建设的公司哪家好长沙建设信息网站
  • 企业网站包含的要素芜湖灵创网站建设
  • 乌市昌吉州建设局网站建设工程施工许可证在哪个网站办
  • 润商网站建设织梦 音乐网站
  • 普洱高端网站建设价格wordpress套用主题
  • 在互联网公司做网站平价网站建设
  • 网站 跑马灯图片怎么做凡科快图怎么制作图片
  • 业网站制作郧阳网站建设
  • 致力于网站建设常州网站建设选思创
  • 如何做好电商网站购物网站 设计
  • 专业建设专业网站制作公司全国中小型企业名录
  • 中国做网站的公司有哪些青岛招聘seo
  • 有没有专门做帽子的网站wordpress移动下方的菜单
  • 深圳做企业网站的公司推荐wordpress编辑器那个好
  • 购物网站最近浏览怎么做陕西网站建设策划内容
  • 长春网站开发培训深圳vi设计有哪些
  • 北京鑫创网站建设外发加工网下载
  • iis7.0 asp网站配置北京建筑公司网站
  • 网上书店网站建设做相册的网站 ppt