原生微信小程序AR(扫描指定图片显示glb模型)

效果

ar案例视频

准备:需要准备要扫描的图片地址和扫描成功后显示的模型
1.在components创建组件
在这里插入图片描述
index.js文件代码

Component({properties: {title: {type: String,value: '',},intro: {type: String,value: '',},hint: {type: String,value: '',},code: {type: String,value: '',},json: {type: String,value: '',},js: {type: String,value: '',},showBackBtn: {type: Boolean,value: false,},},data: {},lifetimes: {attached() {wx.xrTitle = this.data.title;}},methods: {onClickBack() {wx.navigateBack()},}
})

index.json代码

{"component": true,"usingComponents": {}
}

index.wxml代码

<view class="demo-wrap"><scroll-view class="demo-viewer" scroll-y="{{true}}"><block bind:sceneReady="handleSceneReady"><slot></slot></block><view class="intro"><view class="intro-detail"><view class="intro-title" ><text>{{title}}</text> <button class="share" open-type="share">分享给好友</button></view><view class="description" >{{intro}}</view></view></view><view wx:if="{{hint.length > 0}}"><view class="hint-wrap"><text class="hint-words" >{{hint}}</text></view></view><view wx:if="{{code.length > 0}}"><view class="intro"><view class="intro-detail"><view class="title">代码演示</view><view class="code-inner"><rich-text nodes="{{code}}"></rich-text></view></view></view></view><view wx:if="{{js.length > 0}}"><view class="intro"><view class="intro-detail"><view class="title">脚本演示</view><view class="code-inner"><rich-text nodes="{{js}}"></rich-text></view></view></view></view><view wx:if="{{json.length > 0}}"><view class="intro"><view class="intro-detail"><view class="title">动画数据结构</view><view class="code-inner"><rich-text nodes="{{json}}"></rich-text></view></view></view></view><view class="holder"></view></scroll-view><view class="back-btn-wrap" wx:if="{{showBackBtn}}" bind:tap="onClickBack"><view class="back-line-t"></view><view class="back-line-b"></view></view>
</view>

index.wxss代码

.demo-wrap {position: absolute;left: 0;top: 0;width: 100%;height: 100%;
}
.demo-viewer {position: absolute;left: 0;top: 0;width: 100%;height: 100%;
}.holder {height: 60rpx;
}.hint-wrap {text-align: center;
}.hint-words {display: inline-block;color: #000;text-align:center;font-weight:bold;max-width: 300px;padding: 10px 20px;border: 2px dashed #000;background-color: #fff;
}.intro {display: block;margin: 20rpx 0;background: #fff;
}.intro .title {font-size: 36rpx;padding-bottom: 20rpx;
}.intro .description {color: #8f8f8f;font-size: 28rpx;
}.intro-detail {padding: 30rpx;
}.code-inner {margin: 0rpx;padding: 30rpx;font-size: 30rpx;background-color: #f9f9fa;
}.code-inner rich-text {word-wrap: break-word;
}.block-name {display: inline-block;color: #b457ff;
}.attr-name {display: inline-block;color: #ff4d00;
}.ml20 {margin-left: 20rpx;
}.intro-title {font-size: 30rpx;font-weight: bold;display: flex;justify-content: space-between;align-items: baseline;margin-bottom: 24rpx;
}.share {margin: 0 !important;margin-left: 0 !important;margin-right: 0 !important;padding: 0;width: 160rpx !important;background: none;font-size: 28rpx;color: #ff4d00;
}.back-btn-wrap {position: absolute;left: 30rpx;top: 100rpx;width: 90rpx;height: 80rpx;
}
.back-line-t {position: absolute;left: 20rpx;top: 15rpx;width: 30rpx;height: 6rpx;background-color: #000;transform: rotate(-45deg);border-radius: 5rpx;
}
.back-line-b {position: absolute;left: 20rpx;top: 32rpx;width: 30rpx;height: 6rpx;background-color: #000;transform: rotate(45deg);border-radius: 5rpx;
}

