【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>
相关推荐
聊询QQ:688238862 小时前
探索Flac二次开发之弹性应变能分析
阿里云
恶猫3 小时前
STranslate 翻译 工具 v2.0.0 绿色便携版 翻译、OCR工具
ocr·文字识别·自动翻译·翻译·划词翻译·截图翻译
垦***耪5 小时前
台达 DVP ES2 与 3 台英威腾 GD 通讯程序(TDES - 12)开发实战
ocr
homelook9 小时前
uniapp蓝牙demo
uni-app
2501_915909061 天前
手机崩溃日志导出的工程化体系,从系统级诊断到应用行为分析的多工具协同方法
android·ios·智能手机·小程序·uni-app·iphone·webview
TG:@yunlaoda360 云老大1 天前
阿里云国际站代理商RPA跨境服务的适用场景有哪些?
大数据·阿里云·rpa
郑州光合科技余经理1 天前
技术视角:海外版一站式同城生活服务平台源码解析
java·开发语言·uni-app·php·排序算法·objective-c·生活
翼龙云_cloud1 天前
阿里云渠道商:轻量应用服务器连接常见问题与解决指南
服务器·阿里云·云计算
MonkeyKing_sunyuhua1 天前
使用ARQ做PDF OCR和 图片OCR的任务的方案
pdf·ocr