【uniapp】调用阿里云OCR图片识别文字:

文章目录


一、效果:
二、实现:

【阿里官方】高精版OCR文字识别【最新版】-云市场-阿里云

javascript 复制代码
<template>
	<view class="container">
		<!-- 选择图片 -->
		<button @click="imageOcrRecognition">选择图片</button>
		<view v-html="content"></view>
	</view>
</template>
  
<script>
	import { pathToBase64, base64ToPath } from 'image-tools'//npm i image-tools --save

	export default {
		data() {
			return {
				content: '',
			}
		},
    methods: {
			imageOcrRecognition() {
				const that = this;
				uni.chooseImage({
          count: 1,
					sizeType: ['original', 'compressed'],
					sourceType: ['album', 'camera'],
          success: (res) => {
						pathToBase64(res.tempFilePaths[0]).then(base64 => {
							uni.request({
								url: 'https://gjbsb.market.alicloudapi.com/ocrserve/advanced',
                dataType: 'json',
                header: {
									'Authorization': `APPCODE 你的AppCode`
                },
								data: { img: base64.substring(base64.indexOf(',') + 1) },
                method: 'POST',
								success(res) {
                  console.log(res);
									that.content = res.data.content;
								}
							})
            })
					}
				})
      },
		},
	}
</script>
相关推荐
楚识科技1 天前
手写OCR工程接入实录:图像预处理、后处理校验与置信度分层的完整链路
人工智能·计算机视觉·ocr
bug总结1 天前
uniapp vue3全局方法注册使用
前端·javascript·uni-app
大佐不会说日语~1 天前
Android 16 下 uni-app APP 提示“网络连接失败”的排障与修复
android·uni-app
2501_915106321 天前
苹果App Store上架费用及流程全面解析
android·ios·小程序·https·uni-app·iphone·webview
知行EDI1 天前
知行之桥 S3 端口或归档中配置阿里云 OSS 使用指南
阿里云·edi·oss·s3
白远山1 天前
家政服务派单平台搭建实战指南:从需求分析到系统设计全流程解析
java·开发语言·架构·uni-app·需求分析
2501_930472441 天前
上云迁移验收-CVM健康校验用例与数据库比对报告
数据库·人工智能·阿里云·云计算·腾讯云
宸翰2 天前
解决uni-app 中 SVG 图片在 iOS 端显示模糊问题
前端·uni-app
走到天涯海角2 天前
uniApp蓝牙在手机上测试
智能手机·uni-app
悟乙己2 天前
逛逛阿里云 官方Skills 门户
阿里云·云计算