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

新的提交

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