使用百度识图 完成图片识别和文字识别

该博客介绍如何借助百度识图技术进行图片内容识别及文字识别。通过前端接口调用,详细讲解了实现实例,适用于前端开发者进行图像处理应用开发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import Taro , { Component, Config } from '@tarojs/taro';
import { View, Text } from '@tarojs/components';
import './index.scss'


export default class ImageIndex extends Component<any, any> {
  config: Config = {
    navigationBarTitleText: '图像识别'
  }
  state = {
    res: ''
  }

  // 选择照片
  chooseImg(type) {
    let self = this
    Taro.chooseImage({
      count: 9
    })
    .then((res) => {
      let tempFilePaths = res.tempFilePaths
      tempFilePaths.forEach((tempFilePath) => { 
        Taro.getFileSystemManager().readFile({
          filePath: tempFilePath, //选择图片返回的相对路径
          encoding: 'base64', //编码格式
          success: res => { //成功的回调
            let url = ''
            if (type == 'image') {
              // 图片识别
              url = 'https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general?access_token='
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值