2.继续在components里面创建xr-ar-oceanWorld组件
在这里插入图片描述
index.js文件代码

Component({behaviors: [require('../common/share-behavior').default],//路径按照自己项目路径来miku: null,mikuTransform: null,mikuAnimator: null,animationRuning: false,isShow: false,properties: {//是否显示文字贴图默认不显示isShowDolphin: {type: false},},wxball: null,time1: null,time2: null,data: {loaded: false,arReady: false,},lifetimes: {async attached() {// console.log('data', this.data);}},methods: {handleReady({detail}) {const xrScene = this.scene = detail.value;const xrFrameSystem = wx.getXrFrameSystem();},handleAssetsProgress: function ({detail}) {},handleAssetsLoaded: function ({detail}) {// console.log('assets loaded', detail.value);this.setData({loaded: true});},handleTouchmiku: function() {//  console.log('miku TOUCH', this.animationRuning);// if (!this.animationRuning) {//   //   this.animationRuning = true;//   this.mikuAnimator.pauseToFrame('gltfAnimation', 1);//   this.mikuAnimator.pauseToFrame('gltfAnimation#0', 1);//   this.mikuAnimator.resume('gltfAnimation');//   this.mikuAnimator.resume('gltfAnimation#0');// }},handleAnimationStop: function() {console.log('animation Stop');},// 识别模型状态handleARTrackerState({detail}) {// 事件的值即为`ARTracker`实例const tracker = detail.value;// 获取当前状态和错误信息const {state, errorMessage} = tracker;// const video = this.scene.assets.getAsset('video-texture', 'hikari', 'white');console.log(state==2);if(state==2){console.log("状态识别成功", state)this.time1 = setTimeout(() => {this.setData({isShow: true})}, 1000)// this.time2 = setTimeout(() => {//   console.log("暂停动画")//   const animator1 = this.scene.getElementById('wxball-1').getComponent("animator");//   animator1.pause();//   const animator2 = this.scene.getElementById('wxball-2').getComponent("animator");//   animator2.pause();// }, 7000)}else{// clearTimeout(this.time1);// clearTimeout(this.time2);this.setData({isShow: false})}},// 识别海豚handleARTrackerState1({detail}) {// 事件的值即为`ARTracker`实例const tracker = detail.value;// 获取当前状态和错误信息const {state, errorMessage} = tracker;// const video = this.scene.assets.getAsset('video-texture', 'hikari', 'white');console.log(state==2);if(state==2){console.log("识别海豚", state);// this.triggerEvent('传递给父组件的自定义事件名称 newValue',传给父组件的数据 valueText)this.time1 = setTimeout(() => {this.triggerEvent('changeDolphin',{isShowDolphin:true})this.setData({isShow: true,isShowDolphin:true})}, 1000)// this.time2 = setTimeout(() => {//   console.log("暂停动画")//   const animator1 = this.scene.getElementById('wxball-1').getComponent("animator");//   animator1.pause();//   const animator2 = this.scene.getElementById('wxball-2').getComponent("animator");//   animator2.pause();// }, 7000)}else{this.triggerEvent('changeDolphin',{isShowDolphin:false})// clearTimeout(this.time1);// clearTimeout(this.time2);this.setData({isShow: false})}},handleARReady({detail}) {const xrFrameSystem = wx.getXrFrameSystem();const tracker = this.scene.getElementById('ar-tracker').getComponent(xrFrameSystem.ARTracker);// 初始状态const {state, errorMessage} = tracker;// 绑定事件tracker.el.event.add('ar-tracker-state', tracker => {const {state, errorMessage} = tracker;});},handleGLTFLoaded({detail}) {// console.log("进来了")// const el = detail.value.target;// const animator = el.getComponent("animator");// console.log("1111",animator)//  setTimeout(function(){//   console.log("暂停了")//   animator.pause();//  },3000)}}
})

index.json文件代码

{"component": true,"usingComponents": {"xr-demo-viewer": "../xr-demo-viewer/index"},"renderer": "xr-frame"
}

index.wxml

