【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>
相关推荐
雪芽蓝域zzs8 小时前
uniapp 国密sm2加密
uni-app
云天徽上11 小时前
【PaddleOCR】OCR表格识别数据集介绍,包含PubTabNet、好未来表格识别、WTW中文场景表格等数据,持续更新中......
python·ocr·文字识别·表格识别·paddleocr·pp-ocrv5
打不着的大喇叭18 小时前
uniapp的光标跟随和打字机效果
前端·javascript·uni-app
zengzehui18 小时前
uniapp启动图被拉伸问题
uni-app
iOS阿玮21 小时前
AppStore教你一招免备案的骚操作!
uni-app·app·apple
Imagine Miracle1 天前
Ubuntu for ARM 更换为阿里云镜像源
arm开发·ubuntu·阿里云
draymond71071 天前
阿里云-云效自动部署spring boot项目
阿里云
ModyQyW2 天前
用 AI 驱动 wot-design-uni 开发小程序
前端·uni-app
我是小bā吖2 天前
阿里云服务网格ASM实践
网络·阿里云·云计算·服务发现
lxsy2 天前
spring-ai-alibaba 1.0.0.2 学习(七)——集成阿里云百炼平台知识库
学习·spring·阿里云·spring-ai·ai-alibaba