【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>
相关推荐
敲代码的鱼哇4 小时前
发送短信/拨打电话/获取联系人能力 UTS 插件(cz-sms)
android·前端·ios·uni-app·安卓·harmonyos·鸿蒙
code_li12 小时前
阿里云 OSS(对象存储)接入 Cloudflare 回源流量全免,每月 1 亿次免费请求
阿里云·云计算
圆山猫1 天前
[Linux] Ubuntu 26.04 换阿里云镜像源(最新方法)
linux·ubuntu·阿里云
AI人工智能+1 天前
表格识别技术:通过深度学习与计算机视觉融合,实现复杂文档中表格的版面还原及数据的结构化转换。
深度学习·计算机视觉·ocr·表格识别
阿里-于怀1 天前
【无标题】阿里云 AI 网关支持 DeepSeek V4
人工智能·阿里云·云计算·deepseek
石榴树下的七彩鱼1 天前
医疗票据OCR识别API实战:从医保结算单到结构化数据提取(附Python/Java示例)
java·人工智能·python·ocr·api·ocr识别·医疗票据识别
MY_TEUCK1 天前
【AI开发】从0到1写一个uni-app Vue3 小程序开发的Skill:用法、流程与踩坑复盘
人工智能·uni-app
雪芽蓝域zzs1 天前
uni-app x uts类转换
uni-app
新知图书1 天前
通过阿里云百炼平台调用DeepSeek大模型
人工智能·阿里云·云计算·langchian