<xr-scene ar-system="modes:Marker;planeMode: 3" id="xr-scene" bind:ready="handleReady" bind:ar-ready="handleARReady" bind:log="handleLog"><xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded"><xr-asset-load type="gltf" asset-id="miku" src="要是别的模型"/><xr-asset-load type="gltf" asset-id="miku2" src="要显示的模型glb格式"/></xr-assets><xr-env env-data="gz-haixinsha" /><xr-node><!-- 识别图片 --><xr-ar-tracker id="ar-tracker" mode="Marker" src="识别的图片" bind:ar-tracker-state="handleARTrackerState1"><xr-gltf id="wxball-1" position="0.2 0.7 -0.25" scale="0.025 0.025 0.025" rotation="-90 0 0" model="miku" anim-autoplay bind:gltf-loaded="handleGLTFLoaded" wx:if="{{isShow}}"></xr-gltf></xr-ar-tracker><!-- 识别图片 水母--><xr-ar-tracker id="ar-tracker" mode="Marker" src="识别的图片" bind:ar-tracker-state="handleARTrackerState"><!-- 最新使用 0 -1 1  0.45 0.45 0.45--><!-- <xr-gltf id="wxball-2"  position="0 -0.5 1" scale="0.45 0.45 0.45" rotation="-90 0 0" model="miku2" anim-autoplay bind:gltf-loaded="handleGLTFLoaded" wx:if="{{isShow}}"></xr-gltf> --><xr-gltf id="wxball-2"  position="0 0 0.5" scale="0.3 0.3 0.3" rotation="-90 0 0" model="miku2" anim-autoplay bind:gltf-loaded="handleGLTFLoaded" wx:if="{{isShow}}"></xr-gltf></xr-ar-tracker><xr-cameraid="camera" node-id="camera" position="1 1 1" clear-color="0.925 0.925 0.925 1"far="2000" background="ar" is-ar-camera></xr-camera></xr-node><xr-node node-id="lights"><xr-light type="ambient" color="1 1 1" intensity="2" /><xr-light type="directional" rotation="90 60 0" color="1 1 1" intensity="1" /></xr-node>
</xr-scene>

3.pages文件夹里创建scene-ar-oceanWorld文件
在这里插入图片描述
index.js代码

