提交 01c3433a authored 作者: 羊富学's avatar 羊富学

贝因美大框识别参数

上级 4081030f
...@@ -75,56 +75,93 @@ Page({ ...@@ -75,56 +75,93 @@ Page({
src: res.tempFilePath src: res.tempFilePath
}) })
wx.request({ wx.request({
url: 'https://www.7856.work:4433/api/Bym_upload/', url: 'https://www.7856.work:4433/clear_fuzzy_detect/', //目标检测+判断清晰模糊接口 测试地址
// url: 'https://tj5.cc:4433/object/',
// url:'https://ai.china315net.com:35437/object/',
method: 'POST', method: 'POST',
data: { data: {
base: base, base
labelCodejson: 'BeiyinmeiAi'
}, },
success: async (result) => { success: async (_res) => {
if (result.data.codeinfo) { try {
console.log('识别二维码成功',result.data.codeinfo,result); var result = _res.data.result
// 原图(默认放大两倍) var coord = _res.data.coord[0][5]
const photo1 = await that.handleTakePoto(wx.createCameraContext(), 1) console.log('coord', coord)
// 放大图(四倍) var minindex = -1
// await new Promise((resovle) => { var mindistance = 2
// setTimeout(() => { for (var i = 0; i < result.length; i++) {
// resovle() var sublist = result[i]
// },300) var distance =
// }) Math.abs(sublist[0] - 0.5) +
console.log('5555'); Math.abs(sublist[1] - 0.5)
const photo2 = await that.handleTakePoto(wx.createCameraContext(), 4, { if (distance < mindistance) {
flash: 'on' mindistance = distance
minindex = i
}
}
var result_zy = result[minindex][0]
var result_sx = result[minindex][1]
var result_w = result[minindex][2]
var result_zoom = parseFloat((0.85 / result_w).toFixed(1))
that.setData({
result_zoom: result_zoom
}) })
console.log(photo2.tempImagePath, 'photo1'); let state = ''
// this.setData({ let status = ''
// src:photo2.tempImagePath let state_x = ''
// }) console.log(888888888);
// 原图base64 if (result_zy > 0.588 || result_zy < 0.405 || result_sx > 0.577 || result_sx < 0.401) {
const base64_1 = wx console.log(666666);
.getFileSystemManager().readFileSync(photo1.tempImagePath, 'base64') tag = true
// 放大四倍图 base64 wx.showToast({
const base64_2 = wx title: '请把识别二维码对准拍照框',
.getFileSystemManager().readFileSync(photo2.tempImagePath, 'base64') })
} else {
// 请求接口 console.log('识别二维码成功');
Promise.all([that.handleApiCheck(base64_1, 'small'), that.handleApiCheck(base64_2, 'big')]) // 原图(默认放大两倍)
.then(value => { const photo1 = await that.handleTakePoto(wx.createCameraContext(), 1)
let pageType = 'error' // 放大图(四倍)
const result1 = value[0], // await new Promise((resovle) => {
result2 = value[1] // setTimeout(() => {
// data.result == 2 为真 // resovle()
if (result1.data.result == 2 && result2.data.result == 2) { // },300)
pageType = 'success' // })
} console.log('5555');
that.setData({ const photo2 = await that.handleTakePoto(wx.createCameraContext(), 4, {
showPage: pageType flash: 'on'
})
}) })
} else { console.log(photo2.tempImagePath, 'photo1');
// this.setData({
// src:photo2.tempImagePath
// })
// 原图base64
const base64_1 = wx
.getFileSystemManager().readFileSync(photo1.tempImagePath, 'base64')
// 放大四倍图 base64
const base64_2 = wx
.getFileSystemManager().readFileSync(photo2.tempImagePath, 'base64')
// 请求接口
Promise.all([that.handleApiCheck(base64_1, 'small'), that.handleApiCheck(base64_2, 'big')])
.then(value => {
let pageType = 'error'
const result1 = value[0],
result2 = value[1]
// data.result == 2 为真
if (result1.data.result == 2 && result2.data.result == 2) {
pageType = 'success'
}
that.setData({
showPage: pageType
})
})
}
} catch (error) {
tag = true tag = true
wx.showToast({
title: '请把识别二维码对准拍照框',
})
} }
}, },
fail(err) { fail(err) {
tag = true tag = true
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论