【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>
相关推荐
AI人工智能+13 分钟前
药品经营许可证识别技术,融合计算机视觉、自然语言处理和知识图谱,保障药品供应链安全,助力构建智慧药监体系。
深度学习·ocr·药品经营许可证识别
BIGmustang39 分钟前
ACK的集群日志接入及ARMS的应用性能监控及主机监控(云监控)
阿里云·云原生
小杨小杨、努力变强!2 小时前
VS Code运行HBuilder X中的uni-app项目
vscode·uni-app·uni-app run
码兄科技11 小时前
实战:基于Spring Boot + UniApp的地理信息小程序开发
spring boot·后端·uni-app
AI人工智能+20 小时前
智能文档抽取系统采用“解析底座+大模型“双引擎架构,突破传统OCR局限
深度学习·ocr·文档抽取
蓝创工坊Blue Foundry1 天前
图片文字提取到 Excel:批量任务如何先定义要交付的字段
运维·服务器·开发语言·数据库·自动化·ocr·excel
陈天伟教授1 天前
华为云 阿里云 腾讯 WorkBuddy的工具对比
阿里云·华为云·云计算
2501_916007471 天前
iOS和macOS应用程序性能分析和优化工具使用综合指南
android·macos·ios·小程序·uni-app·iphone·webview
求真学习1 天前
智谱联合清华开源GLM-OCR,0.9B参数配MTP多Token预测,文档解析吞吐量1.86页/秒,印章识别90.5分,第二名才42.2分
ocr·pdf解析·glm·文档解析·智谱
Database_Cool_1 天前
阿里云 Tair(企业级内存数据库)vs AWS ElastiCache 内存数据库选型对比:性能/成本/合规全维度 Benchmark
数据库·阿里云