var sceneReadyBehavior = require('../../behavior-scene/scene-ready');//路径按照自己项目路径来
Page({behaviors: [sceneReadyBehavior],data: {isShowDolphin:false,//默认不是海豚isShow: false,show: false,video: false,progressFlag: 0,loadingAni: false,isbegin: true,time1: null,time2: null,time3: null,rotation: {x:0,y: 0,z: 0,},op_n:0,meshCount: 0,loading: 0,barIsShow: true,endShow:false,timer:"",deflautWidth:0,musicbg:null},onUnload(){this.musicbg.stop();// 清除video定时器// clearTimeout(this.data.time3);},onLoad(options) {wx.setNavigationBarTitle({title: "潜入海洋的梦里"})let that = this;// 背景音乐this.musicbg = wx.createInnerAudioContext()this.musicbg.src ="背景音乐地址";this.musicbg.volume=0.6;this.musicbg.loop = true;this.musicbg.play();let index = 0;this.data.timer=setInterval(() => { //注意箭头函数!!index += 1;that.setData({deflautWidth: index})if (that.data.deflautWidth == 100) {clearInterval(this.data.timer);}}, 1000);setTimeout(res=>{that.setData({deflautWidth: 100})},3000)// 关闭主页按钮wx.hideHomeButton();},// 场景加载成功回调loadedInfo(){},//获取海豚状态changeDolphin(e){console.log('获取海豚状态',e.detail);this.setData({isShowDolphin:e.detail.isShowDolphin})},end() {console.log("1111")},// 获取微信头像handleReady: function ({detail}) {this.scene = detail.value;// 该接口已废弃,请授权后,采用 getUserInfo 代替。wx.getUserInfo()({desc: '获取头像',success: (res) => {console.log("微信授权", res);this.scene.assets.loadAsset({type: 'texture', assetId: 'avatar', src: res.userInfo.avatarUrl}).then(() => this.setData({avatarTextureId: 'avatar'}));}})},/*** 获取识别状态* Detected识别成功* Detecting未识别*/handleARTrackerState({detail}) {console.log(detail,"识别");const {state,error} = detail;this.tracker = wx.getXrFrameSystem().ARTrackerconst {gesture} = this.tracker;this.gesture = gesture;let states = wx.getXrFrameSystem().EARTrackerState[state];if (states == "Detected") {// if (this.data.progressFlag == 0) {this.setData({progressFlag: 1})// 修改加载界面展示this.setData({show: true           })//识别成功this.data.time1 = setTimeout(() => {this.setData({show: false           })}, 1000)//识别成功// this.data.time2 = setTimeout(() => {//   this.setData({//     isShow: true,//   });//   // 在定时器回调中判断 isShow 的值//   if (this.data.isShow) {//     this.data.time3 = setTimeout(() => {//       console.log("进入if");//       this.setData({//         video: true,//       });//       // 关闭音乐//       this.musicbg.stop();//     }, 4500);//   }// }, 10000);// } else{//   this.setData({//     show: false           //   })// }} else {//识别失败console.log("识别失败", states);this.setData({show: false,// isShow:false,// video: false});clearTimeout(this.data.time1);clearTimeout(this.data.time2);}},/*** 生命周期函数--监听页面初次渲染完成*/onReady() {},onShow() {/*** 设置页面常亮*/wx.setKeepScreenOn({keepScreenOn: true,fail() {//如果失败 再进行调用wx.setKeepScreenOn({keepScreenOn: true});}});},onHide() {this.musicbg.stop();},/*** 页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh() {},/*** 页面上拉触底事件的处理函数*/onReachBottom() {},/*** 用户点击右上角分享*/onShareAppMessage() {}
})

index.json代码

{"usingComponents": {"xr-demo-viewer": "../../../components/xr-demo-viewer/index",//路径按照自己项目路径来"xr-ar-oceanWorld": "../../../components/xr-ar-oceanWorld/index"//路径按照自己项目路径来},"disableScroll": true
}

index.wxml文件代码

<xr-demo-viewer><xr-ar-oceanWorldisShowDolphin="{{isShowDolphin}}"bindchangeDolphin="changeDolphin"disable-scrollid="main-frame"width="{{renderWidth}}"height="{{renderHeight}}"style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;"bind:arTrackerState="handleARTrackerState"/>
</xr-demo-viewer><view class="faceMask" style="width: 100vw; height: 100vh;background-repeat: no-repeat;background-size: cover;background-position:center;z-index: auto;" wx:if="{{show}}"><view class="head1"><view style="display: flex;align-items: center;justify-content: center;height: 100vh;box-sizing: border-box;padding-bottom: 18vh;"><view style="width: 400rpx;"><progress percent="100" color="#3787BC"  stroke-width="18" active duration="10" /></view></view></view></view><!-- 文字贴图 --><!-- <view  wx:if="{{isShowDolphin}}" style="color: aqua;font-size: 40RPX;text-align: center;width: 100VW;height: 100vh;position: relative;z-index: 9999999;"><view style="position: absolute;bottom: 66vw;left: 0;width: 100vw;"><image src="../../../assets/image/logo.png" mode="widthFix" style="width: 100%;"></image></view></view> -->

index.wxss代码

page{width: 100%;height: 100%;}
.mask_bg{width: 100%;height: 100%; background: rgba(0,0,0,0.3); position: absolute; top:0; left: 0; z-index: 10;}
.mask_Img{width: 100%; height: 100%;}
.mask_Box{width: 100%; position: relative; }
.rote{width: 100%; height: 100%;position: absolute; top:0;left: 0;}
.rote image{width: 95%;animation:rotate_music 5s linear infinite; transform-origin: 50% 50%;}
@keyframes rotate_music{0%{transform: rotate(0deg);} 50%{transform: rotate(180deg);} 100%{transform: rotate(360deg);}}
.Detecting{position: absolute;top:0; left: 0; width: 100%; height: 100%; overflow: hidden; border-radius: 100%;}
.Detecting image{animation:d1 4s linear infinite;}
@keyframes d1{0%,100%{transform: translateY(0);} 50%{transform: translateY(65vw);}}
.ar3d{width: 100%; height: 100%; position: absolute;top:0;left: 0; z-index: 10; display: none; }
.ar3d_box{width: 100%; height:90%;perspective:1px; perspective-origin:center center;}
.ar3d_box text{font-size: 1em;animation:tz 5s linear infinite; color:#fff;}
@keyframes tz{0%{transform: translateZ(-3px);} 100%{transform: translateZ(1px);}}
.loading{width: 100%; text-align: center; margin-top: 20%;}
.loading .box{width: 60%; margin: 0 auto; position: relative;}
.loading .bar{width: 100%; position: absolute; bottom: 2%; left: 0; height:40%;}
.loading .bar_loading{width: 100%; height: 100%;  }
.tips{width: 100%; text-align: center; margin-top: 5%;}
.tips image{width: 70%;}
.EndBox{position: absolute;top:0; left: 0; z-index: 2; width: 100%;height: 100%;}
.EndBox .box{width: 100%; height: 100%; background: url(https://cyvideo.i-oranges.com/ar/cdxg/index/ai1.gif) center no-repeat; background-size:cover}.faceMask{width: 100%; height: 100%;position: absolute;top:0;left: 0; z-index: 999999;} 
/* .faceMask .head1{position: absolute;top:0; left: 0; width: 20%;} */
.faceMask .bottom1{position: absolute;bottom:0; left: 0; width: 100%;}
.faceMask .bottom1 image{vertical-align: middle;}
.faceMask .tips{position: absolute; bottom: 5%; width: 100%;}
.faceMask .tips .box{width: 45%; position: relative; margin: 0 auto;}
.faceMask .tips .close{position: absolute; width: 20%; right: -7%; top:-30%;}

4.在components组件里面创建common文件share-behavior.js
在这里插入图片描述
share-behavior.js代码

export default Behavior({created: function () {this.checkInitShare();},methods: {checkInitShare() {wx.xrScene = undefined;if (!this.scene) {setTimeout(() => {this.checkInitShare()}, 100);return;}if (this.scene.ar) {if (this.scene.ar.ready) {this.initARTrackerState(this.scene);    } else { this.scene.event.add('ar-ready', () => this.initARTrackerState(this.scene));}}if (!this.scene.share.supported) {console.warn('Not support xr-frame share system now!');return;}this.sharing = false;wx.xrScene = this.scene;},initARTrackerState(scene) {const xrFrameSystem = wx.getXrFrameSystem();scene.dfs(() => {}, undefined, true, el => {const comp = el.getComponent(xrFrameSystem.ARTracker);if (comp) {if (typeof comp.state === 'number') {this.triggerEvent('arTrackerState', {state: comp.state, error: comp.errorMessage});el.event.add('ar-tracker-state', tracker => {this.triggerEvent('arTrackerState', {state: tracker.state, error: tracker.errorMessage});});}return true;}});}}
})

4.在pages中创建behavior-scene项目
在这里插入图片描述
scene-ready.js文件代码

module.exports = Behavior({behaviors: [],properties: {},data: {left: 0,top: 0,width: 0,height: 0,renderWidth: 0,renderHeight: 0,windowHeight: 1000,heightScale: 1,showBackBtn: false,activeValues: [1],arTrackerShow: false,arTrackerState: 'Init',arTrackerError: ''},attached: function(){},ready() {const info = wx.getSystemInfoSync();const width = info.windowWidth;const windowHeight = info.windowHeight;const height = windowHeight * this.data.heightScale;const dpi = info.pixelRatio;this.setData({width,height,renderWidth: width * dpi,renderHeight: height * dpi,windowHeight});},methods: {onLoad(options) {wx.reportEvent("xr_frame", {"xr_page_path": options.path});},// onShareAppMessage() {//   try {//     if (wx.xrScene) {//       const buffer = wx.xrScene.share.captureToArrayBuffer({quality: 0.5});//       const fp = `${wx.env.USER_DATA_PATH}/xr-frame-share.jpg`;//       wx.getFileSystemManager().writeFileSync(fp, buffer, 'binary');//       return {//         title: this.getTitle(),//         imageUrl: fp//       };//     }//   } catch (e) {//     return {//       title: this.getTitle()//     };//   }// },// onShareTimeline() {//   try {//     if (wx.xrScene) {//       const buffer = wx.xrScene.share.captureToArrayBuffer({quality: 0.5});//       const fp = `${wx.env.USER_DATA_PATH}/xr-frame-share.jpg`;//       wx.getFileSystemManager().writeFileSync(fp, buffer, 'binary');//       return {//         title: this.getTitle(),//         imageUrl: fp//       };//     }//   } catch (e) {//     return {//       title: this.getTitle()//     }//   }// },getTitle() {return wx.xrTitle ? `${wx.xrTitle}` : 'AR';},handleARTrackerState({detail}) {const {state, error} = detail;this.setData({arTrackerShow: true,arTrackerState: wx.getXrFrameSystem().EARTrackerState[state],arTrackerError: error});}}
})

utils.js代码

var handleDecodedXML = function(decodedXml) {let rerurnXml = '';const blockArr = decodedXml.split('&lt;');for (let i = 0; i < blockArr.length; i++) {let blockStr = blockArr[i];let handleBlockStr = '';let returnBlockStr = '';const sliceBlockStr = blockStr.split(' ');for(let j = 0; j < sliceBlockStr.length; j++) {const subBlockStr = sliceBlockStr[j];const eIndex = subBlockStr.indexOf('=');if (eIndex !== -1) {handleBlockStr += ' <span class="attr-name">' + subBlockStr.slice(0, eIndex) +'</span>' + subBlockStr.slice(eIndex);} else {handleBlockStr += subBlockStr;}}// console.log(sliceBlockStr);const blockEndIndexB = handleBlockStr.indexOf(' ');const blockEndIndexR = handleBlockStr.indexOf('&gt;');// Handle XMLTagif (blockEndIndexB === -1 && blockEndIndexR === -1) {continue;}const endBlockFlag = handleBlockStr[0] === '/';if (blockEndIndexR !== -1) {handleBlockStr += '<br>'}if (blockEndIndexR < blockEndIndexB) {returnBlockStr = '&lt;' + (endBlockFlag ? '/' : '') + '<span class="block-name">' + handleBlockStr.slice(endBlockFlag ? 1 : 0, blockEndIndexR) + '</span>' + handleBlockStr.slice(blockEndIndexR);} else if (blockEndIndexB !== -1) {returnBlockStr = '&lt;' + (endBlockFlag ? '/' : '') +'<span class="block-name">' + handleBlockStr.slice(endBlockFlag ? 1 : 0, blockEndIndexB) + '</span>' + handleBlockStr.slice(blockEndIndexB);} else if (blockEndIndexR !== -1) {returnBlockStr = '&lt;' + (endBlockFlag ? '/' : '') + '<span class="block-name">' + handleBlockStr.slice(endBlockFlag ? 1 : 0, blockEndIndexR) + '</span>' + handleBlockStr.slice(blockEndIndexR);}rerurnXml += returnBlockStr;}return rerurnXml;
}var escapeMarkup = function(dangerousInput) {const dangerousString = String(dangerousInput);const matchHtmlRegExp = /["'&<>]/;const match = matchHtmlRegExp.exec(dangerousString);if (!match) {return dangerousInput;}const encodedSymbolMap = {'"': '&quot;','\'': '&#39;','&': '&amp;','<': '&lt;','>': '&gt;'};const dangerousCharacters = dangerousString.split('');const safeCharacters = dangerousCharacters.map(function (character) {return encodedSymbolMap[character] || character;});const safeString = safeCharacters.join('');return safeString;
}module.exports = {handleDecodedXML,escapeMarkup
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/600218.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

二叉树层次建树

#include <stdio.h> #include <stdlib.h>typedef char BiElemType; typedef struct BiTNode {BiElemType data;struct BiTNode *lChild;struct BiTNode *rChild;//左右节点 } BiTNode, *BiTree; //辅助队列 typedef struct tag {BiTree p;//树的某一个节点&#xf…

Python基础知识总结2——python中的字符串

python字符串 字符串基本特点空字符串和len()函数转义字符字符串拼接字符串复制不换行打印从控制台读取字符串replace() 实现字符串替换str()实现数字转型字符串使用[]提取字符字符串切片slice操作split()分割和join()合并字符串驻留机制和字符串比较字符串比较和同一性成员操作…

如何使用 Python 解决网络抓取中的 reCAPTCHA 问题

在网络抓取的领域&#xff0c;开发人员经常面临 reCAPTCHA 的障碍。为了区分人类和自动化机器人&#xff0c;reCAPTCHA 可能会成为那些试图从网站提取数据的人的沉痛阻碍。然而&#xff0c;借助 Python 和像 Capsolver 这样的工具&#xff0c;可以绕过 reCAPTCHA 并继续抓取有价…

shell 获取主机IP 脚本中使用IP 打印出来IP

目录 查看ip查看网关只查看ens33过滤ip拿到网卡名字对内容进行切片获取第一网卡IP &#xff08;head -1 表示第一个网卡&#xff09;脚本中打印IP 查看ip ip a 查看网关 ip r只查看ens33 ip a show dev ens33过滤ip ip a | grep -oE [0-9]\.[0-9]\.[0-9]\.[0-9] 拿到网卡名…

SQL的联合主键

在SQL中&#xff0c;联合主键是指由多个列组成的主键。联合主键的作用是确保每一行数据的唯一性&#xff0c;即组合列的值必须唯一。可以使用以下语法定义联合主键&#xff1a; CREATE TABLE 表名 (列1 数据类型,列2 数据类型,列3 数据类型,...PRIMARY KEY (列1, 列2, 列3, ..…

扩展 apiserver 连接认证 ip, apiserver证书更新

本文来自我的博客地址 文章目录 问题场景:问题分析:问题解决:查看 apiserver 证书支持的 ip 或 host使用 openssl 生成证书:再次查看 apiserver 证书支持的 ip 或 host 再次尝试将 master 加点加入参考 问题场景: k8s 1.28.1 集群后期新增 vip apiserver 证书不支持 vip 引入…

图像分割实战-系列教程11:U2NET显著性检测实战3

&#x1f341;&#x1f341;&#x1f341;图像分割实战-系列教程 总目录 有任何问题欢迎在下面留言 本篇文章的代码运行界面均在Pycharm中进行 本篇文章配套的代码资源已经上传 U2NET显著性检测实战1 U2NET显著性检测实战2 U2NET显著性检测实战3 6、上采样操作与REBNCONV def…

JS/JQ实现小程序/H5验证码页面

话不多说&#xff0c;先上效果图 核心代码 1、html/css关键代码 <div class"obtain-verification-code"><div class"obtain-verification-code-input-content"><input id"input-0" class"verification-code-input" m…

Spring Data Jpa 使用EntityManager执行SQL操作数据

使用EntityManager执行原生SQL语句可以通过createNativeQuery方法实现。以下是一个简单的例子&#xff0c;演示如何使用EntityManager执行SQL语句进行数据库操作。 import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.trans…

Java学习笔记(四)——正则表达式

文章目录 正则表达式基本规则字符类(只匹配一个字符)预定义字符(只匹配一个字符)数量词练习正则表达式插件 爬虫利用正则表达式获取想要的内容爬取网络信息练习有条件的爬取贪婪爬取非贪婪爬取正则表达式在字符串中的使用 分组捕获分组正则表达式外部使用非捕获分组正则表达式忽…

MobaXterm SSH 免密登录配置

文章目录 1.简介2.SSH 免密登录配置第一步&#xff1a;点击 Session第二步&#xff1a;选择 SSH第三步&#xff1a;输入服务器地址与用户名第四步&#xff1a;设置会话名称第五步&#xff1a;点击 OK 并输入密码 3.密码管理4.小结参考文献 1.简介 MobaXterm 是一个功能强大的终…

智能座舱的下一个价值“爆点”——让“光”更智能

汽车智能化快速升级&#xff0c;智能座舱作为人机交互的主要窗口&#xff0c;交互模态、用户体验也呈现多维度升级。 例如&#xff0c;今年下半年上市的多款高端智能车型纷纷基于高性能座舱硬件平台&#xff0c;集成了AR-HUD、DMS/OMS等高阶功能&#xff0c;同时结合超大屏/多…

Transformer 的双向编码器表示 (BERT)

一、说明 本文介绍语言句法中&#xff0c;最可能的单词填空在self-attention的表现形式&#xff0c;以及内部原理的介绍。 二、关于本文概述 在我之前的博客中&#xff0c;我们研究了关于生成式预训练 Transformer 的完整概述&#xff0c;关于生成式预训练 Transformer (GPT) 的…

VMware ESXI 8 安装ipmitool 调整戴尔服务器风扇转速

本文内容适合ESXI 8版本安装ipmitool &#xff0c;进行管理&#xff0c;已知的是8.0以上版本无法安装社区的vib.所以需要自己编译文件&#xff0c;7.0及之前的版本可以安装vib版本的ipmtools。 一、编译好的适用于esxi8的ipmitool下载 ipmitool下载 二、安装ipmitool 1、开…

基于spark的Hive2Pg数据同步组件

一、背景 Hive中的数据需要同步到pg供在线使用&#xff0c;通常sqoop具有数据同步的功能&#xff0c;但是sqoop具有一定的问题&#xff0c;比如对数据的切分碰到数据字段存在异常的情况下&#xff0c;数据字段的空值率高、数据字段重复太多&#xff0c;影响sqoop的分区策略&…

软件工程:数据流图相关知识和多实例分析

目录 一、数据流图相关知识 1. 基本介绍 2. 常用符号 3. 附加符号 二、数据流图实例分析 1. 活期存取款业务处理系统 2. 工资计算系统 3. 商业自动化系统 4. 学校人事管理系统 5. 教材征订系统 6. 高考录取统分子系统 7. 订货系统 8. 培训中心管理系统 9. 考务处…

​已解决java.lang.ArrayIndexOutOfBoundsException异常的正确解决方法,亲测有效!!!​

已解决java.lang.ArrayIndexOutOfBoundsException异常的正确解决方法&#xff0c;亲测有效&#xff01;&#xff01;&#xff01; 目录 报错问题 解决思路 解决方法 总结 Q1 - 报错问题 java.long.ArrayIndexOutOfBoundsException 是Java中的一个运行时异常​&#xff0c…

强化学习5——动态规划初探

动态规划具体指的是在某些复杂问题中&#xff0c;将问题转化为若干个子问题&#xff0c;并在求解每个子问题的过程中保存已经求解的结果&#xff0c;以便后续使用。实际上动态规划更像是一种通用的思路&#xff0c;而不是具体某个算法。 在强化学习中&#xff0c;被用于求解值函…

【网络工程师】交换机的配置

一、交换机5大基本工作模式 配置网络设备&#xff0c;需要使用console线&#xff0c;在PC上需要使用软件 “超级终端” 1、用户模式&#xff1a;switch> 可以查看交换机的额基本简单信息&#xff0c;且不能做任何修改配置&#xff01; 2、特权模式&#xff1a;switch## …

在使用Composer管理的项目中安装和使用

在使用Composer管理的项目中安装 如果项目框架本身就是使用Composer来管理包的话&#xff0c;直接在项目根目录执行Composer安装命令后&#xff0c;即可在项目控制器中调用QueryList来使用&#xff0c;这种框架有&#xff1a; Laravel、ThinkPHP5等。 在项目根目录执行compo…