当前位置: 首页 > news >正文

wordpress电子书下载地址南宁seo主管

wordpress电子书下载地址,南宁seo主管,在越南做网站需要什么,本地wordpress 上传到服务器uniapp编写微信小程序调用百度OCR 公司有一个识别行驶证需求,调用百度ocr识别 使用了image-tools这个插件,因为百度ocr接口用图片的base64 这里只是简单演示,accesstoken获取接口还是要放在服务器端,不然就暴露了自己的百度项目k…

uniapp编写微信小程序调用百度OCR
公司有一个识别行驶证需求,调用百度ocr识别
使用了image-tools这个插件,因为百度ocr接口用图片的base64
在这里插入图片描述
这里只是简单演示,accesstoken获取接口还是要放在服务器端,不然就暴露了自己的百度项目key

代码我使用了这个博主的代码
https://blog.csdn.net/sjt1010/article/details/108272945

还有需要将百度接口的地址加到微信公众平台,开发管理的服务器域名里

<template><view class="cheliangjinchudengji-index"><view><button type="primary" @click="chooseImg">行驶证拍照识别</button><view style="margin-left:10px ;" v-if="imgList.length > 0"><view v-for="(item,index) in imgList" :key="index"><image :src="item" mode=""></image></view></view><!-- <button type="primary" @click="getBaiduToken">token</button> --><view v-for="item of cardatas" :key="item"><view>{{item}}</view></view></view></view>
</template><script>import { pathToBase64, base64ToPath } from '../../js_sdk/mmmm-image-tools/index.js'import { fetchBaiduOCRDatas  } from '../../utils/basePath';export default {data() {return {imgList: [],token:'',cardatas:{chepai:'',xinghao:''}}},methods: {chooseImg(){let that = this;that.getBaiduToken();uni.chooseImage({success: (chooseImageRes) => {const tempFilePaths = chooseImageRes.tempFilePaths;// #ifdef MP-WEIXINuni.getFileSystemManager().readFile({filePath: tempFilePaths[0],encoding: 'base64',success: r => { console.log(r.data)let base64 = 'data:image/jpeg;base64,'  + r.data;that.imgList.push(base64)that.postBaiduOcr(base64);}})// #endif// // #ifdef APP-PLUS// pathToBase64(tempFilePaths[0])//   .then(base64 => {// 	that.imgList.push(base64)//   })//   .catch(error => {// 	console.error(error)//   })// // #endif}});},postBaiduOcr(imgbase64){let that = this;let accessToken = that.token;fetchBaiduOCRDatas("https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license?access_token="+accessToken, {"image":imgbase64} , {'content-type': 'application/x-www-form-urlencoded'}, "POST", res=>{if(res.statusCode=='200' || res.statusCode==200){uni.showToast({type: 'success',title: 'OCR成功!',icon: 'none',duration:3000});that.cardatas.chepai = res.data.words_result.号牌号码.words;that.cardatas.xinghao = res.data.words_result.品牌型号.words;}else{uni.showToast({type: 'error',title:  res.data.error_description,icon: 'none',duration:3000});}})},getBaiduToken(){fetchBaiduOCRDatas("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=xxxx&client_secret=xxxx", {}, {'Content-Type': 'application/json', 'Accept': 'application/json'}, "POST", res=>{if(res.statusCode=='200' || res.statusCode==200){uni.showToast({type: 'success',title: 'token获取成功!',icon: 'none',duration:3000});this.token = res.data.access_token	}else{uni.showToast({type: 'error',title: res.data.error_description,icon: 'none',duration:3000});}})},}}
</script><style></style>
const fetchBaiduOCRDatas = (url, data, header, method, callback, errCallback)=>{// let token = uni.getStorageSync('token');uni.request({url: url,data: data,method:method,header: header,// {//      'content-type': 'application/x-www-form-urlencoded'//    },success (res) {uni.hideLoading();callback(res);}})
}

在这里插入图片描述
这个行驶证图片是百度开发平台提供的图片

有些人可能有base64传后台需求,但是拍照内存太大需要压缩,加一下压缩图片再转base64代码

chooseImg(){let that = this;that.getBaiduToken();uni.chooseImage({// sizeType: ['compressed'],success: (chooseImageRes) => {const tempFilePaths = chooseImageRes.tempFilePaths;// 压缩uni.compressImage({src: tempFilePaths[0],quality: 0.1,success: res => {uni.getFileSystemManager().readFile({filePath: res.tempFilePath,encoding: 'base64',success: r => { let base64 = 'data:image/jpeg;base64,'  + r.data;that.imgList.push(base64)that.postBaiduOcr(base64);console.log(`压缩111:${base64.length}KB`)}})}})}});
},
http://www.yayakq.cn/news/886737/

相关文章:

  • 网站升级对外解决方案做美食视频的网站
  • 登陆国外网站速度慢长沙房产网最新楼盘
  • 网站维护具体工作内容中国企业信用信息查询网官网
  • 山东省建设厅定额网站童装 技术支持 东莞网站建设
  • 国外对网站开发的研究wordpress woo插件
  • 网站建设的优势网页设计图片居中怎么设置
  • 学做西餐的网站公司广告牌制作
  • 公司建设网站费用属于什么费用吗企业网络推广电话
  • 龙岗网站设计市场电子元器件做哪个网站好
  • 顶呱呱网站建设衡水林熠网站建设公司
  • 网站建设哪家最专业wordpress评论区插件
  • 黔东南购物网站开发设计wordpress运行导入器
  • 发布网站建设需求的经验美工零基础的从哪开始学
  • 朔州网站建设公司上海营销型网站制作
  • 甘肃临夏州建设局网站做搜狗网站排名软件
  • 高明铝业网站建站荆州网站建设多少钱
  • 红酒企业网站模板自己做的网站服务器在哪里
  • linux可以做网站开发吗网站建设公司排名深圳
  • 昆明cms模板建站房山青岛网站建设
  • 网站策划编辑的职责合肥城乡建设网站
  • 个人网站备案核验单网站开发作业代做
  • 网站响应式好吗wordpress禁用前台代码编辑器
  • 企业网站推广 知乎h5和网站的区别
  • 政务网站无障碍建设网站建设推广 公司
  • 沈阳软件公司 网站制作公司网页建立
  • 中国建设银行的网站eclipse开发安卓app
  • 上海哪家做网站资兴市网站建设哪个好
  • 网站建设需要哪些功能php做网站需要啥技术
  • 多人运动免费正能量网站链接网站上的支付接口怎么做
  • 北京学设计去哪个网站好jsp网站开发的使用表格