【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人工智能+7 小时前
智能文档抽取系统采用“解析底座+大模型“双引擎架构,突破传统OCR局限
深度学习·ocr·文档抽取
蓝创工坊Blue Foundry10 小时前
图片文字提取到 Excel:批量任务如何先定义要交付的字段
运维·服务器·开发语言·数据库·自动化·ocr·excel
陈天伟教授11 小时前
华为云 阿里云 腾讯 WorkBuddy的工具对比
阿里云·华为云·云计算
2501_9160074711 小时前
iOS和macOS应用程序性能分析和优化工具使用综合指南
android·macos·ios·小程序·uni-app·iphone·webview
求真学习12 小时前
智谱联合清华开源GLM-OCR,0.9B参数配MTP多Token预测,文档解析吞吐量1.86页/秒,印章识别90.5分,第二名才42.2分
ocr·pdf解析·glm·文档解析·智谱
Database_Cool_13 小时前
阿里云 Tair(企业级内存数据库)vs AWS ElastiCache 内存数据库选型对比:性能/成本/合规全维度 Benchmark
数据库·阿里云
Database_Cool_13 小时前
阿里云 Tair(企业级内存数据库)vs 腾讯云 Redis 云缓存深度对比:性能/数据结构/成本全维度 Benchmark
数据库·阿里云·缓存
Database_Cool_15 小时前
阿里云 RDS MySQL 降本增效实战:从规格选型到成本优化,月成本降低64%全攻略
mysql·阿里云·云计算
胡琦博客1 天前
HarmonyOS 智能工具箱(二):OCR 文字识别工具
华为·ocr·harmonyos
Database_Cool_1 天前
AI Agent 长期记忆怎么存?阿里云 PolarDB-X 对接 Mem0 记忆框架实践
数据库·阿里云