提交 313080e6 authored 作者: 常超凡's avatar 常超凡

新的提交

上级 06316cc9
......@@ -22,71 +22,12 @@ Page({
onLoad(options) {
this.cameraContext = wx.createCameraContext()
this.cameraContext.setZoom({
zoom: 2
zoom: 1
})
this.cameraFrame()
// this.cameraFrameApi()
},
// 视频流(后端校验二维码)
cameraFrameApi() {
let flag = true
const that = this
const listener = this.cameraContext.onCameraFrame((frame) => {
if (flag) {
flag = false
that.setData({
width: frame.width,
height: frame.height,
})
wx.canvasPutImageData({
canvasId: 'myCanvas',
width: frame.width,
height: frame.height,
data: new Uint8ClampedArray(frame.data),
success(rew) {
console.log(rew, 99);
wx.canvasToTempFilePath({
canvasId: 'myCanvas',
x: frame.width / 2 - 150,
y: frame.height / 2 - 150,
width: 300,
height: 300,
destWidth: 300,
destHeight: 300,
quality: 'high',
fileType: 'jpg',
success(path) {
console.log(path.tempFilePath, 66);
const base = wx.getFileSystemManager().readFileSync(path.tempFilePath, 'base64')
that.setData({
src: 'data:image/jpeg;base64,' + base
})
wx.request({
url: 'https://ai.tj5.cc:35437/object/',
method: "POST",
data: {
base
},
success(g) {
console.log(g, 'cccc');
flag = true
}
})
},
fail(rr) {
console.log(rr, 5555);
}
})
},
fail(err) {
console.log(err);
}
})
}
})
listener.start()
},
// 视频流(前端判断二维码)
cameraFrame() {
......@@ -101,7 +42,7 @@ Page({
await wx.canvasPutImageData({
canvasId: 'myCanvas',
x:0,
y:0,
y:-frame.height/5,
width: frame.width,
height: frame.height,
data: new Uint8ClampedArray(frame.data),
......@@ -117,19 +58,22 @@ Page({
})
const base = fileSystem.readFileSync(fileData.tempFilePath, 'base64')
const qr_result = await that.handleCodeAnalysis(base)
console.log('qr_result',flag,5555,qr_result.data.codeinfo);
// 前端校验取消
// const data = new Uint8ClampedArray(frame.data);
// // const nData = data.slice(data.length / 4, data.length / 4 * 3)
// const qr_result = qrcode.decodefrank(frame.width, frame.height, data)
if (qr_result?.codeinfo) {
// console.log('qe_result',qr_result)
// console.log('qr_result.data.codeinfo',qr_result.data.codeinfo)
if (qr_result.data.codeinfo) {
that.setData({
height: frame.height,
width: frame.width
})
// 原图(默认放大两倍)
const photo1 = await that.handleTakePoto()
const photo1 = await that.handleTakePoto(that.cameraContext, 1)
// 放大图(四倍)
const photo2 = await that.handleTakePoto(that.cameraContext, 4)
const photo2 = await that.handleTakePoto(that.cameraContext, 4,{flash:'on'})
// 原图base64
const base64_1 = fileSystem.readFileSync(photo1.tempImagePath, 'base64')
......@@ -151,7 +95,9 @@ Page({
})
})
} else {
flag = true
setTimeout(() => {
flag = true
},750)
}
}
......@@ -161,6 +107,7 @@ Page({
// 后端接口解析二维码
handleCodeAnalysis(base64) {
// console.log('base',base64)
return new Promise((resolve, reject) => {
wx.request({
url: 'https://www.7856.work:4433/api/Bym_upload/',
......@@ -185,6 +132,7 @@ Page({
zoom
})
return await context.takePhoto({
flash:param?.flash || 'off',
quality: param?.quality || 'high',
selfieMirror: param?.selfieMirror || false,
})
......
<!--pages/beiyinmei/beiyinmei.wxml-->
<view wx:if="{{!showPage}}" style="height: 100vh;width: 100vw;position: relative;z-index: 99;">
<camera device-position="back" frame-size="medium" flash="off" style="width: 100%; height: 100%;" mode="normal">
<camera device-position="back" frame-size="medium" flash="auto" style="width: 100%; height: 100%;" mode="normal">
<view class="prompt">
<image src="/assets/imgs/拍照框.png" style="width: 40%;" mode="widthFix" />
<image src="/assets/imgs/拍照框.png" style="width: 25%;" mode="widthFix" />
<text>请把二维码放置拍照框内</text>
</view>
</camera>
......@@ -23,6 +23,6 @@
</view>
</view>
<view style="visibility: hidden;position: fixed;top: 9999px;left: 0px;">
<view style="visibility: hidden;position: fixed;top: 99999px;left: 0px;">
<canvas canvas-id="myCanvas" id="myCanvas" style="width:400px;height: 400px;" />
</view>
......@@ -48,7 +48,7 @@
</camera>
<view class="content">
<text style='font-size:34rpx'>请将识别框对准结构三维码</text>
<image src="/assets/imgs/拍照框.png" mode="widthFix" style="margin:100rpx 0; width: 50%;"/>
<image src="/assets/imgs/拍照框.png" mode="widthFix" style="margin:75rpx 0; width: 35%;"/>
<view class="progress-box">
<text >请保持结构三维码在识别框内等待进度条完成</text>
<progress percent="{{progressNumber}}" active stroke-width="10" show-info color="#0270FF" border-radius='100' active-mode='forwards' style="margin-top: 20rpx;"/>
......
......@@ -18,6 +18,7 @@
<view class="btns">
<image bindtap="takePhoto" src="https://ai.tj5.cc:35437/static/fenggu/comerz.png" mode="widthFix" style="width: 50%;" />
<view class="btn video-btn" bind:tap="handleOpenVideo">查看视频教程</view>
<navigator class="btn video-btn" open-type="exit" target="miniProgram">点击按钮返回主页</navigator>
</view>
<!-- 底部文字 -->
......
......@@ -8,21 +8,25 @@ Page({
aiState: 0, //展示成功或失败页面,
time1: '', //本次认证时间
time2: '', //认证耗时
bg_color:''
bg_color:'',
Labeldiff:0 //展示码不同页面
},
onLoad(options) {
const {
aiState,
time1,
time2
time2,
Labeldiff
} = options
console.log(options,time1);
// console.log(options,time1);
console.log('options.Labeldiff',options.Labeldiff)
this.setData({
aiState: aiState || 0,
time1: time1 || '',
time2: time2 && (new Date().getTime() - time2) / 1000 || '',
bg_color: getApp().page_bg
bg_color: getApp().page_bg,
Labeldiff:Labeldiff || 0
})
},
// 返回首页
......
......@@ -15,6 +15,19 @@
</view>
<image src="/assets/imgs/验证成功底部.png" mode="widthFix" style="width: 100%;" />
</view>
<!-- 码不同页面 -->
<view wx:if="{{Labeldiff == 1 }}" class="error-content full">
<view class="content-text">
<image src="/assets/imgs/未通过.png" mode="widthFix" style="width: 30%;" />
<text style="margin: 40rpx 0;font-size: 34rpx;font-weight: 700;">码不同,不是同一枚标签!</text>
<view style="padding:0 60rpx; text-align: center;font-size: 30rpx;line-height: 48rpx;">请使用同一枚标签进行认证,请保证相机稳定,检查标签码是否有破损,并前往光照适宜的环境进行验证</view>
<view class="btns" >
<view class="btn" bind:tap="handleGoTakePhoto">重新验证</view>
<view class="btn" bind:tap="handleOpenVideo">继续查看视频教程</view>
</view>
</view>
<image src="/assets/imgs/验证成功底部.png" mode="widthFix" style="width: 100%;" />
</view>
<!-- 验证失败页面 -->
<view wx:else class="error-content full">
<view class="content-text">
......
......@@ -25,6 +25,7 @@ Page({
openid: '',
aiState: 0,
sameCodeState: 0,
Labeldiff:0,
filePath: '',
datajson: '',
labelCodejson: '',
......@@ -321,32 +322,33 @@ Page({
const base = wx.getFileSystemManager().readFileSync(this.data.filePath, 'base64')
//增加不需要进行码判断
this.checkAiResult(base);
// this.checkAiResult(base);
// console.log('base', base)
// if (this.data.labelCode) {
// // console.log('开始检查标签相似')
// this.checkIsSameCode(base, (state) => {
// this.setData({
// sameCodeState: state
// })
// if (state === 1) {
// this.checkAiResult(base);
// } else {
// this.setData({
// isLoading: false,
// })
// }
// })
// console.log("sameCodeState", this.data.sameCodeState)
// } else {
// console.log('进入不需要检查标签相似')
// this.setData({
// sameCodeState: 1,
// userimage: false,
// userinfo_name: false
// })
// this.checkAiResult(base);
// }
//判断标签序号
if (this.data.labelCode) {
// console.log('开始检查标签相似')
this.checkIsSameCode(base, (state) => {
this.setData({
sameCodeState: state
})
if (state === 1) {
this.checkAiResult(base);
} else {
this.setData({
isLoading: false,
})
}
})
console.log("sameCodeState", this.data.sameCodeState)
} else {
console.log('进入不需要检查标签相似')
this.setData({
sameCodeState: 1,
userimage: false,
userinfo_name: false
})
this.checkAiResult(base);
}
},
//检查标签是否相同
checkIsSameCode(base, cb) {
......@@ -464,6 +466,7 @@ Page({
});
} else {
console.log('码不同')
const Labeldiff = 1
cb(0);
// console.log('码不同', this.data.sameCodeState)
const dtime2 = util.formatTime(new Date());
......@@ -506,6 +509,10 @@ Page({
},
success: (res) => {
console.log('all入库成功', res);
wx.reLaunch({
url: `/pages/result/result?Labeldiff=${Labeldiff}`
})
return
},
fail: (error) => {
console.log('入库失败', error);
......@@ -739,17 +746,18 @@ Page({
// url:'https://www.7856.work:4433/api/classify16/',
method: 'POST',
data: {
'image_type': 20,
'image_type': 50,
'base': base,
},
success: (res) => {
console.log('base',base)
console.log('打印分类接口返回数据res.data', res.data)
let imagefile = res.data.image_path
const classScore = res.data.result
const max_score = Math.max.apply(null, res.data.confidence)
const max_score_value = max_score.toFixed(3)
const Score_list = res.data.confidence
// console.log('Score_list', Score_list)
console.log('Score_list', Score_list)
for (var i = 0; i < Score_list.length; i++) {
Score_list[i] = Score_list[i].toFixed(3);
}
......@@ -931,7 +939,7 @@ Page({
key: 'notice',
data: notice
})
console.log('notice调用人工服务',notice)
console.log('notice结果展示',notice)
if (notice != '手机边框') {
if (aiState !== 1) {
Count++;
......@@ -1223,7 +1231,7 @@ Page({
// 跳转到结果页面
wx.reLaunch({
url: `/pages/result/result?time1=${util.formatTime(new Date()) || this.data.people_time}&time2=${new Date().getTime()}&aiState=${aiState}`
url: `/pages/result/result?time1=${util.formatTime(new Date()) || this.data.people_time}&time2=${new Date().getTime()}&aiState=${aiState}&Labeldiff=${this.dataLabeldiff}`
})
return
},
......
......@@ -4,7 +4,7 @@
"setting": {
"compileHotReLoad": true,
"urlCheck": false,
"bigPackageSizeSupport": false
"bigPackageSizeSupport": true
},
"condition": {
"miniprogram": {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论