【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>
相关推荐
zhoulcc12 小时前
为什么 uni-app 小程序里并排选项总变竖排?缺了 box-sizing 重置
前端·css·小程序·uni-app·box-sizing
用户112936112191 天前
没写样式为什么还找我要 wxss?uni-app 这个 ENOENT 坑多数人误判了
前端·微信小程序·uni-app
开开心心就好1 天前
游戏安装报错缺环境?运行库整合包补上
java·mysql·游戏·pdf·ocr·音视频·lua
开开心心就好1 天前
重复图片查找工具,拖入文件夹就开搜
java·mysql·pdf·ocr·vim·音视频·emacs
云老大-阿里云国际站代理商2 天前
阿里云国际站CDN回源502错误,源站正常该如何排查?
阿里云·云计算
长春小霸王2 天前
uniapp仿KFC点餐(套餐)界面
uni-app
anyup2 天前
2027 年初,uni-app 官方停更,老项目该何去何从?
前端·vue.js·uni-app
showker2 天前
阿里云 CentOS 6 编译安装 PHP 8.5 完整指南
阿里云·centos·php
梅雅达编程笔记2 天前
扫描件解析出来是空的:RAG 智能问答 PDF 解析完整教程
ocr·智能问答·毕设·pdf解析·paddleocr·pdfplumber·rag