【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>
相关推荐
weixin_408099671 小时前
身份证OCR识别API接入实战:6种自动化脚本3分钟搞定(含天诺/按键精灵/易语言/C#示例)
ocr·图像识别·api对接·易语言·自动化脚本·身份证ocr·石榴智能
阳光先做6 小时前
uniapp打包鸿蒙安装包问题
uni-app
暮雨疏桐7 小时前
阿里云从 OSS 将 CSV 推送至内网机器方案
阿里云·云计算·php
a752066287 小时前
OpenClaw 连接阿里云百炼完整图文实操教程
人工智能·阿里云·云计算·ai办公·openclaw·小龙虾·小龙虾一键部署
鱼在在7 小时前
PP-StructureV3 开启高性能模式转onnx 报错和找不到hpi_model_info_collection.json
ocr·paddle
weixin199701080168 小时前
《求教:用阿里云处理Ozon图片的具体参数怎么设置,搜索匹配度最高?》
阿里云·云计算
认真的薛薛8 小时前
阿里云: A记录 & CNAME
服务器·前端·阿里云
koping_wu10 小时前
【Claude Code】Mac安装Claude Code、通过阿里云百炼接入Claude Code
macos·阿里云·云计算·ai编程
创意岛12 小时前
品牌打造的低成本高回报之路
阿里云
XM_jhxx12 小时前
AI图纸识别 vs 传统OCR:差距在哪里?
人工智能·ocr