【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>
相关推荐
AC赳赳老秦1 小时前
OpenClaw阿里云部署实操:多Agent协同,打造云端自动化工作流
人工智能·阿里云·数据挖掘·自动化·云计算·deepseek·openclaw
橘子编程1 小时前
UniApp跨端开发终极指南
开发语言·vue.js·uni-app
白狐_7983 小时前
我的第一台云服务器:阿里云 ECS 配置记录,以及本地连接后到底能做什么
运维·服务器·阿里云
handsomestWei1 天前
百度飞桨PaddleOCR图片印章检测技术简介
人工智能·百度·ocr·paddlepaddle·红色印章
Database_Cool_2 天前
OpenClaw-Observability:基于 DuckDB 构建 OpenClaw 的全链路可观测体系
数据库·阿里云·ai
s听风忆雪2 天前
aliyun 阿里云服务器 mysql 开启安全组 3306 依然访问不了
服务器·安全·阿里云
stereohomology2 天前
光荣梦想:大模型图片OCR中文识别对比 Qwen3.6plus强
ocr
叱咤少帅(少帅)2 天前
Uniapp开发pc端,小程序和APK
小程序·uni-app
测试开发技术2 天前
自动生成用例:基于OCR+ LLM的设计方案(附落地指南)
自动化测试·软件测试·自动化·llm·ocr·测试用例·用例自动生成
2501_915918413 天前
iOS性能测试工具 Instruments、Keymob的使用方法 不局限 FPS
android·ios·小程序·https·uni-app·iphone·webview