【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>
相关推荐
jialan758 小时前
GLM-ocr测试
ocr
予你@。9 小时前
uni-app(Vue3)实现自定义 Tab 切换滑块效果(微信小程序)
vue.js·微信小程序·uni-app
主机哥哥18 小时前
还不会部署OpenClaw?阿里云推出五种OpenClaw快速部署方案
阿里云·云计算
Re.不晚21 小时前
可视化大数据——淘宝母婴购物数据【含详细代码】
大数据·阿里云·云计算
含老司开挖掘机1 天前
Chandra OCR多格式输出详解:同页同步生成Markdown/HTML/JSON三版本
ocr·文档解析·结构化输出·chandra
HashTang1 天前
【AI 编程实战】第 11 篇:让小程序飞起来 - 性能优化实战指南
前端·uni-app·ai编程
MoMoSQL6661 天前
2026年1月国产数据库大事记:国开行2822万采购Gbase,浙商银行930万采购GoldenDB,墨天轮发布“2025年度数据库”……
数据库·阿里云·tidb·oceanbase·gaussdb
Cccp.1231 天前
【OpenCV】(十八)答题卡识别判卷与文档ocr扫描识别
人工智能·opencv·ocr
合合技术团队1 天前
零代码搭建「招标文件解析智能体」:Coze+TextIn xParse实现PDF上传自动提条款、标风险、出建议
ocr·coze·文档解析·textln