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

贝因美大框识别参数

上级 4081030f
......@@ -75,56 +75,93 @@ Page({
src: res.tempFilePath
})
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',
data: {
base: base,
labelCodejson: 'BeiyinmeiAi'
base
},
success: async (result) => {
if (result.data.codeinfo) {
console.log('识别二维码成功',result.data.codeinfo,result);
// 原图(默认放大两倍)
const photo1 = await that.handleTakePoto(wx.createCameraContext(), 1)
// 放大图(四倍)
// await new Promise((resovle) => {
// setTimeout(() => {
// resovle()
// },300)
// })
console.log('5555');
const photo2 = await that.handleTakePoto(wx.createCameraContext(), 4, {
flash: 'on'
success: async (_res) => {
try {
var result = _res.data.result
var coord = _res.data.coord[0][5]
console.log('coord', coord)
var minindex = -1
var mindistance = 2
for (var i = 0; i < result.length; i++) {
var sublist = result[i]
var distance =
Math.abs(sublist[0] - 0.5) +
Math.abs(sublist[1] - 0.5)
if (distance < mindistance) {
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');
// 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
})
let state = ''
let status = ''
let state_x = ''
console.log(888888888);
if (result_zy > 0.588 || result_zy < 0.405 || result_sx > 0.577 || result_sx < 0.401) {
console.log(666666);
tag = true
wx.showToast({
title: '请把识别二维码对准拍照框',
})
} else {
console.log('识别二维码成功');
// 原图(默认放大两倍)
const photo1 = await that.handleTakePoto(wx.createCameraContext(), 1)
// 放大图(四倍)
// await new Promise((resovle) => {
// setTimeout(() => {
// resovle()
// },300)
// })
console.log('5555');
const photo2 = await that.handleTakePoto(wx.createCameraContext(), 4, {
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
wx.showToast({
title: '请把识别二维码对准拍照框',
})
}
},
fail(err) {
tag = true
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论