【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 小时前
小程序学习(十一)之uni-app和原生小程序开发区别
学习·小程序·uni-app
秋氘渔4 小时前
使用Ollama部署DeepSeek-OCR模型:从零开始的完整指南
ocr·ollama·deepseek-ocr
weixin_462446234 小时前
DeepSeek-OCR:下一代智能文档识别与转换技术详解(复杂表格精准解析)
ocr·deepseek-ocr
Json____5 小时前
使用uni-app开发抖音小程序遇到previewImage方法图片加载不出来解决方案
小程序·uni-app
Jyywww1216 小时前
Uniapp+Vue3 使用父传子方法实现自定义tabBar
javascript·vue.js·uni-app
jingxun1237 小时前
珲春好吃的烤肉
阿里云
山顶夕景18 小时前
【VLM】Format Decoupled Reinforcement Learning for Document OCR
大模型·llm·ocr·多模态·文档智能·vlm
顾北121 天前
阿里百炼AI大模型接入指南
阿里云·ai编程
2501_916008891 天前
iOS开发APP上架全流程解析:从开发到App Store的完整指南
android·ios·小程序·https·uni-app·iphone·webview
酷酷的鱼1 天前
2026 跨平台开发终极选型:Flutter, React Native 与 uni-app x 深度博标与规划指南
flutter·react native·uni-app