【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>
相关推荐
宠友信息5 小时前
消息序号如何保证即时通讯源码聊天记录稳定加载
java·spring boot·redis·python·mysql·uni-app
2501_9160088911 小时前
苹果上架工具怎么选 不用 Mac 上架 App Store 的几种方案
android·macos·ios·小程序·uni-app·iphone·webview
宠友信息11 小时前
MySQL复合索引与Druid优化仿小红书源码个人主页查询链路
数据库·spring boot·websocket·mysql·uni-app
烦德恒14 小时前
本地五恒系统五恒品牌哪家好
阿里云
翔云 OCR API16 小时前
全票种发票识别API|发票OCR接口助力企业财税合规增效
ocr
小保CPP18 小时前
OCR C++ Tesseract从OpenCV中获取图片
c++·人工智能·opencv·ocr·模式识别·光学字符识别
全云在线allcloudonline1 天前
上海阿里云代理商怎么选?跨区域交付能力核验清单
阿里云·云计算·企业上云
阿斯科阀门1 天前
惠州自动化阀门厂家
阿里云
小保CPP1 天前
OCR C++ Tesseract生成可搜索的pdf
c++·人工智能·ocr·模式识别·光学字符识别