【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>
相关推荐
Henry-SAP2 小时前
阿里云大模型份额居首
阿里云·云计算
孙琦Ray5 小时前
百度开源 Unlimited OCR 2:百页文档单请求解析,竞品得分仅其四成
百度·ocr·开源模型·unlimited ocr 2·长文档解析·sr-swa
Elastic 中国社区官方博客8 小时前
基于 Jina OCR v1 与 Elasticsearch 的 PDF 智能混合检索与 RAG 系统实战指南
大数据·数据库·elasticsearch·搜索引擎·ocr·jina
楚识科技8 小时前
信创环境下 OCR 部署实践:从麒麟系统到达梦数据库的全栈适配
数据库·ocr
yyuuuzz1 天前
云服务器安全组规则优先级的机制记录
运维·服务器·网络·安全·阿里云·aws
CHB1 天前
别再问uni-app x蒸汽模式是否成熟了,已经有大量App案例上架应用商店了
uni-app
斯维赤1 天前
OCR到底是接入第三方API 还是自己封装?
java·ocr
云-缩影1 天前
我用阿里云 AI 动画方案跑通了剧本→视频流水线:ComfyUI + 百炼模型实测
人工智能·阿里云·云计算
weixin_403810131 天前
EasyClick苹果群控脚本USBHID技术配合OCR滑动短视频
ocr